将焦点放在MFC视图中托管的无模式对话框上 [英] Set focus on a modeless dialogs hosted in an MFC view

查看:100
本文介绍了将焦点放在MFC视图中托管的无模式对话框上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我有一个MFC视图,还有另一个实现和MFC对话框的项目.
我想在我的视图中托管对话框.
我的观点是CFormView类.

我是这样在我的视图代码中完成的:

Hello,

I have an MFC view, and I have another project which implements and MFC dialog.
I want to host the dialog in my view.
My view is of class CFormView.

I did it that way in my view code:

m_myDialog->Create(myDialog::IDD, this);



现在,我看到了对话框,但是无法将其设置为焦点且无法使用它.

为了在视图中托管对话框,并能够使用对话框并将焦点设置为视图的一部分,我必须进行哪些更改?

谢谢



Now, I see my dialog, but I can''t set focus on it and can''t use it.

What do I have to change in order to host my dialog in my view, and be able to use it and set focus to it, just as part of the view?

Thanks

推荐答案

要将控件嵌入到对话框模板定义的视图中,可以使用CDialogBar对象.然后,来自控件的所有通知都将发送到视图,并可以在那里进行处理.

要在您的项目中执行此操作,请将m_myDialog对象的类型更改为CDialogBar *,然后将所有控制处理程序从CDialog派生类移至视图类.
To embed controls into a view defined by a dialog template you can use a CDialogBar object. Then all notifications from the controls are send to the view and can be handled there.

To do this with your project, change the type of your m_myDialog object to CDialogBar * and move all control handlers from your CDialog derived class to your view class.


请确保您已将Style属性设置为Child.
Make sure you''ve set the Style property to Child.


这篇关于将焦点放在MFC视图中托管的无模式对话框上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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