Click here to Skip to main content
15,887,485 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Exporting function objects from DLL Pin
napoleaninlondon17-Jul-06 5:04
napoleaninlondon17-Jul-06 5:04 
GeneralRe: Exporting function objects from DLL Pin
Cedric Moonen17-Jul-06 5:10
Cedric Moonen17-Jul-06 5:10 
GeneralRe: Exporting function objects from DLL Pin
napoleaninlondon17-Jul-06 5:18
napoleaninlondon17-Jul-06 5:18 
GeneralOT Pin
Eytukan17-Jul-06 6:25
Eytukan17-Jul-06 6:25 
GeneralRe: OT Pin
Cedric Moonen17-Jul-06 6:32
Cedric Moonen17-Jul-06 6:32 
GeneralRe: OT Pin
Eytukan17-Jul-06 7:11
Eytukan17-Jul-06 7:11 
GeneralHello Pin
Hamid_RT17-Jul-06 7:58
Hamid_RT17-Jul-06 7:58 
QuestionCrash after sending custom message (only in release mode) Pin
Matthijs Wessels17-Jul-06 4:47
Matthijs Wessels17-Jul-06 4:47 
I have created a class derived from an edit control. This class manages a double value as "the value" of that edit control. Whenever the value changes, I want to send a message to its parent, so that he can act upon it.
After the message has been sent, the application crashes and I get the send/dont send message from windows multiple times (depending on how many dialog controls there are on the dialog). This only happens in release mode.
The company where I work, had something to allow me to step through the code even though it was in release mode. This allowed me to see that the crash didn't happen in the function sending the message, but after the function was done or in functions in other threads. Still, the crash only happens after sending the message and when I quote the SendMessage function call out, no crash. Also, when I send another message instead of my own(e.g. WM_KEYDOWN), no crash.

The debugger always stops at this line of assembly code in !MFC42():
"mov esi,dword ptr [ecx+4]" with an acces violation. So I guess some memory gets corrupted while sending my message and the next thread that calls a standard MFC function crashes on it. How and Why, I have no clue.

I defined the message like this: "#define EN_APPLY (WM_APP + 1)" in the header file of the edit control.

Inside the message, I sent the dialog control id of the edit control as WPARAM, to allow the parent to distinguish between multiple edits.

In the parent header file I declare "afx_msg void OnApply(int iSenderCtrlId);"

In the parent cpp file I define "ON_MESSAGE(EN_APPLY, OnApply)" (with all the rest of those macros) and ofcourse, the implementation of the function (the content of which doesnt matter, because the error also appears when the function is empty)

I have this function to change the value of the edit and inform the parent:

void CEditWithScrollBar::SetWindowValue(double dValue, bool bNotifyParent)
{
if(m_dValue != dValue)
{
m_dValue = dValue;

if(bNotifyParent) (void)GetParent()->SendMessage(EN_APPLY, (WPARAM)GetDlgCtrlID()); // if I quote out this call, there is no crash.
}

CString sText;
CString sOldText;
sText.Format(m_sDisplayFormat, m_dValue);
GetWindowText(sOldText);
if(sText != sOldText)
{
SetWindowText(sText);
}
}

I found this link on errors happening in release and not in debug:
http://www.flounder.com/debug_release.htm
Maybe its of any use to anyone who wants to help out.

Thx in advance
QuestionRe: Crash after sending custom message (only in release mode) Pin
David Crow17-Jul-06 4:52
David Crow17-Jul-06 4:52 
AnswerRe: Crash after sending custom message (only in release mode) [modified] Pin
Matthijs Wessels17-Jul-06 5:01
Matthijs Wessels17-Jul-06 5:01 
GeneralRe: Crash after sending custom message (only in release mode) Pin
David Crow17-Jul-06 5:11
David Crow17-Jul-06 5:11 
GeneralRe: Crash after sending custom message (only in release mode) Pin
Matthijs Wessels17-Jul-06 5:13
Matthijs Wessels17-Jul-06 5:13 
GeneralRe: Crash after sending custom message (only in release mode) Pin
David Crow17-Jul-06 5:23
David Crow17-Jul-06 5:23 
GeneralRe: Crash after sending custom message (only in release mode) Pin
Matthijs Wessels17-Jul-06 7:18
Matthijs Wessels17-Jul-06 7:18 
GeneralRe: Crash after sending custom message (only in release mode) Pin
Matthijs Wessels17-Jul-06 5:22
Matthijs Wessels17-Jul-06 5:22 
AnswerRe: Crash after sending custom message (only in release mode) Pin
Steve S17-Jul-06 4:54
Steve S17-Jul-06 4:54 
GeneralRe: Crash after sending custom message (only in release mode) Pin
Matthijs Wessels17-Jul-06 5:02
Matthijs Wessels17-Jul-06 5:02 
GeneralRe: Crash after sending custom message (only in release mode) Pin
Matthijs Wessels17-Jul-06 5:21
Matthijs Wessels17-Jul-06 5:21 
AnswerRe: Crash after sending custom message (only in release mode) Pin
Steve S17-Jul-06 5:26
Steve S17-Jul-06 5:26 
GeneralRe: Crash after sending custom message (only in release mode) Pin
David Crow17-Jul-06 5:27
David Crow17-Jul-06 5:27 
QuestionDetect when LAN connection goes up/down, events? Pin
Moak17-Jul-06 4:27
Moak17-Jul-06 4:27 
QuestionRe: Detect when LAN connection goes up/down, events? Pin
David Crow17-Jul-06 4:33
David Crow17-Jul-06 4:33 
AnswerRe: Detect when LAN connection goes up/down, events? Pin
Moak17-Jul-06 5:44
Moak17-Jul-06 5:44 
QuestionRelease build runs slower than Debug build Pin
spiritofklanawa17-Jul-06 4:25
spiritofklanawa17-Jul-06 4:25 
AnswerRe: Release build runs slower than Debug build Pin
Kurt _B17-Jul-06 5:24
Kurt _B17-Jul-06 5:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.