🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.windows.ms.programmer
Article #3111

Re: Rectangle tooo slow?

#3111
From: Risto Lankinen
Date: Fri, 07 Jun 1991 06:47
41 lines
2389 bytes
dave@wucs1.wustl.edu (David T Mitchell III) writes:

>I want to make my winapp's border non-standard colors (ie, active
>and inactive border colors != COLOR_ACTIVEBORDER, COLOR_INACTIVEBORDER).

>It appears that to process WM_NCPAINT, it's all or nothing (is this true?),
>so I decided to be Q&D about it...
>	.
>	.
>	case WM_NCPAINT:
>	    DefWindowProc(hwnd, msg, wParam, lParam);	// draw the window
>	    ExcludeClipRect(hdc, {everything inside the borders});
>	    SelectObject(hdc, CreateSolidBrush(myColor));
>	    Rectangle(hdc, 1, 1, {full window extents});
>	    return 0L;

>This works just dandy (left out details about checking for type of border,
>etc, for clarity), HOWEVER it's suprisingly slow!  Stepping through with the
>debugger I find that calling DefWindowProc paints the entire window frame
>with border BANG!, but Rectangle() paints so slowly that you first see the
>standard borders, then the new color flowing down over.

Hi!

Try FillRect() in place of Rectangle() .  Also, don't use CreateSolidBrush()
in a time-critical or frequently called WinProc-case.  You could create the
brush upon WM_NCCREATE, and store its handle into a static variable for use
where appropriate (and for deletion upon WM_NCDESTROY!!!) .

Also, how does 'wndclass.hbrBackground = NULL' affect the performance?  You
will then have to either handle the WM_ERASEBKGND or use FillRect() for the
first thing in the WM_PAINT to get a clean surface to draw on, but calling
the DefWindowProc() during (and not after) the WM_NCPAINT might generate some
extraneous postings/sendings of these messages.

Terveisin: Risto Lankinen
-- 
Risto Lankinen / product specialist ***************************************
Nokia Data Systems, Technology Dept *  2                              3   *
THIS SPACE INTENTIONALLY LEFT BLANK * 2 +1 is PRIME!  Now working on 2 -1 *
replies: risto@yj.data.nokia.fi     ***************************************
Technical Details
Message-ID: <1196@tuura.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!wuarchive!uunet!fernwood!uupsi!sunic!sics.se!fuug!tuura!risto
References: <1991Jun3.140840.26667@cec1.wustl.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!wuarchive!uunet!fernwood!uupsi!sunic!sics.se!fuug!tuura!risto
From: risto@tuura.UUCP (Risto Lankinen)
Newsgroups: comp.windows.ms.programmer
Subject: Re: Rectangle tooo slow?
Message-ID: <1196@tuura.UUCP>
Date: 7 Jun 91 06:47:29 GMT
References: <1991Jun3.140840.26667@cec1.wustl.edu>
Organization: Nokia Data Systems Oy
Lines: 41