×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

PostMessage crashes crash...

PostMessage crashes crash...

PostMessage crashes crash...

(OP)
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.
 

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close