Re: DispatchMessage: What is message # 0xC0FE ?
- From: Joseph M. Newcomer <newcomer@xxxxxxxxxxxx>
- Date: Sun, 24 Dec 2006 22:21:57 -0500
Of course, one of the fundamental questions is "why?". Using PeekMessage is usually an
indication of some serious design issues, such as trying to do long computations in the
main GUI thread instead of using a secondary thread. It has a tendency to impose
significant overhead and/or significant GUI delays, and should be reserved for very weird
situations.
Why are you defining your own structure? windows.h defines the MSG structure which is what
should be used here. The use of the #define _TPoint is also highly questionable, since it
doesn't define a struct, just two integers.
Here's the structure you should be using:
typedef struct {
HWND hwnd;
UINT message;
WPARAM wParam;
LPARAM lParam;
DWORD time;
POINT pt;
} MSG, *PMSG;
and this is defined by including windows.h, and it is the correct structure to use. Any
belief you have that a WPARAM or an LPARAM can be represented by an int is erroneous.
NEVER substitute your own idea of what WPARAM and LPARAM are defined as with any type
OTHER that WPARAM or LPARAM. The message is a UINT, not an int, the time is a DWORD, not
an int, and the position is a POINT structure, not two fields defined by a macro.
For example, WPARAM and LPARAM are 64-bit values on Win64.
Doing things like this is, frankly, abysmally poor style and must be avoided. I'm not
sure why you are trying to define your own structures, or why you have chosen to invent
your own ideas about what they look like, but you should stop doing this. It also looks
like you are inventing your own names for constants, such as PM_REMOVE being represented
by some constant called pm_Remove, so stop doing this also. There is a reason that there
is a standard windows.h file. Code like this is going to lead you to make serious errors,
including code that is nonportable across platforms.
On what do you base the notion that it takes 2 seconds to dispatch the message? Can you
show the exact code you are using to measure this? Note that since it is a registered
window message you probably have no idea what it is doing, so how do you know it is not
*supposed* to take 2 seconds? Or you are using something like GetTickCount, which doesn't
measure the time taken to execute the dispatch. And isn't very reliable for other than
approximate-clock-time, if you don't mind the fact that every few days it tells you it
took a couple days because of 32-bit rollover.
joe
On Sun, 24 Dec 2006 14:07:46 -0800, Susan Rice <srice1@xxxxxxx> wrote:
I have some code which basically looks like this:Joseph M. Newcomer [MVP]
#define _TPoint int X; int Y
structure TMsg {
HWnd hWnd;
int Message;
int WParam;
int LParam;
int Time;
_TPoint;
}
...
struct TMsg Msg;
...
if ( PeekMessage( &Msg, 0, 0, 0, pm_Remove ) ) {
TranslateMessage( &Msg );
DispatchMessage( &Msg );
And at one point structure Msg has:
Msg.hWnd=B805F2 (Handle to window)
Msg.Message=C0FE (hex. What is this message?)
Msg.WParam=0
Msg.LParam=0
Msg.Time=1189614437 (decimal)
And my question is, what message is C0FE (hex) ?
Dispatching this message takes 2 seconds, so I want to know what
the delay is all about, can I avoid it?
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.
- Follow-Ups:
- Re: DispatchMessage: What is message # 0xC0FE ?
- From: Alexander Grigoriev
- Re: DispatchMessage: What is message # 0xC0FE ?
- References:
- DispatchMessage: What is message # 0xC0FE ?
- From: Susan Rice
- DispatchMessage: What is message # 0xC0FE ?
- Prev by Date: Re: Using QueryPerformanceCounter for precision timing delay
- Next by Date: Re: Slightly OT: Keyboard utility needed
- Previous by thread: Re: DispatchMessage: What is message # 0xC0FE ?
- Next by thread: Re: DispatchMessage: What is message # 0xC0FE ?
- Index(es):
Relevant Pages
|