Gunjitsu
asked on
Popup menu on system tray icon
I have successfully put a system tray icon in my program, i have made it so when you right click on the icon a menu pops up. the only problem with it is the menu wont go away. usually they dissapear when you click on something else on the screen, but mine stays there.
here is the code.
Select Case X
Case 7695
Form1.WindowState = vbNormal
Form1.Show
Dim hProcess As Long
GetWindowThreadProcessId hwnd, hProcess
AppActivate hProcess
Case 7740
Me.PopupMenu Me.Menu " <<-- HERE!!
End Select
can someone tell me what im doing wrong?
here is the code.
Select Case X
Case 7695
Form1.WindowState = vbNormal
Form1.Show
Dim hProcess As Long
GetWindowThreadProcessId hwnd, hProcess
AppActivate hProcess
Case 7740
Me.PopupMenu Me.Menu " <<-- HERE!!
End Select
can someone tell me what im doing wrong?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
how do i call SetForegroundWindow on the window that owns the popup ?
In your code :
....
Case 7740
'<<-- ADD HERE!!
SetForegroundWindow Me
'<<-- ADD HERE!!
Me.PopupMenu Me.Menu
End Select
HTH
....
Case 7740
'<<-- ADD HERE!!
SetForegroundWindow Me
'<<-- ADD HERE!!
Me.PopupMenu Me.Menu
End Select
HTH
ASKER
i get a error saying variable not definied and i click debug and its got "SetForegroundWindow" highlighted...
:-)))
You have to define this API function in module
Public Declare Function SetForegroundWindow Lib "user32" Alias "SetForegroundWindow" (ByVal hwnd As Long) As Long
You have to define this API function in module
Public Declare Function SetForegroundWindow Lib "user32" Alias "SetForegroundWindow" (ByVal hwnd As Long) As Long
ASKER
i did that.
i also got another api call that gets the current windows system running time in my module. will that affect it?
when i run the program now it goes type mismatch. :(
i also got another api call that gets the current windows system running time in my module. will that affect it?
when i run the program now it goes type mismatch. :(
ASKER
i did that.
i also got another api call that gets the current windows system running time in my module. will that affect it?
when i run the program now it goes type mismatch. :(
i also got another api call that gets the current windows system running time in my module. will that affect it?
when i run the program now it goes type mismatch. :(
What line of programm gives your this error?
Where did you put SetForegroundWindow declaration?
Where did you put SetForegroundWindow declaration?
ASKER
it highlightes the word SetForegroundWindow after the error pops up.
this is how i got the code
Case 7740
SetForegroundWindow Me
Me.PopupMenu Me.Menu
End Select
this is how i got the code
Case 7740
SetForegroundWindow Me
Me.PopupMenu Me.Menu
End Select
It seems to me you are making a syntax mistake in your code. Can you send code to me? Today (Apr,13) I have some time...
dmitry_a@hotmail.com
dmitry_a@hotmail.com
ASKER
its
SetForegroundWindow Me.hwnd
not
SetForegroundWindow Me
SetForegroundWindow Me.hwnd
not
SetForegroundWindow Me
PopupMenu Menu
Honestly, I don't have your problem, and i used just this code in the MouseUp Event...