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.
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.