i'm thinking on something like overriding the device contect with a
memoryDC which would be used by all controls and then at the end be
blitted to the original DC. i've not seen any examples on that specific
topic so far. is this possible at all?
regards
Peter
Tom
"Peter Melchart" <do...@spam.com> wrote in message
news:IFJXd.112336$2e4....@news.chello.at...
Joseph M. Newcomer [MVP]
email: newc...@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
Not knowing the real problem, nevertheless one way to speed up dialog
redraws when moving and hiding/showing lots of them is using
BeginDeferWindowPos/DeferWindowPos/EndBeginDeferWindowPos.
Johan Rosengren
Abstrakt Mekanik AB
"Peter Melchart" <do...@spam.com> a écrit dans le message de
news:IFJXd.112336$2e4....@news.chello.at...
i don't want to draw directly on the dialog, i want to have control over
all the standard controls in the window ( buttons, rich edit controls,
... ). so when the window is updated i don't want each control to draw
itselt directly on the window dc but on a memdc and when all controls
are finished i want copy that memdc to the dialog dc. actually... that
would be direct drawing to the dialog.
but would it be possible to create a static control of any kind, and at
some point let all other controls of the dialog becom child windows of
the static control. that way i could handle the onDraw event of the
static control and draw all controls in a memdc and then copy the memdc
to the frontdc. would that work ?
regards
Peter
Why do you think a complicated non-solution to a trivial problem is going to buy anything?
joe
Joseph M. Newcomer [MVP]
LockWindowUpdate() / UnlockWindowUpdate(), as a possible alternative to the
already suggested SetRedraw().
-- David
http://www.dcsoft.com
> Why do you think a complicated non-solution to a trivial problem is going
> to buy anything?
Avoiding flicker and optimizing display performance (with double buffering
or some other technique) is not a trivial problem.
-- David
http://www.dcsoft.com
Avoiding flicker IS trivial. One key technique is to avoid any use of UpdateData, which
causes a lot of flickering as static and edit controls get re-updated. Since I don't use
UpdateData, I never have a flicker problem except in individual controls. And the ways of
avoiding this are well-known, and often do NOT involve needing an offscreen bitmap (for
example, simply invalidating the minimal region required for update usually is
sufficient). "Optimizing display performance" is usually best addressed by a variety of
other means; the offscreen bitmap often pessimizes performance because the entire bitmap
has to be drawn first, and only then a piece of it is transferred to the actual screen.
So again, the issue is well-understood, and has to be localized to each control.
void CMyEdit::SetWindowText(LPCTSTR s)
{
CString old;
CEdit::GetWindowText(old);
if(old != s)
CEdit::SetWindowText(s);
}
is a truly trivial solution to a flickering edit control; substitute CStatic in a CStatic
subclass and you have optimized flicker in a CStatic text control. Hard to imagine a more
trivial solution.
The hardest anti-flicker issue I had to deal with was in updating a real-time scrolling
graph. That did involve using ScrollWindow to slide the graph to the left, and not doing
any drawing on the left side of the scrolled area, neither one of which was particularly
challenging. Other anti-flicker I've done involves only doing a very careful computation
of the minimal region to be invalidated, which is not terribly hard in most cases.
So it is more important to investigate the trivial solutions first.
joe
Joseph M. Newcomer [MVP]
Agreed, but the OP explicitly said the whole dialog and not a control. I
don't really understand the problem he's trying to solve, but you're right,
dialogs don't inherently flicker, so it must be some control he has on it
that could be individually optimized, or else he is getting a DC for the
dialog and drawing on it directly, which I agree should be discouraged.
-- David
http://www.dcsoft.com
Joseph M. Newcomer [MVP]
"David Ching" <d...@remove-this.dcsoft.com> wrote in message
news:_9kYd.8085$C47....@newssvr14.news.prodigy.com...
this just made me wish it would be possible ( like in 3d apps ) to make
the whole window belive that there's no window dc but a memory dc
instead where all controls would update themselves into and later when
all drawing is done i would have copied that memorydc to screen. ok. i
understand that's not possible.
another approach - and i guess a much cleaner one - would be to handle
all the background drawing in OnEraseBackground but before that subtract
all control/child window rects from the drawing/clipping rect somehow. i
guess ExcludeClipRect would be the way to go. so the background would
only be drawn on those areas of the dialog where no other control would
then be drawn afterwards. this would avoid flicker pretty good i guess.
if that fails as well i will just end up creating my own controls where
i have total control of, i guess ;)
thnks anyway
Peter
I think painting the background in OnEraseBackground will do it for you.
Just draw your bitmap at that time. The dialog has the WS_CLIPCHILDREN
style, so all the Windows controls on top of your background will be
automatically clipped out when you paint your background.
One more thing: don't call the inherited OnEraseBackground(), as that will
paint a solid gray background before you paint your bitmap, which isn't
necessary. As long as your bitmap covers every pixel in the dialog, that's
all that's needed.
Hope this helps,
David
http://www.dcsoft.com
There is no need to "subtract" the controls out if you do the WS_CLIPSIBLINGS style on the
CWnd you create; it will be properly clipped, so you don't need to compute clipping
regions. WS_CLIPCHILDREN would work for the dialog, I think, but since I don't believe in
drawing on the dialog I've never tried to solve this problem (I have used the CWnd trick
to get fancy backgrounds on a dialog).
There is certainly no need to create your own controls, particularly because they will not
change this problem in the slightest.
joe
Joseph M. Newcomer [MVP]
Joseph M. Newcomer [MVP]
- Mark R
Yes, our bosses may or may not be able to appreciate the subtle details of
our implementations, but they sure can tell flicker when they see it and
assume the rest of our code is equally laden unoptimized.
-- David
http://www.dcsoft.com
--
songzude
------------------------------------------------------------------------
Posted via http://www.codecomments.com
------------------------------------------------------------------------