PDA

View Full Version : a better DestroyWindow?


lotion
25th February 2009, 08:06 PM
I need a tiny, tiny app that just closes the current foreground window.

I ended up writing a small app that just sends the OK virtual key which works fine except that it seems HTC X Button doesn't capture the VK so the default action is executed (SmartMinimize) instead of the action I have HTC X Button set up to perform (real close).

My second solution was to write a small app to send the WM_Close message which worked fine. I later changed it to the destroy message for two reasons ... 1) terminate without any prompting and 2) because there is already a DestroyWindow function so I don't need to sendmessage:

#include "stdafx.h"
int _tmain(int argc, _TCHAR* argv[])
{
HWND hwnd = GetForegroundWindow();
DestroyWindow(hwnd);
return 0;
}

What I'd like to do is make it a bit more intelligent and, rather than Destroy blindly, prevent it from closing shell32 or cprog, yet properly close what I can only presume are it's children (such as the Programs or Settings Window).

I'm new to windows mobile native coding so I'm having some trouble debugging and developing.

lotion
6th March 2009, 05:38 PM
bump ... no developers?
If not, is anyone aware of a small application that merely closes the topmost window (actual close, not smart minimize)?

nir36
6th March 2009, 09:00 PM
Would you like me to move your thread to the Dev&Hack section?

lotion
6th March 2009, 09:57 PM
I guess but I'm a bit confused ... Last time I asked a dev question in Development and Hacking I got chastised for not posting in Q&A. :)

If it's cool with you then sure!