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

Why do VB-compiled apps disappear? 1

Status
Not open for further replies.

AndyGroom

Programmer
May 23, 2001
972
0
0
GB
Can anyone tell me why VB-compiled EXEs 'disappear' if I do an End Task on an Explorer window in XP?

I have several VB EXEs running, for example an FTP program I wrote, plus a utility running in the system tray. If I do Ctrl-Alt-Del and End Task on a Windows Explorer window (causing a complete screen refresh - icons, taskbar etc), all the VB-compiled apps disappear even though they're still running.

You can do Alt-Tab to get them to reappear on the Taskbar, although the one in the system tray never reappears.

- Andy
___________________________________________________________________
If you think nobody cares you're alive, try missing a couple of mortgage payments
 
If I understand Windows XP correctly If you go in and kill the "EXPLORER" process then that is the desktop you are killing. And when it restarts automatically it might not show buttons for previously running apps.

Maybe you should kill "Applications" and leave the "Explorer" process alone??

Warning: I could be totally wrong with all of this....
 
That's true but lots of other apps reappear, things like IE and Office apps, plus system tray utilities reappear too, it seems like Windows treats VB apps differently for some reason.

- Andy
___________________________________________________________________
If you think nobody cares you're alive, try missing a couple of mortgage payments
 
There's a message WM_TASKBARCREATED that you should respond to.

Greetings,
Rick
 
>End Task on a Windows Explorer window ... causing a complete screen refresh

It does substantially rather more than that. One of the things it does it to completely reinitialise the system tray, so you need to notify it that you want to re-add your icon again ... but that means your application needs to know when Explorer restarts

However almost every single VB system tray example on the internet is based on a quite old example from Microsoft, which doesn't include any way of spotting an Explorer (or, more specifically, system tray) restart (mainly because no such notification existed when the example was first written).

So what you need to do is watch for a specific window message registered as "TaskbarCreated") that is sent to all top level windows when the system tray is resarted, and readd your icon when you spot it ...
 
Thanks for that, it sounds like an answer as far as the system tray utility is concerned.

As fas as other apps go, is it possible to get them to reappear on the Taskbar? If you Alt-Tab to them they reappear on the Taskbar but if you're a non-technical Windows user you'll just assume that the program isn't running any longer and try to open it again.

If I watch for the wm_taskbarcreated message, what code should I then run to refresh my app?

- Andy
___________________________________________________________________
If you think nobody cares you're alive, try missing a couple of mortgage payments
 
>is it possible to get them to reappear on the Taskbar

Yes. Easiest way (in my opinion) is to use the shell's TaskbarList object which exposes the ITaskbarList interface which has a simple ActivateTab method to which you pass your window's handle.

Trouble is that the TaskbarList doesn't get exposed in any COM object that VB understands ... so I'd suggest getting hold of an OLE type library that does. The one I favour is edanmo's (OLELIB.TLB) which can be found here:
 
(oh, and to be a pedant there's no such message constant as WM_TASKBARCREATED ...)
 
Yes, after digging a little deeper in my ancient project I noticed that this was a "constant" that I myself had cleverly named after the windows standard messages namimg convention and that was retrieved by calling RegisterWindowMessage(TEXT("TaskbarCreated"));

However, there was no need for correction since you already were there....

Greetings,
Rick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top