从cpp调用的对话框返回 [英] go back from a dialoguebox which called from a cpp

查看:111
本文介绍了从cpp调用的对话框返回的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我已经创建了一个MFC应用程序.它创建了test.cpp和testDlg.cpp

我从test.cpp中调用了如下对话:

    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;
}



默认情况下,对话框中会创建一个确定"和取消"按钮.
但是单击取消"不会返回DoModal下面的代码. DoModal之后的甚至断点也不起作用.

知道为什么会这样吗?

谢谢,
Skunkhead:)

解决方案

我正在给出一个正常的程序,在这种情况下我将按照此程序操作,可能此顺序可能会对您有所帮助.
1.检查两个按钮的ID(应为IDOK,IDCANCEL).
2.重新编译总解决方案(或项目)并检查(我想您可以尝试这样做)
3.如果不起作用,请将断点放在INT_PTR nRes = Logindlg.DoModal();
4.按F10键,您必须打开Logindlg对话框并关闭对话框(使用ok或cancel或X标记的任何方式)
5.现在检查IDE下一步执行什么.


Skunkhead尝试一下..

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
}



您不需要检查IDCANCEL的额外条件,正如您所说的那样,控制流在DoModal()之后停止,则资源文件或OnInitDialog()中可能存在问题,请将断点放入此函数中并进行检查.


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 :)

解决方案

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.


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.


这篇关于从cpp调用的对话框返回的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆