Results 1 to 2 of 2

Thread: VB - Moving Forms without Title Bar

  1. #1

    Thread Starter
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171

    VB - Moving Forms without Title Bar

    VB Code:
    1. Option Explicit
    2.  
    3. Private Declare Function ReleaseCapture Lib "user32" () As Long
    4. 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
    5.  
    6. Const WM_NCLBUTTONDOWN As Long = &HA1
    7. Const HTCAPTION As Long = 2
    8.  
    9. Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    10.     Dim lngReturnValue As Long
    11.     If Button = vbLeftButton Then
    12.         Call ReleaseCapture
    13.         lngReturnValue = SendMessage(Me.hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&)
    14.     End If
    15. End Sub


    Has someone helped you? Then you can Rate their helpful post.

  2. #2

    Thread Starter
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171

    Another way

    VB Code:
    1. Option Explicit
    2.  
    3. Dim XX As Integer
    4. Dim YY As Integer
    5.  
    6. Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    7.     XX = X
    8.     YY = Y
    9. End Sub
    10.  
    11. Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    12.     If Button = vbLeftButton Then
    13.         Me.Left = Me.Left - XX + X
    14.         Me.Top = Me.Top - YY + Y
    15.     End If
    16. End Sub


    Has someone helped you? Then you can Rate their helpful post.

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