简体   繁体   English

MFC面板和窗口手柄

[英]MFC Panel and window handle

Is there something like a panel that I can use in a MFC application. 是否有可以在MFC应用程序中使用的面板之类的东西。 This is to overlay the default window in MFC (a dialog application). 这是为了覆盖MFC(对话框应用程序)中的默认窗口。 Then to paint the panel black and paint some random stuff on top of it. 然后将面板涂成黑色,并在面板上涂一些随意的东西。 Something like a view port. 像视口一样的东西。

is there a better option than this to achieve the same effect ? 有没有比这更好的选择来达到相同的效果?

Sure. 当然。 It's called a window! 叫做窗户! Create a class that derives from CWnd and overrides OnPaint(). 创建一个从CWnd派生并重写OnPaint()的类。

In your dialog's OnInitInstance(), instantiate a CMyWnd object and call it's Create() member. 在对话框的OnInitInstance()中,实例化一个CMyWnd对象,并将其称为Create()成员。 Of course, make sure the lifetime of your CMyWnd object is the same as the dialog's object lifetime window. 当然,请确保CMyWnd对象的生存期与对话框的对象生存期窗口相同。 iow, make it a member of you CMyDialog class. 现在,使其成为您的CMyDialog类的成员。

Not very complicated but obviously an area where MFC shows why it doesn't fall in the RAD tools category. 不是很复杂,但是很显然MFC可以在其中展示为什么它不属于RAD工具类别。

Another solution would be to derive from CDialog . 另一个解决方案是从CDialog This way you can use the resource editor to edit the panel visually and you don't need to paint anything yourselve. 这样,您可以使用资源编辑器直观地编辑面板,而无需自己绘制任何内容。 Also the Panel class is rather thin and just needs to propagate the Create() and Show() calls to support subpanels and multiple panels within a single form. 另外,Panel类非常薄,只需要传播Create()Show()调用即可在一个表单中支持子面板和多个面板。

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

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