SendMessage crashes
-
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
-
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
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.
-
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
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 ofLRESULT func( WPARAM, LPARAM )
, but if you created the function asvoid 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