Timothy Dean
You should create the parent with the WS_CLIPCHILDREN style.
It is rare to ever draw on a CFormView directly.
joe
Joseph M. Newcomer [MVP]
email: newc...@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
Tom
"Timothy Dean" <tim....@mobiledataforce.com> wrote in message
news:uQh1JBWM...@TK2MSFTNGP04.phx.gbl...
Timothy Dean
"Tom Serface" <tom.n...@camaswood.com> wrote in message
news:262C18CA-05A8-4FA7...@microsoft.com...
http://www.codeproject.com/staticctrl/TransparentStaticCtrl.asp
Tom
"Timothy Dean" <tim....@mobiledataforce.com> wrote in message
news:e74b3IhM...@TK2MSFTNGP02.phx.gbl...
You would have to subclass the controls, intercept the OnPaint notifications, and handle
them there, which is nontrivial in and of itself, but take it that without doing this it
is IMPOSSIBLE to know when a control redraws itself. Or you could use an in-process hook
function to accomplish this. But you can safely assume that (a) you have no control over
drawing order and (b) no idea when to draw anything anywhere under any conditions, unless
you know when the WM_PAINT message comes in for that control! While it may appear that
there is an order to the messages, there are lots of ways this order can change, so you
can't rely on it. Z-order is irrelevant because the parent dialog is implicitly below
every other control and this cannot be changed.
If you place some other control on top of the control, it would have to be a transparent,
non-responsive, CStatic, and you would have to invalidate it whenever you intercepted a
WM_PAINT for the control it covers...and that's just a guess on my part that it could be
made to work at all. And I'm not sure that would work, anyway. Windows just has too many
assumptions built in that you are trying to violate all over the place, and therefore you
are fighting the basic design of the system.
Why don't the controls decorate themselves? You are trying to accomplish something that
is not really supported by the fundamental operating system, and most attempts to achieve
what you want that do not involve actually subclassing the controls themselves, and in the
case of WM_PAINT this is a really, really dangerous thing to do, is likely going to be
doomed.
joe
Timothy Dean
"Joseph M. Newcomer" <newc...@flounder.com> wrote in message
news:9t8sk39qhvo8kuptv...@4ax.com...
There are a couple ways to handle this. For example, you could use a "buddy" window, a
CStatic that was of the desired size and which was the immediate predecessor in the
Z-order. So the custom control would then get the previous control in the Z-order, and
SendMessage a user-defined message to it. This control would simply draw itself. If the
dialog has WS_CLIPSIBLINGS, then it will not overwrite its sibling control. If I wanted
to do this, that's the approach I'd take. Note that if the immediate sibling is NOT one
of your magical decoration CStatics, then the message will be ignored (I would not use
other than a RegisteredWindowMessage message for this). Or, you could have a "master"
CStatic that covered the entire dialog, and you would SendMessage the handle or CWnd* of
your current control. From this handle or CWnd*, you can GetWindowRect, ScreenToClient,
expand the resulting rectangle by the size of the decoration, Invalidate that area, and
just let that window redraw. It would query each custom control by doing a SendMessage of
a RegisteredWindowMessage, saying "please tell me about your decorations" and the LRESULT
would either be NULL ("no decorations, or I'm not one of your custom windows") or a
pointer to some useful information that tells it what decorations to add. Both of these
are substantially easier than most other approaches I can think of.
joe