Click here to Skip to main content
15,900,461 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Problem with EndDialog Pin
Fernando A. Gomez F.4-Jan-07 8:07
Fernando A. Gomez F.4-Jan-07 8:07 
AnswerRe: Problem with EndDialog Pin
Michael Dunn3-Jan-07 14:24
sitebuilderMichael Dunn3-Jan-07 14:24 
GeneralRe: Problem with EndDialog Pin
Fernando A. Gomez F.3-Jan-07 14:27
Fernando A. Gomez F.3-Jan-07 14:27 
GeneralRe: Problem with EndDialog Pin
Fernando A. Gomez F.4-Jan-07 8:08
Fernando A. Gomez F.4-Jan-07 8:08 
AnswerRe: Problem with EndDialog Pin
Rajesh R Subramanian3-Jan-07 19:58
professionalRajesh R Subramanian3-Jan-07 19:58 
QuestionRe: Problem with EndDialog Pin
prasad_som3-Jan-07 19:11
prasad_som3-Jan-07 19:11 
AnswerRe: Problem with EndDialog Pin
Fernando A. Gomez F.4-Jan-07 8:08
Fernando A. Gomez F.4-Jan-07 8:08 
AnswerRe: Problem with EndDialog Pin
Fernando A. Gomez F.4-Jan-07 8:06
Fernando A. Gomez F.4-Jan-07 8:06 
Hello. First of all, I'd like to thank you all for the help provided. Indeed, I am so happy now, and after your help and like 50 cigarrettes, I was able to find the bug. Here's the issue.

It was happening something like Mark and Michael told me, about not running a single line of code after the EndDialog. That is, the code must have a return after the EndDialog call. However, in my code there was an EndDialog and a return. Yet in other part of the code, this dialog created another dialog and this new child window, when it ends the dialog, does not have a return and indeed there was more code executing after the call of EndDialog. So a simple return there ended the problem. Something like the following:

<br />
<br />
void CAnotherDialog::EndDialog()<br />
{<br />
  DoSomething();<br />
  if (m_bSomething)<br />
    EndDialog(IDCANCEL);<br />
<br />
  DoMoreStuff();<br />
}<br />
<br />
void CMyDialog::DoSomething()<br />
{<br />
  CAnotherDialog dlg;<br />
  dlg.DoModal();<br />
<br />
  if (bSomeFlag)<br />
  {<br />
    EndDialog(IDCANCEL)<br />
    return;<br />
  }<br />
<br />
  DoMoreStuff();<br />
}<br />


So I just changed it into:

<br />
<br />
void CAnotherDialog::EndDialog()<br />
{<br />
  DoSomething();<br />
  if (m_bSomething)<br />
  {<br />
    EndDialog(IDCANCEL);<br />
    return;<br />
  }<br />
<br />
  DoMoreStuff();<br />
}<br />
<br />
void CMyDialog::DoSomething()<br />
{<br />
  CAnotherDialog dlg;<br />
  dlg.DoModal();<br />
<br />
  if (bSomeFlag)<br />
  {<br />
    EndDialog(IDCANCEL)<br />
    return;<br />
  }<br />
<br />
  DoMoreStuff();<br />
}<br />


Thank you guys, you really saved my nervous system. Big Grin | :-D

One last thing: should I post this issue in the subtle bugs section, or it was only pure lack of knowledge (stupidity, that is) from my part?

Thanks again.

Regards,
Fernando.

A polar bear is a bear whose coordinates has been changed in terms of sine and cosine.
Personal Site

QuestionAn IM that Scales Well Pin
Waleed Eissa3-Jan-07 11:12
Waleed Eissa3-Jan-07 11:12 
AnswerRe: An IM that Scales Well Pin
Ray Kinsella3-Jan-07 11:22
Ray Kinsella3-Jan-07 11:22 
GeneralRe: An IM that Scales Well Pin
Waleed Eissa3-Jan-07 11:36
Waleed Eissa3-Jan-07 11:36 
Questioninsert binary file in image column in MS-SQL database Pin
neilsolent3-Jan-07 9:48
neilsolent3-Jan-07 9:48 
AnswerRe: insert binary file in image column in MS-SQL database Pin
David Crow3-Jan-07 9:52
David Crow3-Jan-07 9:52 
AnswerRe: insert binary file in image column in MS-SQL database Pin
Cristian Amarie3-Jan-07 9:55
Cristian Amarie3-Jan-07 9:55 
GeneralRe: insert binary file in image column in MS-SQL database Pin
neilsolent3-Jan-07 10:04
neilsolent3-Jan-07 10:04 
Questiondefault oem codepage Pin
Peter Weyzen3-Jan-07 9:13
Peter Weyzen3-Jan-07 9:13 
AnswerRe: default oem codepage Pin
Cristian Amarie3-Jan-07 9:16
Cristian Amarie3-Jan-07 9:16 
GeneralRe: default oem codepage Pin
Peter Weyzen3-Jan-07 9:42
Peter Weyzen3-Jan-07 9:42 
Questiondiff between stricmp and _stricmp? Pin
Like2Byte3-Jan-07 9:02
Like2Byte3-Jan-07 9:02 
AnswerRe: diff between stricmp and _stricmp? Pin
Cristian Amarie3-Jan-07 9:13
Cristian Amarie3-Jan-07 9:13 
GeneralRe: diff between stricmp and _stricmp? Pin
Like2Byte3-Jan-07 9:37
Like2Byte3-Jan-07 9:37 
AnswerRe: diff between stricmp and _stricmp? Pin
David Crow3-Jan-07 9:23
David Crow3-Jan-07 9:23 
GeneralRe: diff between stricmp and _stricmp? Pin
Like2Byte3-Jan-07 9:40
Like2Byte3-Jan-07 9:40 
QuestionGetting Error code as 1407 "Cannot find window class." Pin
Pradeep.Reddy3-Jan-07 7:22
Pradeep.Reddy3-Jan-07 7:22 
AnswerRe: Getting Error code as 1407 "Cannot find window class." Pin
Mark Salsbery3-Jan-07 7:52
Mark Salsbery3-Jan-07 7:52 

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.