Results 1 to 4 of 4

Thread: ?: making a window moveable

  1. #1
    Staifour
    Guest

    ?: making a window moveable

    hi all
    i've made a form with the value "none" in the border style property, but i want my form to be moveable, i remeber someone here giving some API functions that does that, can anyone help ??
    thanks in advance

  2. #2
    Hyperactive Member Alan777's Avatar
    Join Date
    Jan 2001
    Location
    New Zealand
    Posts
    303
    You don't even need APIs for this.

    VB Code:
    1. Dim prevX As Single, prevY As Single
    2.  
    3. Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    4.     prevX = X
    5.     prevY = Y
    6. End Sub
    7.  
    8. Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    9.  
    10.  If Button = 1 Then Move Left - (prevX - X), Top - (prevY - Y)
    11.  
    12. End Sub
    "Today's mighty oak is just yesterday's nut,
    that held its ground."

  3. #3
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

  4. #4
    Hyperactive Member Alan777's Avatar
    Join Date
    Jan 2001
    Location
    New Zealand
    Posts
    303
    Just to bring what mendhak is linking to into focus:

    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.  
    4. Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    5.     Const WM_NCLBUTTONDOWN = &HA1
    6.     Const HTCAPTION = 2
    7.     If Button = 1 Then
    8.         ReleaseCapture
    9.         SendMessage Me.hWnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&
    10.     End If
    11. End Sub

    So you can do it either way
    "Today's mighty oak is just yesterday's nut,
    that held its ground."

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