Re: DrawCaption()

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



"L. Spiro" <LSpiro@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:2A7A6A65-85CD-4A52-B4BF-C9374183009C@xxxxxxxxxxxxxxxx
> The drawing of my caption must take place in two phases.
> Since my child dialog does not have a closing button, I have to draw it
> manually.
> I am drawing it by selecting the Webdings font and ExtTextOut() with
> character "r", which in that font is a closing-button "X".
> My problem is that if my dialog box gets too thin, the "X" draws over the
> title, which is far from professional in terms of looks.
>

Perhaps you could catch the 'resize' message and disallow anything smaller
than you want.
I can see you are experienced so if this is too obvious please forgive me.

> So I want to draw it in two passes.
> I use a clipping region to clip out the are right of where the "X" button
> begins, and I use DrawCaption() with DC_TEXT there.
> Then I invert that clipping region so only the "X" area is being drawn,
and
> I use DrawCaption() without DC_TEXT.
>
> This was supposed to cut the text off before it overlaps the closing
button,
> but instead the second DrawCaption() just doesn't do anything and leaves
me
> with a grey hole in my caption.
>
> I thought the problem was my clipping region initially, so I removed it
> totally.
> First I used DC_TEXT and it drew fine. I recompiled, omitting DC_TEXT
while
> not changing the clipping region at all and nothing was drawn.
> So I know it is not a problem with my clips.
>
> I do want my caption to be drawn, but not in the second pass. So it is
very
> inefficient to remove my caption text, draw, and then add it back.
>
> The only other solution I have considered is keeping a second window
hidden
> and setting the window styles on it that I want drawn on my current dialog
> caption and passing that HWND to DrawCaption() using my current dialog's
HDC.
> Doing that I could eliminate the need for multi-pass drawing since I can
add
> the button to the secondary window and all will be drawn at once.
> But is this really professional either?

I don't think so.

>
> Is there a better solution or a solution to this DrawCaption() problem?
>
>
> L. Spiro

What if you drew the caption into a mem DC and then blit it onto the window
as required?
If the gradient is to be one of your own choosing, and the width of the
window remains constant, perhaps you could use a bitmap with everything
already drawn on it?


Vince Morgan
Remove UNSPAM
vinhar@xxxxxxxxxxxxxxxxxxxxx


.


Quantcast