Click here to Skip to main content
16,010,114 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
HI guys,

I have create a MFC Application. It creates test.cpp and testDlg.cpp

I called the dialogue from the test.cpp as below;

    CLoginUIDlg Logindlg;
INT_PTR nRes = Logindlg.DoModal();
if (nRes == IDOK)
{
    // TODO: Place code here to handle when the dialog is
    //  dismissed with OK
    //call the dll do the checking
}
else if (nRes == IDCANCEL)
{
    // TODO: Place code here to handle when the dialog is
    //  dismissed with Cancel
    return FALSE;
}


by default there were a OK and Cancel button created in the dialogue.
But clicking Cancel does not get back to the code here below the DoModal. Even breakpoints after the DoModal does not work.

Any ideas why this is?

Thanks,
Skunkhead :)
Posted

Hi I am giving a normal procedure which i will follow in these conditions, may this sequence may help you.
1. you check the Ids of two buttons(It should be IDOK, IDCANCEL).
2. Recompile total solutinon(or project) and check(I think you may tried this)
3. if not working put the break point at the INT_PTR nRes = Logindlg.DoModal();
4. Press F10, you have to get the Logindlg dialog and close the dialog(by any means using ok or cancel or X mark)
5.Now check the IDE what is the next execution step.
 
Share this answer
 
Hi Skunkhead try this..

CLoginUIDlg Logindlg;

if(Logindlg.DoModal() == IDOK)
{
  // When user will click on Ok button control will come here
}
else
{
  // When user will click on Cancel button control will come here
}


You dont need to check extra conditon for IDCANCEL, As you are saying that the control flow stop after DoModal() then there might be problem in resource file or in OnInitDialog(), put break point into this function and check same.
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900