|
-
April 8th, 1999, 09:19 PM
#1
knowing when user select OK in modal dialog box
I created a menu item for a modal dialog box and eventually use the code:
void CMainFrame::OnDialogsModal()
{
CModal modalDlg;
modalDlg.DoModal();
}
Everything works great. Now I want to print to the SDI screen when the user selected the OK button or when the user selected the CANCEL button. Reading through books, I employ the following code in the view class;
void CTextEditView::OnDraw(CDC *pDC)
{
CModal modalDlg;
if (modalDlg.DoModal() == IDOK)
pDC->TextOut(1,1,"user pressed ok");
if (modalDlg.DoModal() == IDCANCEL)
pDC->TextOut(1,1,"user pressed cancel");
}
When I add the previous code, my dialog box appears when I execute the program rather than when I select the menu item! Furthermore, the dialog box will sometimes keep appearing even after I hit the OK button. How can I fix this so that the dialog appears only when I select that menu item and when I hit OK, it prints to the screen "user pressed ok" and then the modal dialog box goes away until I call it again?
Any response any one can give me will be greatly appreciated.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|