Link to home
Start Free TrialLog in
Avatar of Gunjitsu
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?
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

try the following:
PopupMenu Menu

Honestly, I don't have your problem, and i used just this code in the MouseUp Event...
ASKER CERTIFIED SOLUTION
Avatar of samopal
samopal

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Gunjitsu
Gunjitsu

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

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
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 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. :(
What line of programm gives your this error?
Where did you put SetForegroundWindow declaration?
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
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
its
SetForegroundWindow Me.hwnd
not
SetForegroundWindow Me