|
-
Sep 28th, 2000, 06:27 PM
#1
Thread Starter
Hyperactive Member
In an app I have an icon on the tray which will make a window visible again using ShowWindow API.
This all works fine. Only thing is the window doesn't really have the focus - it is the topmost window
(I use SetForegroundWindow API to get it there), but the titlebar isn't colored until I click it.
Is there a way to get this window selected, i.e. in the state is was before it was hidden?
I tried Putfocus API, didn't work.
Maybe generating a mouse click at it?
P.S.
What's the best way of reading a windows size (not just min or max), position, etc and
restoring a hidden window to the state it was before being hidden? The ShowWindow API restores
the window to a min size.
[Edited by dsy5 on 09-28-2000 at 07:49 PM]
-
Sep 28th, 2000, 06:39 PM
#2
Lively Member
Can you just use the setfocus method of the form? i.e. frmMain.SetFocus
-
Sep 28th, 2000, 06:50 PM
#3
Thread Starter
Hyperactive Member
Originally posted by KillemAll
Can you just use the setfocus method of the form? i.e. frmMain.SetFocus
I guess I wasn't too clear here. It is not the form I want to show, it is a running app
which was previously hidden.
[Edited by dsy5 on 09-28-2000 at 07:52 PM]
-
Sep 28th, 2000, 07:00 PM
#4
Lively Member
so the hidden app is not part of the same application in VB that you are trying to do this with? like, you are trying to bring up an external hidden application from your programs icon in the systray? is that it?
-
Sep 28th, 2000, 07:03 PM
#5
The SetForegroundWindow api function works for me.
Code:
Private Declare Function FindWindow Lib "user32.dll" _
Alias "FindWindowA" (ByVal lpClassName As Any, ByVal _
lpWindowName As Any) As Long
Declare Function SetForegroundWindow Lib "user32.dll" _
(ByVal hwnd As Long) As Long
Private Sub Command1_Click()
h = FindWindow(vbNullString, "Calculator") 'Find Calculator
x = SetForegroundWindow(h) 'Give it focus
End Sub
-
Sep 28th, 2000, 07:16 PM
#6
Thread Starter
Hyperactive Member
Matthew
It works if you just call the function from code, but when you are clicking an icon in
the system tray, I believe the Mousemove event for the icon that instantiates the
SetForegroundWindow receives the focus even after you set the handle to the program
to receive focus. Am I making sense here?
At any event, the SetForegroundWindow doesn't work here.
Killemall
Yes, that's what I'm trying to do.
[Edited by dsy5 on 09-28-2000 at 08:19 PM]
-
Sep 28th, 2000, 07:22 PM
#7
Argh, making life harder, aye?
How about actually putting the code into a Command Button. And calling it in the menu property?
Code:
Private Sub menu_Click()
Command1_Click
End Sub
-
Sep 28th, 2000, 07:59 PM
#8
Thread Starter
Hyperactive Member
Originally posted by Matthew Gates
Argh, making life harder, aye?
How about actually putting the code into a Command Button. And calling it in the menu property?
Code:
Private Sub menu_Click()
Command1_Click
End Sub
I do have a right button menu on the icon that has the code in one of its selections and it works.
Its the fact that I would like to just click the icon and perform a toggle of hiding
and showing by clicking the icon. May not be possible due to that Mouse_move event of the icon itself.
Any ideas on saving and restoring the window's size possition, etc when showing with ShowWindow API?
Maybe the ShowWindowPos API?
-
Sep 29th, 2000, 07:30 PM
#9
Thread Starter
Hyperactive Member
It will work in Windows 95, so I think that with the new support for a more "friendly"
(yeah, right) system tray with Win98+, it has some different results. (Hours to find a workaround await... <sigh>)
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
|