-
Dear All Friends,
I hope to post a question on manipulating multiple forms.
My application has a main window and several smaller toolwindows like the look of Photoshop.
I have used the function (suggested by a nice member in the forum):
**********************************************************
In Genral Declaration:
______________________
Private Declare Function SetWindowPos Lib "user32" _
(ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
In MDIForm_Load:
________________
frmToolbox1.Show
SetWindowPos frmToolbox1.hwnd, -1, 0, 0, 0, 0, 3
:
:
etc
**********************************************************
to display the toolwindow forms on top of the main form.
When I switch from my application to another like a browser by clicking the tab on the taskbar, the toolwindows still display on top of the another application. This is very misleading and inconvenient to the users.
If I want the toolwindows display only when my application main window is displayed / on focus, how can I achieve this?
Thank you very much for your help.
-
You may try this:
Code:
------------------------------------------------
¡® Put this on your toolwindows
Option Explicit
Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, _
ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, _
ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Private Sub Form_GotFocus()
'Set your form topmost
SetWindowPos hwnd, -1, 0, 0, 0, 0, 3
End Sub
Private Sub Form_LostFocus()
'Cancel the topmost position of your form and put it on the taskbar
SetWindowPos hwnd, -2, 0, 0, 0, 0, 3
End Sub
------------------------------------------------
-
You may try this:
Code:
------------------------------------------------
¡® Put this on your toolwindows
Option Explicit
Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, _
ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, _
ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Private Sub Form_GotFocus()
'Set your form topmost
SetWindowPos hwnd, -1, 0, 0, 0, 0, 3
End Sub
Private Sub Form_LostFocus()
'Cancel the topmost position of your form and put it on the taskbar
SetWindowPos hwnd, -2, 0, 0, 0, 0, 3
End Sub
------------------------------------------------
Is that what you want?
-
well if ur main app loses focus then tell it to minimize all other forms in the lost focus event
-
Yes. theman32x is right. We can put other code in that event. And it seems better to put the SetWindowsPos function in the Form_GotFocus event than in the Form_Load event.
-
you know to avoid all the coding you could try to make your app into an MDI ... like AOL ... that way ur app will be the main form and everything else will be its children
so if you have aol u've seen how everything in it minimize with the main app because everything is inside it