如何使用 Windows API 在菜单栏中包含 DropDownList?
假设使用 C++ 为 Win32 API 进行编程,我想知道是否可以在菜单栏中包含 DropDownList(具有 CBS_DROPDOWNLIST 样式的 COMBOBOX 窗口)。
任何有关此事的线索或从哪里开始学习该主题将不胜感激。
Assuming programming in C++ for the Win32 API, I would know if it is possible to include a DropDownList (COMBOBOX window with CBS_DROPDOWNLIST style) in a menu bar.
Any light in that matter or where start to learn on the topic would be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
所有者绘图是您自定义内置 API 菜单的唯一选择。这不仅是后背的巨大痛苦,而且仍然达不到你想要的效果。您必须手动绘制组合框并编写代码来响应所有鼠标事件,而不是仅仅放入标准组合框控件。
我的建议是使用工具栏或rebar控件 模拟菜单栏,而不是标准菜单栏。这就是 Windows(和 Internet)资源管理器绘制菜单栏的方法,它为您提供了更多的灵活性来包含哪些控件。
这里有关于如何使用工具栏执行此操作的完整说明:
创建 Internet Explorer 样式的菜单栏
您可以在此处找到钢筋的示例代码:使用 Rebar 控件
Owner drawing is your only option for customizing the built-in API menus. Not only is that a giant pain in the rear, it still won't produce the effect that you want. You'd have to draw the combo box by hand and write code to respond to all the mouse events, instead of just dropping in a standard combo box control.
My suggestion is to use either a toolbar or a rebar control that simulates a menu bar, rather than the standard menu bar. This is what Windows (and Internet) Explorer does to draw its menu bar, and it provides you with a lot more flexibility in what controls can be included.
There's a complete description of how you might do this using a toolbar available here:
Creating an Internet Explorer-style Menu Bar
And you can find sample code for the rebar here: Using Rebar Controls
如果您准备好处理所有绘制消息,您最终可以对应用程序的客户区执行任何操作。您准备投入多少工作和代码?
If you're prepared to handle all paint messages you can ultimately do anything to the client area of your application. How much work and code are you prepared to put in?