Results 1 to 4 of 4

Thread: Did the form move

  1. #1

    Thread Starter
    Frenzied Member Technocrat's Avatar
    Join Date
    Jan 2000
    Location
    I live in the 1s and 0s of everyones data streams
    Posts
    1,024
    I need to know if a form has moved. I am making another form dock to the main form. I need to know when the user moves the main form so I can keep the child form with it. Any ideas on how I tell? Or how to attached another form to the first one? I would perfer it to dock but will take whatever I can.

  2. #2
    Frenzied Member
    Join Date
    Mar 2000
    Posts
    1,089
    You need to subclass your form and trap the WM_WindowPositionChanged message, If you havn't done any subclassing before get a book on using the API, there'll be some examples and explanation, I can't really tell you all about it here because it's a big subject and if you get it wrong your machine just crashes so I don't recomend doing it unless you relly understand what's going on.

  3. #3
    Member
    Join Date
    Apr 1999
    Posts
    56
    This is the API that I used to dock a form in one of my programs. The form doesn't have a title bar though. You move the form by clicking on the form itself. Maybe you can adapt it to do what you want. Before I found this code, I had to use a timer which isn't very good, but it works.

    Code:
    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
    
    Private Declare Sub ReleaseCapture Lib "User32" ()
    Private Const WM_NCLBUTTONDOWN = &HA1
    Private Const HTCAPTION = 2
    
    Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Dim lngReturnValue As Long
    '// Detect the left mouse button
    If Button = 1 Then
    '// Release the capture of the mouse
    Call ReleaseCapture
    '// Move the form with the mouse
    lngReturnValue = SendMessage(Me.hWnd, WM_NCLBUTTONDOWN, _
    HTCAPTION, 0&)
    End If
    End Sub

  4. #4

    Thread Starter
    Frenzied Member Technocrat's Avatar
    Join Date
    Jan 2000
    Location
    I live in the 1s and 0s of everyones data streams
    Posts
    1,024
    I am looking in to subclassing it. Subclassing is something I have not done before. Can you recomend some place I get some go info. I have Dan Appleman guide to API but it does not talk about subclassing that well.

    My main form has a title bar. If it didn't I would do that exact thing. I had tought about a timer but that just seems like the wrong way to do it.

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