|
-
Nov 25th, 2000, 07:12 AM
#1
Thread Starter
Addicted Member
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.
-
Nov 25th, 2000, 10:43 AM
#2
Addicted Member
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
------------------------------------------------
-
Nov 25th, 2000, 10:44 AM
#3
Addicted Member
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?
-
Nov 25th, 2000, 10:47 AM
#4
Hyperactive Member
well if ur main app loses focus then tell it to minimize all other forms in the lost focus event
-
Nov 26th, 2000, 01:55 AM
#5
Addicted Member
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.
-
Nov 26th, 2000, 12:19 PM
#6
Hyperactive Member
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
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
|