Solved

Problem with Systray

Posted on 2003-10-23
2
273 Views
Last Modified: 2010-05-01
Hi, my english is not very good, but anyway:
my application puts an icon in the systray and when you rightclick the icon a popup menu appears; ok that works very good, but the problem is that when you rightclick on the icon and you later decide not to click on any of the menu's on the popup menu, the popupmenu stays, nomather where you click even if you click somewhere on the desktop it does not go away.

please help me with this problem.

thank you,
Stasio
0
Comment
Question by:stasio
2 Comments
 
LVL 5

Accepted Solution

by:
JCinDE earned 250 total points
ID: 9608814
It's really easy to solve.

Add this API declaration to your code:

    Public Declare Function SetForegroundWindow Lib "user32" Alias "SetForegroundWindow" (ByVal hwnd As Long) As Long

Call it right before you call the PopupMenu function:

    SetForeGroundWindow Me.hWnd
    PopupMenu mnuPopup

This causes your app to take focus before displaying the menu. When you click away from the menu, your app loses focus again and destroys the menu. If you don't call this then your app never takes focus until you actually click a menu item...so if you click somewhere else instead of the menu, it never receives the 'lost focus' message and doesn't get rid of the menu.

Hope it helps!
-JC
0
 
LVL 27

Expert Comment

by:planocz
ID: 10173594
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
No response from stasio from 10/23/2003 comment
Award points to JCinDE is recommend.
Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

planocz
EE Cleanup Volunteer
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now