从cpp调用的对话框返回

编程入门 行业动态 更新时间:2024-10-08 19:43:56
本文介绍了从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调用的对话框返回

本文发布于:2023-11-27 09:57:20,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1637597.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:对话框   cpp

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!