[SubClass] Move & Size Forms together

A

Alessandro Baraldi

Good Night.

I've two Forms, and i need to Size and Move the First one like a
MasterForm
end the 2nd need to follow the same events like a sincronism.
The 2nd is attack to the master(1st).

So i subclass the 1st Form and i test WM_WINDOWPOSCHANGING,
then i get WINDOWPOS and i send the new Position and Size to the 2nd
one.

All work fine, but on the CaptionClick(WM_NCHITTEST) my lParam-->
WINDOWPOS returned by WM_WINDOWPOSCHANGING contain all Atoms=0
In this way passing this structure to MoveWindow the new position is
X=0
Y=0
Cx=0
Cy=0
and the 2nd form is not visible, it's too smoll..........!
Just i try to move the 1st Form all return OK and the 2nd one move and
size sincronus.

Why on WM_NCHITTEST the lParam of WM_WINDOWPOSCHANGING is resetted..?
How can i bypass this trubble

I show you my SubClass procedure, i think there is no error, because
work
good, when no reset is made on lParam.

Public Function NewWindowProc(ByVal hwnd As Long, _
ByVal msg As Long, _
ByVal wParam As Long, _
ByVal lParam As Long) As Long


Dim mWP As WINDOWPOS

Select Case uMsg
Case WM_WINDOWPOSCHANGING
CopyMemory mWP, ByVal lParam, LenB(mWP)


Me.Caption = "X=" & mWP.X & " Y=" & mWP.Y & _
" CX=" & mWP.cx & " CY=" & mWP.cy


Call MoveWindow(Forms![~Ancora].hwnd, _
mWP.X + mWP.cx, mWP.Y, _
mWP.cx, mWP.cy, 1)


End Select
NewWindowProc = CallWindowProc(OldWindowProc, hwnd, msg,
wParam,lParam)


End Function

(Sorry for English mistake)
Tnx in advance.

Alessandro(IT)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top