如何从模式对话框中访问cmainframe onupdate处理程序? [英] How to access cmainframe onupdate handlers from a modal dialog?

查看:165
本文介绍了如何从模式对话框中访问cmainframe onupdate处理程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

要在平板电脑触摸屏上使用我的程序,我为菜单创建了一个替代方案。在模态对话框中,我有一个CMenu成员,它从资源加载主菜单。

在对话框中,我可以使用CMenu类的成员用菜单项填充按钮。这有效但我喜欢访问CMainframe中的更新处理程序来设置CCmdUI中菜单项的状态,如下所示:



To use my program with a tablet touchscreen I created an alternative for the menu. In a modal dialog i have a CMenu member which load the main menu from resource.
In the dialog I can fill the buttons with menu items using the members of the CMenu class. This works but I like to access the Update handlers in CMainframe to set the status of the menu item from a CCmdUI like this:

void CMainFrame::OnUpdateViewInstant(CCmdUI* pCmdUI) 
{
	pCmdUI->Enable();
	pCmdUI->SetCheck(m_wndInstantBar.IsVisible());
}





我不想将它们复制为对话框的成员,以避免维护噩梦。



此路由可行吗?





我尝试过:



CCmdUI CmdUI;

...

CmdUI.DoUpdate(AfxGetMainWnd(),FALSE);



I don't want to copy them as members of the dialog to avoid a maintenance nightmare.

Is this routing possible?


What I have tried:

CCmdUI CmdUI;
...
CmdUI.DoUpdate(AfxGetMainWnd(), FALSE);

推荐答案

您可以使用PostThreadMessage API。您可以在此文章中找到一些解释。



在消息中你应该可以将所需的数据作为参数或者有一些共享数据(全局模型)来获得实际数据。



考虑使用无模式对话,如果它是适合您的解决方案。通常,对话框表示应用程序和用户的焦点位于对话框窗口中,并且所有外部都没有使用。
You can use the PostThreadMessage API. You find some explanation in this article.

In the message you should can the needed data as parameter or have some shared data (global model) to have actual data.

Consider using modeless dialog if it is the right solution for you. Normally a dialog means that the focus of the app and the user is in the dialog windows and all outside isnt used.


这篇关于如何从模式对话框中访问cmainframe onupdate处理程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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