afxMessageBox(_T(" hi"))oninitdialog()中的问题 [英] afxMessageBox(_T("hi")) Issue in oninitdialog()

查看:113
本文介绍了afxMessageBox(_T(" hi"))oninitdialog()中的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好



这个问题有点奇怪或可能是真的但我不知道解决方案。

我是使用MFC,我刚刚创建了一个示例项目,其中创建了三个对话框



1. DLG_MAIN

2. DLG_DADDY(包含/实现的类CDaddy )

3. DLG_SON(包含类/实现CSon)



在DLG_MAIN中添加了一个按钮,表示CALL_BTN_DADDY

在DLG_DADDY中添加一个按钮说CALL_BTN_SON



现在在代码和执行步骤中

注意:父类已相应地传递给了课程。

1.当用户点击CALL_BTN_DADDY按钮时,将弹出DLG_DADDY。

2.现在在DLG_DADDY中,如果用户单击CALL_BTN_SON,则会出现DLG_SON。

3.在CSon :: OnintDialog()中请写AfxMessageBox(_T(hi))



结果

注意:MessageBox工作正常,所以我的要求是只使用AfxmessageBox

1.消息将出现在对话框弹出窗口之前。嗯,这也是我的要求。

2.点击OK后,DLG_SON变为MODELLESS。我的意思是我可以关闭DLG_DADDY而不关闭DLG_SON。





我用Google搜索只能使用messagebox而不是afxmessagebox。 但这不是我的要求。



你有解决方案或建议吗?



提前感谢

Hi all

This problem is little bit weird or may be genuine but i don't know the solution.
I am using MFC and I just created a sample project in which three dialog created

1. DLG_MAIN
2. DLG_DADDY (class included/implemented CDaddy)
3. DLG_SON (class included/implemented CSon)

In DLG_MAIN one button added say CALL_BTN_DADDY
In DLG_DADDY one button added say CALL_BTN_SON

Now in Code and execution steps
Note: Parent has been Passed accordingly to class.
1. When user click on CALL_BTN_DADDY button DLG_DADDY will popup.
2. Now in DLG_DADDY if user click CALL_BTN_SON then DLG_SON will appear.
3. In CSon::OnintDialog() please write AfxMessageBox(_T("hi"))

Result
Note: MessageBox is working fine so my requirment is to use only AfxmessageBox
1. Message will appear before dialog popup. Well it is my requirement too.
2. After clicking OK the DLG_SON become MODELLESS. i mean i can close DLG_DADDY with out closing DLG_SON.


what i googled got only to use messagebox instead of afxmessagebox. But that is not my requrment.

Do you have the solution or suggestion.

thanks in advance

推荐答案

AfxMessageBox上贴一个断点调用并跟踪代码。在深入了解调用 MessageBox 的细节之前,你会看到它做了很多事情 - 包括设置 HWND 用于 MessageBox 调用当前窗口,以便在 AfxMessageBox 调用完成时重新启用该窗口。



因为你不想要这种行为你有很多选择:



- 重新实现那一点MFC。哎哟。

- maul MFC应用程序对象的状态,这样你可以调用 AfxMessageBox 而不会产生副作用,然后将所有内容重新放回原位。不是那么哎,但仍然很痛苦。

- 使用 MessageBox NULL HWND 并回避整个抱歉问题。
Stick a breakpoint on your AfxMessageBox call and trace the code through. You'll see it does loads of things before getting down to the nitty-gritty of calling MessageBox - including setting the HWND used in the MessageBox call to the current window so it can re-enable that window when the AfxMessageBox call finishes.

So as you don't want this behaviour you've got a bunch of choices:

- reimplement that bit of MFC. Ouch.
- maul the state of the MFC application object so you can call AfxMessageBox without the side effects then put everything back in place afterwards. Not so ouch but still painful.
- use MessageBox with NULL for HWND and sidestep the whole sorry issue.


您还可以发布 WM_USER 消息其子对话框在 OnInitDialog()

作为对该消息的反应将打开消息框:)
You could also post a WM_USER message for the son-dialog in its OnInitDialog(),
as its reaction for the message would open the message box :)


这篇关于afxMessageBox(_T(" hi"))oninitdialog()中的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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