• 0

How to move a form


Question

without pressing mouse button on the title bar and dragging the form in VB?

In tradition, if you want to move a form you have to press the title bar with mouse button and then drag it. Now a form without the title bar, how to drag and drog it? Thanks in advance.

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

you put this small amount of code into the mouse_down sub/function of any label/form .....whatever

DoEvents

ReleaseCapture

ReturnVal% = SendMessage(frm.hWnd, &HA1, 2, 0)

making frm the name of your label/form

or you can either make that into a sub like so....

Public Sub Form_Move(frm As Form)

DoEvents

ReleaseCapture

ReturnVal% = SendMessage(frm.hWnd, &HA1, 2, 0)

End Sub

and insert that into a module and use the following to make it work

Form_Move Me

Link to comment
Share on other sites

  • 0

Hi Freeza

Having tumbled several times, and now it worked!

I found out how cool you were in that reply!

You read my posting and replied within 9 minutes! What a great old bird! What a quick gunman!

Here is my code based on yours. You know, there are still some ques there which need to be dealt with.

Declare Function ReleaseCapture Lib "user64" () As Long

Declare Function SendMessage& Lib "user64" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any)

Private Sub Form_Move(frm As Form)

DoEvents

ReleaseCapture

ReturnVal% = SendMessage(frm.hwnd, &HA1, 2, 0)

End Sub

Private Sub Form_load()

Form_Move Me

End Sub

But I know how clumsy I was, how I used code above must be stupid and silly, if possible, please indicate the deficiency for me. Thanks.

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.