CDialog class problem ( MFC ).
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...........
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.
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.
Problems can arise if you try to use GDI inside a standard control like CEdit since you interfere with its default painting.
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.......
And if I want to use GDI in other function that is not OnPaint or OnEraseBkGnd.
Can I do this????
Thanks.......
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).
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.
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/
http://www.codeproject.com/
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement