Moving Form By Dragging

Private Declare Sub ReleaseCapture Lib “user32″ ()
Private Declare Function SendMessage Lib _
“user32″ Alias “SendMessageA” (ByVal hwnd As Long, _
  ByVal wMsg As Long, ByVal wParam As Integer, _
  ByVal lParam As Long) As Long

Public Sub FormDrag(theForm As Form)
  Call SendMessage(theForm.hwnd, &HA1, 2, 0&)
End Sub

Private Sub Form_MouseDown(Button AsInteger, _
Shift As Integer, X AsSingle, Y As Single)

  FormDrag Me ”Dragging
End Sub

Useful Links for Visual Basic



API, Hooking and SubClassing

Helper Tools – Add-In



Documentation Tools

Notes : Please inform me if you found any broken link. I do appreciated for your help.


Differences between Image and PictureBox

Image control

  • a "lightweight" control that has no device context (or hDC) or it's own.
  • can display a gif file loaded into the picture property with a transparent background.
  • flicker when moved at runtime.
  • can only be z-ordered (layered) over another lighweight control.
  • has Stretch property. Otherwise, ImageControl can stretch the image.
  • No AutoSize Property.
  • is not a container control.
  • no OLE drag/drop.
  • PaintPicture doesnt' work. and no drawing or printing ability (printing to the image contained therein)

Image control

  • Has Hwnd and Hdc.
  • no transparent background.
  • doesn't flicker when moved at runtime.
  • No layered.
  • No Stretch Property
  • Has Autosize Property
  • is a container control.
  • OLEDrag/Drop
  • Work with PaintPicture.

References URL(s) ~


VB6 – Detecting whether the program is running under the control of Visual Studio or not..

Drag Article : Moved from Old Blog

Private Declare Function GetModuleHandle _
Lib "kernel32" Alias _
"GetModuleHandleA" _
(ByVal lpModuleName As String) As Long </span>
<span style="font-family: verdana; font-size: 85%">
Public Function TestEnvironment() As Boolean
Dim ModuleHandle As String
Dim EnvFileName As String
Dim EnvVal As Variant
Dim ReturnVal As Long
Dim i As Long
EnvVal = _
Array("vb.exe", _
"vb32.exe", _
"vb5.exe", _
For i = LBound(EnvVal) To UBound(EnvVal)
ModuleHandle = EnvVal(i)
ReturnVal = GetModuleHandle(ModuleHandle)
If ReturnVal  0 Then
EnvFileName = ModuleHandle
TestEnvironment = True
Exit For
End If
End Function

Private Sub Command1_Click()
If TestEnvironment() = True Then
MsgBox ("Running under IDE")
MsgBox ("Running as EXE")
End If
End Sub

Another way to do is to detect whether the Visual Studio 6 IDE open or not using some API.

References Link
Question: How can I test whether a program is running at design time or run time using VB6?