我可以使用MFC在窗口的任何矩形区域中绘制菜单(不是弹出菜单)吗?

时间:2022-01-22 00:20:49

I override OnNcPaint() method along with OnNcLButtonDown() and OnNcMouseMove() and OnNcHitTest() method. So the original menu of the window doesn't exist. I want to add a menu with the area of the caption bar. How can I do this?

我重写了OnNcPaint()方法以及OnNcLButtonDown()和OnNcMouseMove()以及OnNcHitTest()方法。因此窗口的原始菜单不存在。我想添加一个带有标题栏区域的菜单。我怎样才能做到这一点?

Thank you very much!

非常感谢你!

1 个解决方案

#1


The menu is painted as part of the non-client area. So if you are doing your own non-client painting, you'll also have to draw the window yourself. You may be able to hack something out with TrackPopupMenu to do the actual menu drawing, and you'll just have to handle the menu bar and top-level menu items yourself.

菜单被绘制为非客户区域的一部分。因此,如果您正在进行自己的非客户端绘画,您还必须自己绘制窗口。您可以使用TrackPopupMenu来修改实际的菜单绘图,您只需自己处理菜单栏和*菜单项。

Drawing the non-client area yourself is fraught with peril. Are you sure you don't just want to use an owner drawn menu?

自己绘制非客户区域充满了危险。您确定不只是想使用所有者绘制的菜单吗?

It can be tempting to tweak your UI dialogs to fit your exact needs, but also keep in mind that it is jarring to users who are accustomed to the look-and-feel of windows already.

调整UI对话框以满足您的确切需求可能很诱人,但请记住,对于已经习惯了Windows外观的用户来说,这是一种刺激。

#1


The menu is painted as part of the non-client area. So if you are doing your own non-client painting, you'll also have to draw the window yourself. You may be able to hack something out with TrackPopupMenu to do the actual menu drawing, and you'll just have to handle the menu bar and top-level menu items yourself.

菜单被绘制为非客户区域的一部分。因此,如果您正在进行自己的非客户端绘画,您还必须自己绘制窗口。您可以使用TrackPopupMenu来修改实际的菜单绘图,您只需自己处理菜单栏和*菜单项。

Drawing the non-client area yourself is fraught with peril. Are you sure you don't just want to use an owner drawn menu?

自己绘制非客户区域充满了危险。您确定不只是想使用所有者绘制的菜单吗?

It can be tempting to tweak your UI dialogs to fit your exact needs, but also keep in mind that it is jarring to users who are accustomed to the look-and-feel of windows already.

调整UI对话框以满足您的确切需求可能很诱人,但请记住,对于已经习惯了Windows外观的用户来说,这是一种刺激。