|
-
Feb 24th, 2000, 11:08 AM
#1
Thread Starter
Member
My program has one main form open all the time, and if you move the cursor over a tray icon, another form is shown. Here's the problem - If another application is in front of the main form window (i.e. the main form is in the background) and the tray icon form is shown, the main form window pops to the front. This is really annoying, since the whole point of the tray icon form is to have a small, unobtrusive way to access some functions from the main window. Unloading the main form window is not an option. Please advise! Thanks in advance...You guys are great!
--Mike Wellems
PowerQuery Development
-
Feb 25th, 2000, 12:31 AM
#2
Frenzied Member
Here's an idea...
You might just try sending your form to the bottom of the z-order (sending it to the back) in the activate event of the tray form (the one that brings it to the front).
Use the SetWindowPos API to send a window to the back, as in the following example. Here I am assuming that Form1 is your main form (change the name if necessary). Im not sure this works, since I dont have VB here and I just got this from the VB API web site.
Copy into a standard module:
Code:
Option Explicit
Public 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
Public Const SWP_NOMOVE = 2
Public Const SWP_NOSIZE = 1
Public Const FLAGS = SWP_NOMOVE Or SWP_NOSIZE
Public Const HWND_BOTTOM = 1
Copy into the Form_Activate event of the form that is bringing the main form to the top:
Code:
Option Explicit
Private Sub Form_Activate()
Dim lRetVal As Long
lRetVal = SetWindowPos(Form1.hwnd, HWND_BOTTOM, _
0, 0, 0, 0, FLAGS)
End Sub
Let me know if this works!
Hope that helped,
~seaweed
-
Feb 25th, 2000, 06:56 AM
#3
Hyperactive Member
On the other hand, if you have the user do it on Mouse_Click, rather than Mouse_Over, the form will never pop up unless the user wants it to. I prefer this method to having it pop up on mouse over.
-
Feb 25th, 2000, 01:04 PM
#4
Thread Starter
Member
Thanks for your help. The Z-order solution, while not perfect, will make this less annoying until I figure out a more foolproof way. My thinking is that there's got to be a way to turn off this "linking" behavior. I mean, in other applications, the forms don't all show together... I realize they might not be made in VB, but I think there's probably some API call that will separate the windows. Another thoought that crossed my mind - how easy is it to have two separate programs talk to each other? The tray popup and main window could be two separate EXEs if it was easy to communicate between them.
Thanks,
Mike Wellems
PowerQuery Development
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
|