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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Destroy Event 1

Status
Not open for further replies.

jmcswain

Programmer
May 30, 2001
16
0
0
US
My application minimizes to the system tray, and it's working beautifully now. I have just two things to work out that would polish it off perfectly.

First, is there a way to prevent my app from appearing in the taskbar when it is open and visible?

Second, I'd like to keep the Close button ("X" in top right of caption bar) available to the user, but I'd like it to just hide my form instead of destroying it. Is this possible?
 
The answer is fairly simple. In your startup code, put this:

ON SHUTDOWN DO MyShutdownProg

The shutdown prg will then be executed when the user tries to quit FoxPro, either by clicking the X or using the Exit command. Your prg file can then intercept and minimize instead of shutting down, or alternately issue a QUIT if the conditions are correct.
 
Well, it's pretty much just as easy to trap the Close click in the Destroy event. The question is, how do I prevent the form from being unloaded?

Let's say my code looks like:
Code:
On Shutdown Do IgnoreClose
DO FORM frmMain NAME gfrmMain LINKED
READ EVENTS

PROCEDURE IgnoreClose
  * What do I put here to halt the destroy/unload/release???
ENDPROC
 
In the QueryUnload event of the form, issue NODEFAULT to prevent the form from unloading.

AFAIK, there's not a way to prevent the app from showing in the taskbar when the top form is visible. Though, I may be wrong.

Even if it were do-able, IMHO, I'd advocate you not. I get annoyed with those types of windows. You double-click the tray to get them to open and if they fall behind another window, you've got to minimize one-by-one looking for it or go back to the tray and double-click again to get it to come to the foreground. Frustrating. Jon Hawkins
 
Thanks, Jon, once again you have the answers I need.

You make a good point about the taskbar thing. As you probably guessed, I used your tips about forcing a single instance to activate and setforeground from the tray icon's double-click. (My caption bar does indeed change.)

After reflecting, though, I realize that I hit the taskbar to bring it to the foreground whenever it's open because you are right, it's much easier than double-clicking the little tray icon. Not to mention that all the other apps in my tray show in the taskbar when they are open.

If you haven't tried it, Bela's new bbsystray with the menu functionality is very nice, and I say well worth the 8 bucks. :)
 
Glad I could help.

IMHO, one of the most difficult tasks in Software Engineering/Programming is learning to disassociate yourself from an IT state-of-mind and thinking like the target end-user. It's typically evident in the finished software, if the developer(s) possessed that skill.

AFA Bela's software, I wouldnt hesitate to say it's worth many times more than 8 bucks. :) Jon Hawkins
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top