mattzippyking
09-14-2004, 08:38 AM
Hi I was wonderingif any one could help me
I would like to be able to move a window automatically when I move another form.
I have tried the Repaint event on the form but this just means that the I can only move very small distancesat a time.
What I am trying to do is have my program run an seperate program and then be able to keep this program in the same place relative to my programs window.
Hope some one can help
Thanks
Matt
crabby
09-14-2004, 08:56 AM
the window that determines the slave window position, is that one of your apps or is it alien ?
mattzippyking
09-14-2004, 09:01 AM
It is an Alien program, a CAD package called Rhino
crabby
09-14-2004, 09:09 AM
well thats not so nice. i see two ways, even though there maybe more. first is you run a loop (egg timer or do-while), check the position and react according to the positions you retrieve or you could look into suclassing/hooking and catch the messages for the form you are interested in BUT suclassing external apps in VB was never a really good idea.
mattzippyking
09-14-2004, 10:14 AM
I have tried the timer as you suggested but it is acting in the same way as when I was using the Paint event. The problem seems to be that the SetWindowPos API moves the mouse focus over to the Alien window and so causes the move you were doing on the main window to be cancelled and it jumps back to its original position.
Private Sub Form_Paint()
Dim wRect As RECT
Call GetWindowRect(Me.hwnd, wRect)
Call SetWindowPos(RhinoScript.windowhandle, HWND_TOPMOST, wRect.Left + 10, wRect.Top + 140, ((wRect.Right - wRect.Left) / 2) - 20, wRect.Bottom - wRect.Top - 150, SWP_SHOWWINDOW)
end sub
00100b
09-14-2004, 11:35 AM
John has a thread here (http://www.xtremevbtalk.com/showthread.php?t=179942) concerning magnetic forms. With some slight modifications, it may be able to serve your purpose.
mattzippyking
09-15-2004, 04:43 AM
Thanks for pointing out the link.
Yes I managed to get it working. I was having a problem because I couldn't find the window proceedure for my Alien window but then I realise I didn't actually need to know it so now it is working fine.
Thanks to John for the MagneticWindow program which had the answer
Matt