Click here to Skip to main content
16,016,882 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionRe: DoModal() question? Pin
Maximilien23-Nov-07 3:11
Maximilien23-Nov-07 3:11 
AnswerRe: DoModal() question? Pin
Gofur Halmurat23-Nov-07 3:38
Gofur Halmurat23-Nov-07 3:38 
GeneralRe: DoModal() question? Pin
toxcct23-Nov-07 3:48
toxcct23-Nov-07 3:48 
GeneralRe: DoModal() question? Pin
Gofur Halmurat23-Nov-07 3:50
Gofur Halmurat23-Nov-07 3:50 
GeneralRe: DoModal() question? Pin
toxcct23-Nov-07 3:53
toxcct23-Nov-07 3:53 
GeneralRe: DoModal() question? Pin
Gofur Halmurat23-Nov-07 4:18
Gofur Halmurat23-Nov-07 4:18 
AnswerRe: DoModal() question? Pin
Mark Salsbery23-Nov-07 5:04
Mark Salsbery23-Nov-07 5:04 
AnswerRe: DoModal() question? Pin
Gary R. Wheeler24-Nov-07 2:41
Gary R. Wheeler24-Nov-07 2:41 
No. By calling the Create function for your alert dialog, you've made it a modeless dialog. Calling DoModal() in this case will not work correctly.

There are two solutions here. One, use the alert dialog modally:
CMyAlert *alert = new CMyAlert;
if (alert->DoModal() == IDOK) {
  message("IDOK is clicked");
}
delete alert;
The second is to use your alert dialog as a modeless dialog, and have it send a user-defined message to the parent when the OK button is clicked, which is more complicated:
#define WM_MyAlertMessage (WM_USER + 1)
void CMyAlert::OnOK()
{
  CWnd *parent = GetParent();
  if (parent != NULL) {
    parent->SendMessage(WM_MyAlertMessage,0,0);
  }
}
BEGIN_MESSAGE_MAP(CMyParentWindow,CDialog)
  ON_MESSAGE(WM_MyAlertMessage,OnMyAlertMessage)
END_MESSAGE_MAP()
LRESULT CMyParentWindow::OnMyAlertMessage(WPARAM /*wParam*/,LPARAM /*lParam*/)
{
  message("IDOK is clicked");
  return (LRESULT)0;
}



Software Zen: delete this;

QuestionSign ' is the same as \' ? Pin
George_George23-Nov-07 2:26
George_George23-Nov-07 2:26 
AnswerNOPE Pin
CPallini23-Nov-07 2:39
mveCPallini23-Nov-07 2:39 
GeneralRe: NOPE Pin
George_George23-Nov-07 3:08
George_George23-Nov-07 3:08 
GeneralRe: NOPE Pin
DoomedOne23-Nov-07 3:37
DoomedOne23-Nov-07 3:37 
GeneralRe: NOPE Pin
George_George23-Nov-07 5:13
George_George23-Nov-07 5:13 
GeneralRe: NOPE Pin
toxcct23-Nov-07 3:41
toxcct23-Nov-07 3:41 
GeneralRe: NOPE Pin
George_George23-Nov-07 5:15
George_George23-Nov-07 5:15 
QuestionWhere to put delete[] to prevent memory leaks? Pin
Priya_Sundar22-Nov-07 23:47
Priya_Sundar22-Nov-07 23:47 
AnswerRe: Where to put delete[] to prevent memory leaks? Pin
Nelek22-Nov-07 23:57
protectorNelek22-Nov-07 23:57 
GeneralRe: Where to put delete[] to prevent memory leaks? Pin
CPallini23-Nov-07 0:17
mveCPallini23-Nov-07 0:17 
GeneralRe: Where to put delete[] to prevent memory leaks? Pin
Priya_Sundar23-Nov-07 0:42
Priya_Sundar23-Nov-07 0:42 
GeneralRe: Where to put delete[] to prevent memory leaks? Pin
CPallini23-Nov-07 2:08
mveCPallini23-Nov-07 2:08 
GeneralRe: Where to put delete[] to prevent memory leaks? [modified] Pin
Nelek23-Nov-07 2:02
protectorNelek23-Nov-07 2:02 
GeneralRe: Where to put delete[] to prevent memory leaks? Pin
CPallini23-Nov-07 2:18
mveCPallini23-Nov-07 2:18 
GeneralRe: Where to put delete[] to prevent memory leaks? Pin
Nelek23-Nov-07 4:20
protectorNelek23-Nov-07 4:20 
GeneralRe: Where to put delete[] to prevent memory leaks? Pin
CPallini23-Nov-07 5:28
mveCPallini23-Nov-07 5:28 
GeneralRe: Where to put delete[] to prevent memory leaks? Pin
Nelek25-Nov-07 21:22
protectorNelek25-Nov-07 21:22 

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.