简体   繁体   English

Windows MFC宏

[英]Windows MFC macros

I'm trying to learn the MFC to code for Windows and I've come across things like the ID_FILE_EDIT macros that are defined as being unicode values I think. 我正在尝试学习MFC为Windows编码,并且遇到了ID_FILE_EDIT宏之类的东西,这些宏被定义为我认为的unicode值。 I understand, I think, that the macros specify the item in the menu pulldowns. 我认为宏可以在菜单下拉菜单中指定项目。 Question is, how do I define my own and where do I put them. 问题是,我该如何定义自己的东西以及将它们放在哪里。 I'm trying to get custom menus and custom menu buttons to stem from the MFC. 我试图从MFC获得自定义菜单和自定义菜单按钮。 Like I want under file 'new, open existing doc and stuff like that'. 就像我想在文件“新建,打开现有文档之类的东西”下一样。 I've got VS2013 pro and all the headers I could ever want. 我有VS2013 pro和我可能想要的所有标头。 Second question is where do I start with the MFC. 第二个问题是我从MFC开始的地方。 Should I start by practicing making windows then pulldowns and then... something else? 我应该首先练习制作窗户,然后下拉菜单,然后...其他东西吗? I know where the documentation is at and I understand where the class references are. 我知道文档在哪里,我知道类引用在哪里。 Really just confused on using it to make my own stuff. 真的只是对使用它制作自己的东西感到困惑。

ID_FILE_EDIT (and other defines, like ID_FILE_NEW , ID_FILE_OPEN , etc.) are macros to specify a name for an unique resource identifier that is used to identify a menu command and/or toolbar item. ID_FILE_EDIT (以及其他定义,例如ID_FILE_NEWID_FILE_OPEN等)是用于为唯一资源标识符指定名称的宏,该标识符用于标识菜单命令和/或工具栏项。 They are typically defined in a header file named resource.h . 它们通常在名为resource.h的头文件中定义。

Microsoft has released a numbering and naming convention as a Technical Note (TN), because the names and values ​​represented by these macros must follow a certain pattern: http://msdn.microsoft.com/en-us/library/t2zechd4.aspx Microsoft已发布了编号和命名约定作为技术说明(TN),因为这些宏代表的名称和值必须遵循某种模式: http : //msdn.microsoft.com/zh-cn/library/t2zechd4的.aspx

Under normal circumstances you can use Visual-Studio's built-in resource editor to create dialogues, menus, buttons, and all the other UI stuff. 在正常情况下,您可以使用Visual Studio的内置资源编辑器来创建对话框,菜单,按钮和所有其他UI内容。 These editors also assign automatically unique ID's for any resource and generate the macros. 这些编辑器还会为任何资源自动分配唯一的ID,并生成宏。

Your second question can not be answered easily. 您的第二个问题很难回答。 MFC applications are a wide field, ranging from simple, dialogue-based programs to sophisticated Model-View-Controller-based applications. MFC应用程序领域广泛,从简单的基于对话的程序到复杂的基于模型-视图-控制器的应用程序。 If you just want to play around with MFC to familiarize yourself with the basic concepts of this framework, I recommend to start with a dialogue-based app. 如果您只是想使用MFC来熟悉该框架的基本概念,建议您从基于对话框的应用程序开始。

Regards, Stephan 问候,斯蒂芬

In VC++ 6.0, Insert menu - Resource - Menu. 在VC ++ 6.0中,插入菜单-资源-菜单。 Is how you add/edit a menu. 是您添加/编辑菜单的方式。

Where is the formatting bar gone on answers. 格式栏在哪里回答。

To learn MFC basics, manually build up the Scribble example application ( http://msdn.microsoft.com/en-us/library/92y4h944%28v=vs.90%29.aspx ) with which whole generations of MFC programmers made their first contacts with MFC. 要学习MFC的基础知识,请手动构建Scribble示例应用程序( http://msdn.microsoft.com/en-us/library/92y4h944%28v=vs.90%29.aspx ),整代MFC程序员都可以使用该示例应用程序第一次与MFC联系。 Don't just read it, start with an empty application and gradually add the stuff as in the tutorials. 不要只是阅读它,而是从一个空的应用程序开始,然后按照教程中的说明逐步添加内容。 It'll show you a lot. 它会告诉你很多。 If you don't know the win32 api yet though, you may want to start with reading the Petzold from front to back. 如果您还不知道win32 api,则可能要从头到尾阅读Petzold。 Good luck, remember that these are libaries and API's from a time when it wasn't considered unreasonable to spend 3 months full time to learn something. 祝您好运,请记住,这些都是从图书馆和API时代开始的,因为人们不认为花3个月的时间来学习某些东西是不合理的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM