0

Is it possible to track when an mfc application terminates? I would like to track when my mfc application terminates so that I can show the task bar on termination.

CWnd* pWnd = CWnd::FindWindow("Shell_TrayWnd", "");
pWnd->ShowWindow(SW_HIDE);

The above lines of code are used to show and hide the task bar windows. I would like to know if there is any possiblity to track the task manager.

shivcena
  • 2,023
  • 8
  • 24
  • 50

3 Answers3

0

If it's an MFC application use the CWinApp::ExitInstance override to finish application termination cleanup.

If you're looking to write an app to monitor application termination (e.g. proper shutdown or crash) you can use a Mutex. A good example described here:

Best way to detect an application crash and restart it?

Community
  • 1
  • 1
snowdude
  • 3,854
  • 1
  • 18
  • 27
0

Why do you want to hide the taskbar? Hiding the taskbar is flat out wrong and rude. Why? Because you don't own it. The taskbar is managed by the system and owned the user; if the user wanted it hidden, he would have hidden it himself.

Just like you don't go 'hiding' cars you don't own, you shouldn't go hiding windows you don't own.

If nothing else, if your app crashes, the user is screwed and will most likely be forced to log off, and then back on to recover their taskbar.

If you need a full-screen app, then write a full-screen app using the available functionality & APIs. If you are on VS2010 and later consider using CFullScreenImpl which is documented at http://msdn.microsoft.com/en-us/library/cc308980.aspx.

Or check this out, right here on StackOverflow: How to create full screen window with MFC?.

A quick Google search also revealed this CodeProject link: http://www.codeproject.com/Articles/9632/Views-in-Full-Screen-Mode

Community
  • 1
  • 1
Nik Bougalis
  • 10,495
  • 1
  • 21
  • 37
-1

Use the NOTIFYICONDATA structure and associated api to track

Sivaraman
  • 438
  • 2
  • 9
  • i found half of the solution, WM_CLOSE is the message handler tracks when pressing end task of windows task manager. but i want to know the message handler when click end process button in windows task manager. – shivcena Oct 22 '12 at 07:39
  • There is no message for end process. End process by definition is a dirty shutdown of the executable. The OS simply stops it. – GazTheDestroyer Oct 22 '12 at 08:04
  • @Gaz : is their any other way to notify end process. – shivcena Oct 22 '12 at 09:10
  • The only other way would be to write a watchdog type application that periodically polls for the existence of the watched app. – GazTheDestroyer Oct 22 '12 at 09:13
  • @Gaz : i cant able to find ant samples by googling , do u have any samples or links for watchdog type of application. this seems very new to me.. – shivcena Oct 22 '12 at 09:20