Jump to content
  • Advertisement
Sign in to follow this  

CDialog class problem ( MFC ).

This topic is 4328 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Is CDialog class can use with GDI? If I want to display graphics that use GDI in the "dialog window" that derived from class CDialog ,Can I do this ??? If I can use CDialog with GDI ,how can I do? Thank you very much...........

Share this post


Link to post
Share on other sites
Advertisement
last i recall you can use WM_PAINT and WM_ERASEBKGND to draw stuff with GDI in a dialog, however, i'm not sure if BitBlt's will work or not. I don't know if this has changed over the years (in the old days you couldn't, but try it and find out), as I haven't messed with GDI drawing in dialogs for quite some time now and I have the tendencies to still do things "the old way," but an old hack (i.e. for splash dialogs that need to draw bitmaps) is to draw or place the bitmap in a child window, such as a static control or another window. so just override your OnPaint or OnEraseBkgnd and give some GDI drawing a go... it should work.

Share this post


Link to post
Share on other sites
You can use GDI in every HWND (or CWnd derived), so it works without any problems in CDialog as well. Depending on your design you can do the drawing in OnPaint or OnEraseBkGnd. Simply override one of these two and use the CPaintDC (or CDC) you get passed.

Problems can arise if you try to use GDI inside a standard control like CEdit since you interfere with its default painting.

Share this post


Link to post
Share on other sites
Thank you very much.
And if I want to use GDI in other function that is not OnPaint or OnEraseBkGnd.
Can I do this????

Thanks.......

Share this post


Link to post
Share on other sites
You can (in general) use the GDI in any place where you have access to the appropriate handles - namely, the window handle (HWND) and device context (HDC).

Share this post


Link to post
Share on other sites
Quote:
Original post by _mito_
Thank you very much.
And if I want to use GDI in other function that is not OnPaint or OnEraseBkGnd.
Can I do this????

Thanks.......


Yes, you can use it whereever you want. As ApochPiQ said, all you need to access it is the HWND. From there you can get access to the HDC.

The default place is WM_PAINT/WM_ERASEBKGND though, so be aware, that things may not work that smoothly if you do painter from other places.

Share this post


Link to post
Share on other sites
I have been using owner draw buttons for things like display a COLORREF. You can do a LOT with owner drawn controls. There are a lot of cool tutorials and samples at:

http://www.codeproject.com/

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!