2
votes

Is there something like a panel that I can use in a MFC application. This is to overlay the default window in MFC (a dialog application). 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 ?

2

2 Answers

4
votes

Sure. It's called a window! Create a class that derives from CWnd and overrides OnPaint().

In your dialog's OnInitInstance(), instantiate a CMyWnd object and call it's Create() member. Of course, make sure the lifetime of your CMyWnd object is the same as the dialog's object lifetime window. iow, make it a member of you CMyDialog class.

Not very complicated but obviously an area where MFC shows why it doesn't fall in the RAD tools category.

0
votes

Another solution would be to derive from 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.