visual studio如何将mfc对话框与对话资源相关联? [英] How does visual studio associate mfc dialog classes with dialog resources?

查看:298
本文介绍了visual studio如何将mfc对话框与对话资源相关联?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何使用相应的对话框资源将Visual Studio 关联到code> MFC CDialog 派生类。我对运行时的连接方式感兴趣(如这里),而是在设计时。

I was wondering how Visual Studio associates MFC CDialog derived classes with their corresponding dialog resources. I'm not interested in how the connection is made at run time (as asked here), but rather at design time.

当我将一个消息处理程序添加到对话框中时,它如何知道哪个类添加处理程序。
另外,是否可能有几个与同一个对话资源相关联的几个 CDialog 派生类,反之亦然?

When I add a message handler to a dialog, how does it know which class to add the handler to. Also, is it possible to have several CDialog derived classes associated with the same dialog resource and vice versa?

我在项目目录中搜索了 IDD_SOMEDIALOG 字符串,但只在 SomeDialog.h resource.h Project.rc 在预期的地方,所以我猜它以某种方式推断了这些文件的连接,最有可能在CSomeDialog类中中的枚举SomeDialog.h

I have searched the project directory for the IDD_SOMEDIALOG string but have only found it in SomeDialog.h, resource.h and Project.rc in the expected places so I guess it somehow deduces the connection from those files, most likely the enum in SomeDialog.h:

// in class CSomeDialog:
    enum { IDD = IDD_SOMEDIALOG };

我大部分都是出于好奇心问道。

I'm asking this mostly out of curiosity.

推荐答案

这取决于什么版本的开发工作室。

It depends on what version of dev studio.

在VS6中,它都保存在CLW文件)。

In VS6 it was all kept in the CLW (Class Wizard File).

在较新版本的开发工具室中,它不再使用CLW,我不知道如何知道,但我怀疑它的实时解析而不是使用一个缓存的CLW。

In newer versions of dev studio it doesn't use the CLW anymore and I don't know specifically how it knows, but i suspect its a live parsing instead of using a cached CLW.

对于使用相同资源的多个派生对话框,可以手动完成。您可以复制创建的类文件并重命名它们,并从头文件中删除枚举,并将源文件中的IDD枚举的使用编辑为实际的对话资源ID(IDD_SOMEDIALOG)。

As for having multiple derived dialogs using the same resource, it can be done manually. You can duplicate the created class files and rename them and remove the enum from header and edit the use of the IDD enum in the source file to be the actual dialog resource id (IDD_SOMEDIALOG).

AFAIK Dev Studio一次只能快乐地处理一个对话框。在我的经验中,尝试重新使用这样的对话资源只是结束了与MFC& Dev Studio,因为他们不打算这样做。

AFAIK Dev Studio will only 'happily' handle one class to a dialog at a time. In my experience trying to re-use a dialog resource like this just ends up in a bit of battle with MFC & Dev Studio since they were not intended to do this.

这篇关于visual studio如何将mfc对话框与对话资源相关联?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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