|
-
Feb 28th, 2002, 12:52 AM
#1
Thread Starter
Hyperactive Member
Move child window with parent...
Hello,
Need some help real quick. I have a parent Window (form) that loads a single non-modal child Window. My problem is that when I move the parent window, whether with mouse or keyboard, I want the child Window to move also with it`s parent. It should be such that the child seems to follow the parent one.
So if any of you have any idea about how I could detect a form move or any sample code in that direction would be much appreciated.Thanx...
-
Feb 28th, 2002, 04:01 AM
#2
Frenzied Member
Hi,
The EventVB.ApiWindow class implements a Form Move event. It does this by subclassing the form and trapping the WM_MOVE message.
To use this:
Code:
Option Explicit
Dim WithEvents vbLink As EventVB.APIFunctions
Dim WithEvents vbWnd As EventVB.ApiWindow
Private Sub Form_Load()
Set vbLink = New EventVB.APIFunctions
Set vbWnd = New ApiWindow
vbWnd.hWnd = Me.hWnd
vbLink.SubclassedWindows.Add vbWnd
End Sub
Private Sub Form_Unload(Cancel As Integer)
vbLink.SubclassedWindows.Remove vbWnd
End Sub
Private Sub vbWnd_Move(ByVal x As Long, ByVal y As Long, Cancel As Boolean)
Me.Caption = "(" & x & "," & y & ") Location"
End Sub
HTH,
Duncan
-
Feb 28th, 2002, 04:31 AM
#3
Thread Starter
Hyperactive Member
That would have been fine but the company for which I`m working for does not want to use any third party Dlls so I need the piece of code that can allow me do that....
-
Feb 28th, 2002, 05:26 AM
#4
Frenzied Member
See the source code.
Extract...
Code:
Public Event Move(ByVal x As Long, ByVal y As Long)
'.......in subclass procedure.....
If wMsg = WM_MOVE Then
x = LoWord(lParam)
y = HiWord(lParam)
RaiseEvent Move(x, y)
'..utility functions.....
'\\ --[LoWord]------------------------------------------------------------------
'\\ Returns the low word component of a long value
'\\ Parameters:
'\\ dw - The long of which we need the LoWord
'\\
'\\ --------------------------------------------------------------------------------
'\\ (c) 2001 - Merrion Computing. All rights to use, reproduce or publish this code reserved
'\\ Please check http://www.merrioncomputing.com for updates.
'\\ --------------------------------------------------------------------------------
Public Function LoWord(dw As Long) As Integer
If dw And &H8000& Then
LoWord = &H8000 Or (dw And &H7FFF&)
Else
LoWord = dw And &HFFFF&
End If
End Function
'\\ --[HiWord]-------------------------------------------------------------------
'\\ Returns the high word component of a long value
'\\ Parameters:
'\\ dw - The long of which we need the HiWord
'\\
'\\ --------------------------------------------------------------------------------
'\\ (c) 2001 - Merrion Computing. All rights to use, reproduce or publish this code reserved
'\\ Please check http://www.merrioncomputing.com for updates.
'\\ --------------------------------------------------------------------------------
Public Function HiWord(dw As Long) As Integer
If dw And &H80000000 Then
HiWord = (dw \ 65535) - 1
Else
HiWord = dw \ 65535
End If
End Function
HTH,
Duncan
-
Feb 28th, 2002, 05:52 AM
#5
Frenzied Member
..alternatively, you could steer your company towards a code subscription ? It is likely that this will save them a great deal of time and money in the long run.
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
|