|
-
Mar 22nd, 2000, 03:57 AM
#1
Thread Starter
Frenzied Member
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.
-
Mar 22nd, 2000, 04:39 AM
#2
Frenzied Member
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.
-
Mar 22nd, 2000, 05:00 AM
#3
Member
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
-
Mar 22nd, 2000, 05:21 AM
#4
Thread Starter
Frenzied Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|