|
-
August 30th, 1999, 03:51 PM
#3
Re: SendMessage from Thread
Hi Dustin
This was discussed in Paul DiLascia's C++ Q&A column in Microsoft Systems Journel in July 1999.
"In the March 1999 issue, a reader asked about a mysterious bug he was experiencing in release builds only. The problem had to do with ON_MESSAGE which lets you handle an arbitrary message such as WM_MYMESSAGE.
const WM_FOO = WM_USER + 1;
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
ON_MESSAGE(WM_FOO, OnFoo)
END_MESSAGE_MAP
The handler function OnFoo must have the signature
LRESULT OnFoo(WPARAM, LPARAM)
That is, it should take a WPARAM and LPARAM, and return an LRESULT. If instead OnFoo has no arguments and returns void (an easy error if you don't use the arguments), your code will compile and even run - in debug builds. But because of the differences in stack checking and correction, it fails in release builds - in an especially gruesome and hard-to-understand way. (The stack becomes corrupt, the program goes on executing a while, then crashes somewhere else far removed from the real bug.)"
He then goes on to explain a method of protecting yourself from this.
Rail
------------
Recording Engineer/Software Developer
Rail Jon Rogut Software
http://home.earthlink.net/~railro/
[email protected]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|