Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PostMessage crashes crash...

Status
Not open for further replies.

Demonpiggies

Programmer
Apr 9, 2007
42
US
I have created a new section of the already cramped status bar to display member information of a specific class. I am trying to do this be means of a PostMessage() but my application crashes when I run it in Release (but not in Debug).

Here are the custom messages (from defines.h):

#define WM_CUSTOMMESSAGE_FIELD_SELECTED WM_USER+12
#define WM_CUSTOMMESSAGE_FIELD_DESELECTED WM_USER+13

Here is me handling the messages (from MainFrm.cpp):

ON_MESSAGE(WM_CUSTOMMESSAGE_FIELD_SELECTED, OnUpdateFieldInformationSelectedStatus)

ON_MESSAGE(WM_CUSTOMMESSAGE_FIELD_DESELECTED, OnUpdateFieldInformationDeselectedStatus)

And here is the PostMessage (from CField.cpp):
BOOL CField::SelectField( CWnd* pWnd, CPoint* cptMouse )
{
.
.
.
if(pWnd)
{
pWnd->PostMessage(WM_CUSTOMMESSAGE_FIELD_SELECTED, NULL, NULL);
}

return TRUE;
}

When the user selects a field a message is posted and the status bar is updated. But this does not happen correctly. As stated before, the application crashes. I have read MANY articles on this and have failed to come up with anything useful. To clarify the application crashes AFTER the status bar has been updated and I do not know why. The crash happens right after the message is picked up and OnUpdateFieldInformationSelectedStatus is finished. If I take out the PostMessage the application is fine. I have tried SendMessage() but this crashes the application sooner than PostMessage(). If I can the method directly I get initialized information (meaning everything I pull from the CField object is initialized to 0) yet if I use PostMessage I get the correct data. I am not looking to rewrite the CField of the application but if someone could help me fix this PostMessage issue I would be grateful.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top