Page 1 of 2

PPC2002 (X) on applications

PostPosted: Feb 21, 2002 @ 9:41pm
by RICoder
What is the windows message that is sent when the little (X) in the upper corner of an app is pressed?

It is not a WM_COMMAND like in a dialog.

Hrm...is it the WM_CLOSE?

PostPosted: Feb 21, 2002 @ 9:54pm
by Kzinti
It is indeed WM_CLOSE.

PostPosted: Feb 21, 2002 @ 9:55pm
by RICoder
uh..nope. tried it. meh...

thanks though.

anyone else?

PostPosted: Feb 21, 2002 @ 10:11pm
by Dan East
Where / what are you sending it to?

Dan East

PostPosted: Feb 21, 2002 @ 10:26pm
by RwGast
not related but that button sucks it doesnt even close the app it just sends it to the background!

PostPosted: Feb 21, 2002 @ 10:44pm
by James S
WM_TERMINATE is the command that actually closes the app, I believe.
WM_MINIMIZE would be the one that brings it to the background.

PostPosted: Feb 22, 2002 @ 4:55am
by RICoder
Let me be more clear. I want my app to close, not go to the background when it is tapped. So, I want to capture that command.

I suppose I could use Spy++ or something to find out.

My app creates a ~[filename].xml temp file, and I want it gone when it closes.

PostPosted: Feb 22, 2002 @ 5:02am
by RwGast
Is there a spy++ for the ppc?

PostPosted: Feb 22, 2002 @ 5:07am
by RICoder
Yeah, do you have eVC++? It's tools->remote spy++, or you can find it in C:\Windows CE Tools\BIN if you installed to the default directory.

PostPosted: Feb 22, 2002 @ 5:12am
by RwGast
Cool thanks, i just learned something new. You should make the X close your program i guess microsoft missed that X means close not hide when they built ppc2002.

PostPosted: Feb 22, 2002 @ 5:23am
by RICoder
Ok, it's one of the following.

WM_NCACTIVATE
WM_CANCELMODE

I can't find NCACTIVATE in the help files, so I have no clue what that is. My guess it is the CANCELMODE.

PostPosted: Feb 22, 2002 @ 6:28am
by Dan East
Okay, now I see what you are trying to do. Here's the docs for WM_NCACTIVATE:

WM_NCACTIVATE
The WM_NCACTIVATE message is sent to a window when its nonclient area needs to be changed to indicate an active or inactive state.

A window receives this message through its WindowProc function.

LRESULT CALLBACK WindowProc(
HWND hwnd, // handle to window
UINT uMsg, // WM_NCACTIVATE
WPARAM wParam, // new state (BOOL)
LPARAM lParam // not used
);
Parameters
wParam
Specifies when a title bar or icon needs to be changed to indicate an active or inactive state. If an active title bar or icon is to be drawn, the wParam parameter is TRUE. It is FALSE for an inactive title bar or icon.
lParam
This parameter is not used.
Return Values
When the wParam parameter is FALSE, an application should return TRUE to indicate that the system should proceed with the default processing, or it should return FALSE to prevent the title bar or icon from being deactivated. When wParam is TRUE, the return value is ignored.

Remarks
The DefWindowProc function draws the title bar or icon title in its active colors when the wParam parameter is TRUE and in its inactive colors when wParam is FALSE.


So, if you receive WM_NCACTIVATE with wParam==FALSE, then PostMessage a WM_CLOSE to your main hwnd.

Dan East

PostPosted: Feb 22, 2002 @ 6:54pm
by RICoder
Thank Dan...
WM_NCACTIVATE is undefined, so I have to use the hex, but other than that it is all cool.

PostPosted: Feb 22, 2002 @ 7:18pm
by RICoder

PostPosted: Feb 23, 2002 @ 7:55pm
by RICoder
Don't know if anyone is reading this thread besides me, but just in case...

I used the code above and it was a no-go.

Problem is, if you launch a dialog or anything, the message is recieved and expected bad stuff happens. I was gonna put in a flag to handle this, but I don't want to hack it like that.

I am going to investigat WM_CANCELMODE a bit further, but until then, this is where I am.