Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. SendMessage crashes

SendMessage crashes

Scheduled Pinned Locked Moved C / C++ / MFC
announcementgraphicsdebuggingtutorialquestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    Wim Engberts
    wrote on last edited by
    #1

    Hi all, I have a program that does all kinds of graphical stuff. It calls classes from classes, etc. On the deepest level, something may change which requires the mainroutine to redraw the image. Currently, I pass all these classes a pointer to the parent class, and call "m_Parent->SendMessage (XL_REDRAW)". In the main class, I catch this message and perform the necessary drawing actions. However, this causes the program to crash in the release version. Everything goes well in the debug version however. Please note that the subclasses are no windows in their own right, but are basically just called from the parent class and may in turn again call sub classes themselves. Anyone any idea why this approach does not work? (and of course most of all: how to solve this) Thanks in advance William

    M J 2 Replies Last reply
    0
    • W Wim Engberts

      Hi all, I have a program that does all kinds of graphical stuff. It calls classes from classes, etc. On the deepest level, something may change which requires the mainroutine to redraw the image. Currently, I pass all these classes a pointer to the parent class, and call "m_Parent->SendMessage (XL_REDRAW)". In the main class, I catch this message and perform the necessary drawing actions. However, this causes the program to crash in the release version. Everything goes well in the debug version however. Please note that the subclasses are no windows in their own right, but are basically just called from the parent class and may in turn again call sub classes themselves. Anyone any idea why this approach does not work? (and of course most of all: how to solve this) Thanks in advance William

      M Offline
      M Offline
      Matthew Faithfull
      wrote on last edited by
      #2

      If multi threading is involved then remember that SendMessage halts the caller until the message is processed and it returns. In this scenario PostMessage is your friend. Either way you'd probably be better off doing an Invalidate or InvalidateRect when the message is sent rather than trying to draw directly. This will cause Windows to send you WM_PAINT messages at its convenience which generally works a lot better. If Debug builds work and Release builds don't then it's usually a timing or memory overrun problem. This one looks more like timing/synchronisation but I couldn't be sure wihtout the code :)

      Nothing is exactly what it seems but everything with seems can be unpicked.

      1 Reply Last reply
      0
      • W Wim Engberts

        Hi all, I have a program that does all kinds of graphical stuff. It calls classes from classes, etc. On the deepest level, something may change which requires the mainroutine to redraw the image. Currently, I pass all these classes a pointer to the parent class, and call "m_Parent->SendMessage (XL_REDRAW)". In the main class, I catch this message and perform the necessary drawing actions. However, this causes the program to crash in the release version. Everything goes well in the debug version however. Please note that the subclasses are no windows in their own right, but are basically just called from the parent class and may in turn again call sub classes themselves. Anyone any idea why this approach does not work? (and of course most of all: how to solve this) Thanks in advance William

        J Offline
        J Offline
        James R Twine
        wrote on last edited by
        #3

        If you are using VS6.0 with MFC, there may be a problem with how your message handlers are written.  The version of MFC that ships with 6.0 is very tolerant of mismatched signatures with the message handlers.    For example, when you create an ON_MESSAGE handler, the function used with it is supposed to have a signature of LRESULT func( WPARAM, LPARAM ), but if you created the function as void func( WPARAM, LPARAM ), it would/may still compile and run correctly in debug, but would crash quickly in release.    Peace!

        -=- James
        Please rate this message - let me know if I helped or not! * * * If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
        Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
        See DeleteFXPFiles

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups