Question Resize and already open window to automatically accomodate a new open window

pankajsingh5k

New member
Joined
Feb 24, 2009
Messages
1
Programming Experience
Beginner
Hi guys,

if you guys have used office 2003 or better( i am sure all) then you would have seen that when the help window open it causes the active windows say of MS WORD to change accordingly so that this help windows fits with it along the right side and this functionality i want to implement in my VB windows application and have no idea how to do it...

Also i have seen this feature in GOOGLE DESKTOP GADGETS...

i want to implement that when my application opens which ever is the active window( of any application) snaps to the left and allows my application to fir in the right hand side

please if any of you have implemented this feature plz tell how to do it...i am developing my application in VS 2005 using Visual Basic....
 
You need to use the Windows APIs, with the GetForegroundWindow and GetWindowRect functions you should be able to find where to position your own window. pinvoke.net: the interop wiki! can help you with the declarations. Example code to forms Load event:
VB.NET:
Expand Collapse Copy
Dim r As New RECT
Dim h As IntPtr = GetForegroundWindow()
If h <> Me.Handle AndAlso GetWindowRect(h, r) Then
    Me.SetBounds(r.Right, r.Top, 150, r.Height)
End If
 
Back
Top