Custom messages cause failure in Release.

This is a discussion on Custom messages cause failure in Release. within the Windows Programming forums, part of the Platform Specific Boards category; I'm making a network chat program using MFC in VC++ 6. I derived a class from CAsyncSocket. At the top ...

  1. #1
    Progmammer
    Guest

    Custom messages cause failure in Release.

    I'm making a network chat program using MFC in VC++ 6. I derived a class from CAsyncSocket. At the top of this class's header file I added:

    #define DSOCK_RECEIVE WM_APP
    #define DSOCK_CONNECTED WM_APP+1

    It has a pointer (HWND* m_hWndParent) to the HWND of the dialog class it's a member of. In some of it's functions it calls this:

    SendMessage(*m_hWndParent, DSOCK_RECEIVE, 0, 0);

    In the dialogs message map it has:

    ON_MESSAGE(DSOCK_RECEIVE, OnDSockRecieve)

    At runtime in the Debug build of this application all goes smooth, at runtime in the Release build it says "Chat has caused an error in MFC42.DLL." I tried commenting out only the part where it sends the mesage and it ran fine. I cannot think of any other way to "get the message across" to my dialog. And I don't know why this fails. Any suggestions? ANSWERS?

    Thanks in advance.

  2. #2
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,856
    My bad.

    Wrong idea.

    I thought the SendMessage() may be having a problem with the size of the defined msg. But the msg param is a UINT not int (as WM_APP are not in the int msg range, WM_USER is).

    I use WM_USER+1001 and up and have no problems.
    Last edited by novacain; 04-02-2002 at 11:27 PM.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  3. #3
    Progmammer
    Guest

    Still doesn't work.

    I'm still have the same problem.

  4. #4
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,856
    If using MFC CWND try without the HWND.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  5. #5
    Progmammer
    Guest
    I've tried using a pointer to the dialog class (CDialog*) and calling it's SendMessage(DSOCK_RECEIVE), but that fails in Release and works in Debug as well.

    It seems like passing a message to another class should be relatively easy. I cannot however include my dialog classes header in my socket classes header and call the dialog class functions directly, because I'm trying to make my socket class easily reusable in other applications.

  6. #6
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,856
    Try one of the other msg posting macros. Could be it is because SendMessage() does not return until the msg is processsed.

    Try PostMessage() maybe?

    Could it have something to do with the socket receive handling?

    Make sure there is not a mem error prior to this that is causing this to crash).

    Are you using any DLL's as sometimes they mangle the function param list in release mode? (in debug there is enough room in the debug info to hold the params, need to create a DLL def file)
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. AddRef and Release
    By George2 in forum C++ Programming
    Replies: 20
    Last Post: 02-07-2008, 12:19 AM
  2. Spy++ view messages posted/sent to a control, or from it?
    By hanhao in forum Windows Programming
    Replies: 2
    Last Post: 06-24-2007, 11:07 PM
  3. Custom Windows Message.
    By Mastadex in forum Windows Programming
    Replies: 9
    Last Post: 05-10-2006, 01:43 PM
  4. Sending windows messages
    By Ideswa in forum Windows Programming
    Replies: 2
    Last Post: 03-02-2006, 12:27 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21