Results 1 to 4 of 4

Thread: [RESOLVED] Move Fixed Border Form

  1. #1

    Thread Starter
    Registered User
    Join Date
    Apr 2006
    Posts
    62

    Resolved [RESOLVED] Move Fixed Border Form

    Hi, I have a form which has a borderstyle of fixed single. I have removed the controlbox and set caption to nothing so that I don't have a title bar on my form.

    How can I move around my form by clicking anywhere on the form and dragging it? Is this possible? Form.Move?

    Thanks!

  2. #2
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Move Fixed Border Form

    VB Code:
    1. Private Declare Function ReleaseCapture Lib "user32.dll" () As Long
    2.  
    3. Private Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" ( _
    4.     ByVal hWnd As Long, _
    5.     ByVal wMsg As Long, _
    6.     ByVal wParam As Long,
    7.     ByRef lParam As Any _
    8. ) As Long
    9.  
    10. Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    11.     Const WM_NCLBUTTONDOWN As Long = &HA1
    12.     Const HTCAPTION As Long = 2
    13.     If (Button And vbLeftButton) = vbLeftButton Then
    14.         ReleaseCapture
    15.         Call SendMessage(Me.hWnd, WM_NCLBUTTONDOWN, HTCAPTION, ByVal 0&)
    16.     End If
    17. End Sub

  3. #3
    Smitten by reality Harsh Gupta's Avatar
    Join Date
    Feb 2005
    Posts
    2,938

    Re: Move Fixed Border Form

    try this:
    VB Code:
    1. Private Declare Function SendMessage Lib "User32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
    2. Private Declare Sub ReleaseCapture Lib "User32" ()
    3. Const WM_NCLBUTTONDOWN = &HA1
    4. Const HTCAPTION = 2
    5. Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    6.     'KPD-Team 1999
    7.     'URL: [url]http://www.allapi.net/[/url]
    8.     'E-Mail: [email][email protected][/email]
    9.     Dim lngReturnValue As Long
    10.     If Button = 1 Then
    11.         'Release capture
    12.         Call ReleaseCapture
    13.         'Send a 'left mouse button down on caption'-message to our form
    14.         lngReturnValue = SendMessage(Me.hWnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&)
    15.     End If
    16. End Sub
    17. Private Sub Form_Paint()
    18.     Me.Print "Click on the form, hold the mouse button and drag it"
    19. End Sub
    Show Appreciation. Rate Posts.

  4. #4

    Thread Starter
    Registered User
    Join Date
    Apr 2006
    Posts
    62

    Re: Move Fixed Border Form

    Thanks guys, much appreciated.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width