遇到CMFCToolBar类的LoadToolBarEx函数和COpenGLControl类的set ID [英] having trouble with LoadToolBarEx function of the CMFCToolBar class and set ID for the COpenGLControl class

查看:1037
本文介绍了遇到CMFCToolBar类的LoadToolBarEx函数和COpenGLControl类的set ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了一个新的空白对话框来测试代码



,我在本网站上阅读了许多问题,并且还研究了大量网页上的页面。最后我来到这里,使用 CMFCToolBar 类而不是 CToolbar 来支持工具栏的32位24x24图标,但没有这些页面真的有帮助,我还没有看到我的对话框顶部的工具栏。

请帮助我介绍一个链接,视频教程等,教你添加支持的工具栏Visual Studio 2010中的32bit图像的图标到基于对话框的mfc应用程序**

**我更喜欢一个从头开始的教程,对于MFC的初学者以及aguru



谢谢。我很高兴你的回答。



已编辑我的问题部分基于@Edward Clements有用的指导

这是我的项目的Resource.h文件

  // {{NO_DEPENDENCIES}} 
// Microsoft Visual C ++生成的include文件。
//由InitialJobProject2.rc使用
//
#define IDM_ABOUTBOX 0x0010
#define IDD_ABOUTBOX 100
#define IDS_ABOUTBOX 101
#define IDD_INITIALJOBPROJECT2_DIALOG 102
#define IDR_MAINFRAME 128
#define IDB_BITMAP1 130
#define IDR_TOOLBAR1 132
#define IDI_ICON1 135
#define IDC_NewBtnTbr 135
#define IDC_ZoomInBtnTbr 136
#define IDC_ZoomOutBtnTbr 137
#define IDI_ICON2 138
#define IDC_PanBtnTbr 138
#define IDC_TXTDataFile 1001
#define IDC_EDTDataPath 1002
#define IDC_BTNBrowse 1003
#定义IDC_RICHEDTHeader 1005
#define IDC_OPENGL 1009

//新对象的下一个默认值
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 139
#define _APS_NEXT_COMMAND_VALUE 32776
#define _APS_NEXT_CONTROL_VALUE 1010
#define _APS_NEXT_SYMED_VALUE 104
#endif
#endif

我不知道如何设置数字?并且如何计算分配给新ID的号码?

_APS_NEXT_RESOURCE_VALUE _APS_NEXT_COMMAND_VALUE _APS_NEXT_CONTROL_VALUE _APS_NEXT_SYMED_VALUE

,如果我将号码1010分配给新的ID,然后我应该在 _APS_NEXT_CONTROL_VALUE 前面写下什么?

和另外一个问题,这是一个:



我使用了 MFC / C ++ Helper类,用于从代码项目窗口调整大小,将对话框的控件放置到其中。此类使用控件的ID。我已经添加了一个 COpenGLControl从codeguru设置OpenGL在MFC控件,它不需要ID在其构造函数中,但由于它是从CWnd类派生的,它有一个函数 setHelpID 我可以这样添加一个 IDM,IDB,IDD,IDR,IDS,IDI或IDC (我不知道哪一个请帮我如何在他们之间选择,然后通过函数 setHelpID 将该ID分配给类的实例 COpenglControl ?然后使用此ID通过类 CWndResizer?将OpenGL窗口挂接到主窗口?



问题解决< br>
我建议为opengl窗口设置ID的方式工作,除了您应该使用SetDlgCtrlID成员函数而不是SetHelpID

解决方案

我不太熟悉将工具栏加载到对话框中,但是您需要使用ID创建工具栏资源(我不会使用 IDR_MAINFRAME 自己,因为它很混乱,您可能需要多个工具栏)和在 LoadToolBarEx 中使用此ID;工具栏将包含具有自己的图像和ID的按钮。您的邮件地图中将需要一个 ON_COMMAND ON_UPDATE_COMMAND_UI ,以启用/禁用按钮并响应按钮点击。



此MSDN论坛帖子提到您的对话框需要从 CDialogEx 而不是 CDialog



有关MFC Featurepack Controls(如CMFCToolbar)的文档很少, CodeProject文章可能有所帮助(即使它是关于移植旧版应用程序,它仍然有很多有用的做和不要)。



更多信息在这些 SO article ,这是关于创建工具栏动态(没有工具栏资源)。


I have created a new empty dialog to test the code Some notes on CMFCToolBar – Docking Large Buttons and use of the MDIClientArea but I see that this line produces false:

bool b = m_FirstToolbar.LoadToolBarEx(IDR_MAINFRAME, tbi, TRUE);  

and this is the resources of my project:

what's the problem and what should I add to the resources?
please help me. this is the third question that I ask today about toolbars on an MFC dialog based application.
My toolbar on a dialog based mfc application is not shown
after writing the code to add a toolbar to a dialog-based mfc the dialog doesn't run
and I have read many questions on this site and also studied lots of pages on the web. finally I came to the point to use CMFCToolBar class instead of CToolbar to support 32bit 24x24 icons for the toolbar but none of the pages helped really and I haven't still seen the toolbar at top of my dialog.
Could you please help me introduce a link,a video tutorial and etc which has taught adding toolbars that support icons of 32bit images in Visual studio 2010 to a dialog-based mfc application **
**I'd prefer a tutorial which has started from scratch and is good for a beginner of MFC as well a to aguru

thanks.I'd be glad to here your answers.

Edited section of my question based on @Edward Clements useful guidances
this is my project's Resource.h file

//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by InitialJobProject2.rc
//
#define IDM_ABOUTBOX                    0x0010
#define IDD_ABOUTBOX                    100
#define IDS_ABOUTBOX                    101
#define IDD_INITIALJOBPROJECT2_DIALOG   102
#define IDR_MAINFRAME                   128
#define IDB_BITMAP1                     130
#define IDR_TOOLBAR1                    132
#define IDI_ICON1                       135
#define IDC_NewBtnTbr                   135
#define IDC_ZoomInBtnTbr                136
#define IDC_ZoomOutBtnTbr               137
#define IDI_ICON2                       138
#define IDC_PanBtnTbr                   138
#define IDC_TXTDataFile                 1001
#define IDC_EDTDataPath                 1002
#define IDC_BTNBrowse                   1003
#define IDC_RICHEDTHeader               1005
#define IDC_OPENGL                      1009

// Next default values for new objects
// 
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE        139
#define _APS_NEXT_COMMAND_VALUE         32776
#define _APS_NEXT_CONTROL_VALUE         1010
#define _APS_NEXT_SYMED_VALUE           104
#endif
#endif  

I don't know how the numbers are set? and how should I compute the number to assign to the new ID?
what's the difference between _APS_NEXT_RESOURCE_VALUE,_APS_NEXT_COMMAND_VALUE,_APS_NEXT_CONTROL_VALUE and _APS_NEXT_SYMED_VALUE?
and if I assign the number 1010 to the new ID then what should I write in front of _APS_NEXT_CONTROL_VALUE?
and one more question that rose up is this one:

I have used the MFC/C++ Helper Class for Window Resizing from codeproject to anchor controls of dialog to it. This class uses ID of controls. and I have added a COpenGLControl from codeguru for Setting Up OpenGL in an MFC Control which does not need ID in its constructor but since it is derived from CWnd class,it has a function setHelpIDCould I add this way anIDM,IDB,IDD,IDR,IDS,IDI or IDC (I don't know which one please help me how to choose between themand then assign this ID through functionsetHelpIDto the instance of the classCOpenglControl? and then use this ID to hook the openGL window to the main window through classCWndResizer`?

Problem solved
the way that I suggested for setting ID for the opengl window does work except that you should use SetDlgCtrlID member function instead of SetHelpID

解决方案

I'm not familiar with loading toolbars into a dialog, but you need to create a Toolbar resource with an ID (I would not use IDR_MAINFRAME myself since it is confusing and you may need multiple toolbars) and use this ID in LoadToolBarEx; the toolbar would contain buttons with their own images and IDs. You will need a ON_COMMAND and ON_UPDATE_COMMAND_UI in your message map to enable/disable the buttons and to respond to the button clicks.

This MSDN forum post mentions that your dialog needs to be derived from CDialogEx instead of CDialog.

There's very little clear documentation on the MFC Featurepack Controls (like CMFCToolbar), this CodeProject article might help (even though it's about porting a legacy application, it still has quite a lot of useful do's and dont's).

Some more info in ths SO article, this is about creating toolbars dynamically (without having a toolbar resource).

这篇关于遇到CMFCToolBar类的LoadToolBarEx函数和COpenGLControl类的set ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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