Solved

URGENT: Problem Sending Windows Message to taskbar icon.

Posted on 2003-11-11
5
437 Views
Last Modified: 2008-03-03
I have a taskbar icon (program) that is supposed to open a form when a user double clicks on a file associate with the program.  I don't want to open a new instance, so in the Main function, I check to see if there is already an instance running, if so, write the filename to registry and tell the existing tray program to open it via SendMessage imported from user32.dll.  The problem is, the taskBar has  form that is run as minimized wtih ShowInTaskBar set to false.  When I set this to true, it accepts the Windows message correctly.  When I set it to false, it does not.  

how can I send a windows message to the application in the tray?  Is it possible?  If not, is there some way I can notify the .exe without have to setup remoting (I don't want to use TCP/IP, so this would be a problem).  

0
Comment
Question by:jjacksn
  • 2
  • 2
5 Comments
 
LVL 22

Accepted Solution

by:
_TAD_ earned 500 total points
Comment Utility


If you are using WIN API then you want to use the Shell_NotifyIcon Function  


here is a page from the MSDN:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/functions/shell_notifyicon.asp
0
 
LVL 22

Expert Comment

by:_TAD_
Comment Utility


More or less, you need to tell the tray icon to show the window/applicaiton (whether minimized or not is up to you), you then send your window message to the open application like you normally would
0
 
LVL 5

Author Comment

by:jjacksn
Comment Utility
_TAD_

I'm slightly confused.

How do you "Show" something that is minimized.  I don't think the application is listening for Widows Messages.  When the ShowInTaskBar boolena is set to true, everything works like it is supposed to.  I think the form is already running in its minimized state, as I am calling Application.Run on the form...
0
 
LVL 10

Expert Comment

by:ptmcomp
Comment Utility
May be you need a Window Messagequeue to send and receive Messages.
0
 
LVL 5

Author Comment

by:jjacksn
Comment Utility
I got it.

I was using processes to find the process by the same name, then callling process.handle or process.mainWindowHandle (i still think the latter should work)

but doing a simple FindWindow works.
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Article by: Ivo
Anonymous Types in C# by Ivo Stoykov Anonymous Types are useful when  we do not need to follow usual work-flow -- creating object of some type, assign some read-only values and then doing something with them. Instead we can encapsulate this read…
Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

772 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

10 Experts available now in Live!

Get 1:1 Help Now