Re: Distorted dialog title bar after SetWindowPos in OnInitDialog
- From: Joseph M. Newcomer <newcomer@xxxxxxxxxxxx>
- Date: Tue, 05 Dec 2006 14:24:08 -0500
That ;is exactly one of the problems I've seen; and Default() really does pass the
WM_SETTEXT to the base class, which gets the drawing wrong. It also can produce annoying
flicker as the wrong text is displayed, the area is invalidated, and the right text is
displayed.
There's a cheat I do, when I'm feeling lazy. I place a CStatic down and use it as a
frame. Then I
c_Frame.GetWindowRect(&r);
ScreenToClient(&r);
c_MyControl.Create(...., r, c_Frame.GetDlgCtrlID(), this);
c_Frame.DestroyWindow();
it adds just a few lines to the OnInitDialog, lets me place the control easily, and just
replaces it at runtime by a control of the same size and ID, but derived from my desired
class. Much easier than having to define new window classes so I can name them and then
figure out the hex values for the style bits.
joe
On Mon, 4 Dec 2006 17:17:00 -0800, "David Ching" <dc@xxxxxxxxxxxxxxxxxxxxxx> wrote:
"Joseph M. Newcomer" <newcomer@xxxxxxxxxxxx> wrote in messageJoseph M. Newcomer [MVP]
news:crf9n21oh9a8elitp9n8ivkhcr1ql5ek1h@xxxxxxxxxx
I've seen this bug appear in a number of situations when CStatic was
chosen. I have
typically fixed it by changing it from a CStatic to a CWnd derivation. I
only see the
problem when SetWindowText is involved. It has been a couple years since
I last saw it,
but I have a vague memory that WM_SETTEXT was actually being handled and
it still came out
wrong, but I've forgotten the details.
I've not hit it myself because I tend to derive from CStatic only for
non-text displays.
Actually, my OnSetText() calls Default(), then InvalidateWindow() so maybe
the Default() causes the original STATIC wndproc to do GetDC() and draw on
it rather than invalidating the window still. But then I follow that up
with a call to InvalidateWindow() so the control should be painted for good.
I like to derive from CStatic because it makes it easy for my control to be
used in a dialog. Just drag a static control from the Toolbox into the
dialog, and use the Add Class wizard to set it to my CStatic-derived class.
This isn't possible with a CWnd derived class. I don't think it's even
possible to add a control of your class using the dialog editor.
-- David
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.
- Follow-Ups:
- Re: Distorted dialog title bar after SetWindowPos in OnInitDialog
- From: Alexander Grigoriev
- Re: Distorted dialog title bar after SetWindowPos in OnInitDialog
- References:
- Distorted dialog title bar after SetWindowPos in OnInitDialog
- From: Wolfram Roesler
- Re: Distorted dialog title bar after SetWindowPos in OnInitDialog
- From: Joseph M . Newcomer
- Re: Distorted dialog title bar after SetWindowPos in OnInitDialog
- From: Wolfram Roesler
- Re: Distorted dialog title bar after SetWindowPos in OnInitDialog
- From: Joseph M . Newcomer
- Re: Distorted dialog title bar after SetWindowPos in OnInitDialog
- From: David Ching
- Re: Distorted dialog title bar after SetWindowPos in OnInitDialog
- From: Joseph M . Newcomer
- Re: Distorted dialog title bar after SetWindowPos in OnInitDialog
- From: David Ching
- Distorted dialog title bar after SetWindowPos in OnInitDialog
- Prev by Date: Re: Zoom in/ Zoom out images
- Next by Date: Re: how to limit the plot in Client area while handling WM_PAINT?
- Previous by thread: Re: Distorted dialog title bar after SetWindowPos in OnInitDialog
- Next by thread: Re: Distorted dialog title bar after SetWindowPos in OnInitDialog
- Index(es):
Relevant Pages
|