Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Send to tray external applications with dynamic titles

Status
Not open for further replies.

OmniCog

Programmer
Jan 23, 2004
27
0
0
CA
How do I send open windows to tray if the windows contain dynamic titles, and the proccess was not created by the program?

How would I send an explorer window, or a music player that changes it plays a song, or a word document to tray?

I'm new to delphi and know how to send my own applications to tray, and have read about sending external applications to tray using ShellAPI, but they require that a) the proccess was created by the application or b) the title is static.

TIA
 
What are you calling tray? The system tray (where the clock and the antivirus are) or the task bar (where the minimized apps appear)?

And why the tittle need to be static? Can you give us a hint about what API functions are you refering too?

If, by chance, you are refering to FindWindow API, you can use the title or the class name. While the title can be variable, the class name never is.

Please, elaborate a little more so we can help you.

buho (A).
 
Thnx for the reply Buho

By tray I mean system tray, and yes I was refering to FindWindow, the problem is that the program does not know the windows name.

I know a program in VB 'hides' a window by having a user select it with his mouse. The window name will then appear in a list so that it can be restored. I'm looking for similiar code in Delphi. An example would be nice, if it is not too much work.
 
1) Use some tool like WinSight or WinSpy to figure out the window class name.

2) Use FindWindow (with the class name) to get the window handle.

3) Use ShowWindow with said handle to minimize or restore the window (you can send a WM_SIZE instead of using ShowWindow). You can close it too (sending a WM_QUIT) and/or do another funny things (as moving it out of your way).

Now, to send an app to the tray area, I'm not sure about. The function used is Shell_NotifyIcon, but I believe we are facing some problems here.

a) Shell_NotifyIcon uses a NotifyIconData record and I don't know if Windows can marshall it between processes.

b) If the app is not designed as a tray app, I have no idea how it will react if you manage to set it in the tray. Not to say how Windows will react after sending it a NIM_XXXX message.

If you are going to try, please keep us informed here.

buho (A).
 
Is there an api function that would return the window's handle from cursor coords?
 
WindowFromPoint; ChildWindowFromPoint and ChildWindowFromPointEx.

buho (A).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top