Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Re: Owner draw main windows, will left some drawing on the background of the window, I want the reason and how to prevent this happen?

16 views
Skip to first unread message

green

unread,
Dec 23, 2009, 12:48:31 AM12/23/09
to
I used HDC hWindowDC = GetWindowDC();
Draw the non client area on hWindowDC

in class of WTL:

class CMainFrame : public CFrameWindowImpl<CMainFrame>, public
CUpdateUI<CMainFrame>,
public CMessageFilter, public CIdleHandler


---------------------------------------------------------------------------------------------
"green" <green...@hotmail.com> д����Ϣ����:e4v77F5g...@TK2MSFTNGP02.phx.gbl...
> Hello, every one!
>
> Ownerdraw main window , I used SetWindowRgn to cut down the four corners,
> but there will left something drawing here when you drag the corners and
> borders to resized the window on the background of the main window. Only 3
> corners of the four corners do this.
>
>
> Thanks a lot!
>
>
>
>


David Ching

unread,
Dec 23, 2009, 2:03:05 PM12/23/09
to
I haven't seen SetWindowRgn being used on an overlapped window (one
containing the caption bar with the minimize, maximize, close buttons)
before. Windows normally draws that non-client area. Are you running on
Aero? I've seen people report issues that they can no longer custom paint
the non-client area on Aero, maybe this is related to trying to use
SetWindowRgn to limit the painting of it. I have only seen SetWindowRgn
used successfully with WS_POPUP windows which don't have the caption bar.

-- David


"green" <green...@hotmail.com> wrote in message
news:uvUQRO5g...@TK2MSFTNGP02.phx.gbl...

Joseph M. Newcomer

unread,
Dec 23, 2009, 3:05:32 PM12/23/09
to
It looks like you have a one-pixel error. Be aware that GDI coordinates in GM_COMPATIBLE
mode (the default, unless you have set GM_ADVANCED, which is rarely done) are 1 smaller
than the object. So you might try adding 1 to the right/width and bottom/height of
computations and see if that fixes the problem.

Note: given a choice of representing x0-to-x1 using either the value x1-1 or x1, no matter
which choice is made, it will be wrong. Over the years, I have worked with several
graphics systems. Some of them used x1, some used x1-1. Each will give you problems. The
x1-1 generally has fewer problems. In either system you end up in some contexts either
adding 1 (for those that give x1-1) or subtracting 1 (for those that give x1) so there is
no one "right" solution.
joe

On Wed, 23 Dec 2009 13:33:38 +0800, "green" <green...@hotmail.com> wrote:

>Hello, every one!
>
>Ownerdraw main window , I used SetWindowRgn to cut down the four corners,
>but there will left something drawing here when you drag the corners and
>borders to resized the window on the background of the main window. Only 3
>corners of the four corners do this.
>
>
>Thanks a lot!
>
>

Joseph M. Newcomer [MVP]
email: newc...@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm

Joseph M. Newcomer

unread,
Dec 23, 2009, 3:18:02 PM12/23/09
to
My essay on SetWindowRgn, which has a cat-shaped region, is a top-level window. But it
doesn't have a caption, so I'm not sure this is relevant.
joe

green

unread,
Dec 23, 2009, 9:36:17 PM12/23/09
to

Thank you David and Joe, Merry Christmas and a Happy New Year!


"Joseph M. Newcomer" <newc...@flounder.com>
??????:bfu4j5ls8v719g0iq...@4ax.com...

green

unread,
Dec 23, 2009, 10:31:22 PM12/23/09
to
Thank you Joseph,

Your idea seems good and ... ,
Let me try!

By the why , late I will upload my test source code and the app (exe file).

Merry Christmas and a Happy New Year!

"Joseph M. Newcomer" <newc...@flounder.com>
??????:rpt4j59avpte2ucm5...@4ax.com...

Joseph M. Newcomer

unread,
Dec 24, 2009, 1:16:58 PM12/24/09
to
File attachments, particularly images, depend on the news server and the news reader. Some
servers simply discard attachments. Some news readers will show the attachments as text,
which makes for long boring sequences of incomprehensible text in messages.

It is generally a good idea to avoid posting attachments, whether zip files or images. For
example, I almost never see an image; I saw one a few days ago, and that was actually a
surprise.
joe

On Thu, 24 Dec 2009 13:27:14 +0800, "green" <green...@hotmail.com> wrote:

>
>I can not upload zip files and jpg files now , Just one more test on jpg
>file upload.


>
>
>
>
>"green" <green...@hotmail.com> д����Ϣ����:e4v77F5g...@TK2MSFTNGP02.phx.gbl...

David Ching

unread,
Jan 4, 2010, 10:07:50 PM1/4/10
to
"green" <green...@hotmail.com> wrote in message
news:#dC6vxaj...@TK2MSFTNGP05.phx.gbl...
> Hi, Everyone!

>
> Ownerdraw main window , I used SetWindowRgn to cut down the four corners,
> but there will left something drawing here when you drag the corners and
> borders to resized the window on the background of the main window. Only 3
> corners of the four corners do this.
>
> I used HDC hWindowDC = GetWindowDC();
> Draw the non client area on hWindowDC
>
> In class of WTL:

>
> class CMainFrame : public CFrameWindowImpl<CMainFrame>, public
> CUpdateUI<CMainFrame>,
> public CMessageFilter, public CIdleHandler
>


I've not used hWindowDC after SetWindowRgn before. Why don't you use a
client DC? Why do you need to draw the non-client area after you've cut
down (I assume you mean rounded) corners? I've used SetWindowRgn (
CreateRoundRectRgn(...) ) with good success.

-- David

0 new messages