Re: OnDestroy
From: Joseph M. Newcomer (newcomer_at_flounder.com)
Date: 02/20/05
- Next message: Miken: "draw multi-line text"
- Previous message: Joseph M. Newcomer: "Re: bug chat of OS"
- In reply to: Hanna-Barbera: "OnDestroy"
- Next in thread: Hanna-Barbera: "Re: OnDestroy"
- Reply: Hanna-Barbera: "Re: OnDestroy"
- Reply: Hanna-Barbera: "Re: OnDestroy"
- Messages sorted by: [ date ] [ thread ]
Date: Sat, 19 Feb 2005 23:49:07 -0500
No. There is no DC, so there is nothing to deselect from.
It is an excellent place to delete the objects, but only if you do not already have them
set up as objects in the window class.
For example, suppose I have a class
class CMyDialog : public CDialog {
protected:
CFont somefont;
CFont anotherfont;
CBrush RedBrush;
CBrush BlueBrush;
CPen DottedGreenPen;
... lots of other stuff
};
Then when the destructor for the class is called, the objects will be destroyed.
Why waste time with a GetDC()? It does nothing, other than generate a totally useless DC
that serves no useful purpose.
There is no need to call GetSafeHWnd() because you know that when you are in the OnDestroy
handler, you have a valid window handler.
The CWnd object is being destroyed. That implicitly removes it from the screen. The
Microsoft description is pretty vague.
But there is no reason to destroy the GDI objects at this point. They will be destroyed
with the CDialog object. So there's nothing for you to do.
joe
On Fri, 18 Feb 2005 20:35:26 -0500, "Hanna-Barbera" <NULL@excite.com> wrote:
>When we have some GDI object created when the programming was running, and
>the window is now beeing closed, is this function a good place to deselect
>from the DC and destroy them?
>
>Does the window still exist when this function is called?
>
>I called GetSafeHWnd() in a CDialog class and GetDC() before and after the
>call to
>CDialog::OnDestroy();
>
>and they always return valid handles.
>
>MSDN says
>
>"The framework calls this member function to inform the CWnd object that it
>is being destroyed. OnDestroy is called after the CWnd object is removed
>from the screen. "
>
>What do they mean by beeing removed from the screen?
>
>
>
>
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
- Next message: Miken: "draw multi-line text"
- Previous message: Joseph M. Newcomer: "Re: bug chat of OS"
- In reply to: Hanna-Barbera: "OnDestroy"
- Next in thread: Hanna-Barbera: "Re: OnDestroy"
- Reply: Hanna-Barbera: "Re: OnDestroy"
- Reply: Hanna-Barbera: "Re: OnDestroy"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|