MFC CToolBar 帮助/链接?

发布于 2024-09-24 13:20:04 字数 372 浏览 0 评论 0原文

我找不到一个简单的 CToolBar 示例。

我在资源编辑器中创建了一个工具栏,并在我的代码中加载了该工具栏,如下所示:

toolbar = new CToolBar;
toolbar->CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_ALIGN_TOP, CRect(0, 0, 0, 0), AFX_IDW_TOOLBAR);
toolbar->LoadToolBar(IDR_TOOLBAR);

我还在消息映射中处理了 WM_LBUTTONDOWN。

现在,所有按钮都变灰了..我是否错过了某个步骤?

感谢您的任何帮助/链接=)

I can't find a simple CToolBar example of all things..

I created a toolbar in the resource editor, and loaded the toolbar in my code like this:

toolbar = new CToolBar;
toolbar->CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_ALIGN_TOP, CRect(0, 0, 0, 0), AFX_IDW_TOOLBAR);
toolbar->LoadToolBar(IDR_TOOLBAR);

I have also handled WM_LBUTTONDOWN in the message map.

Now, all the buttons are grayed out.. am I missing a step somewhere?

Thanks for any help/links =)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

守不住的情 2024-10-01 13:20:04

默认情况下,MFC 中工具栏中的按钮是禁用的。对于应与命令 ID 关联的每个按钮,您需要有一个 ON_UPDATE_COMMAND_UI 宏。只要应用程序空闲,就会调用您在此宏中使用的处理函数。该函数可以调用CCmdUI<的成员函数/code>传递给函数的指针,例如 启用方法。

The buttons in a toolbar are disabled in MFC by default. For each button, which should be associated with a command ID, you need to have an ON_UPDATE_COMMAND_UI macro in your message map. The handler function you use in this macro will be called whenever the app is idle. This function can call the member functions of the CCmdUI pointer that is passed to the function, such as the Enable method.

枕头说它不想醒 2024-10-01 13:20:04

您是否在消息映射中提供了 ON_COMMAND 处理程序?应该看起来像
ON_COMMAND(SOME_BUTTON_ID, OnSomeButton) 其中 SOME_BUTTON_ID 对应于工具栏上的按钮之一。

Have you supplied an ON_COMMAND handler in the message map? Should look something like
ON_COMMAND(SOME_BUTTON_ID, OnSomeButton) where SOME_BUTTON_ID corresponds to one of the buttons on your toolbar.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文