Article View: borland.public.cppbuilder.nativeapi
Article #38Re: Some HDC questions
From: UO
Date: Tue, 05 Aug 2008 19:16
Date: Tue, 05 Aug 2008 19:16
39 lines
1984 bytes
1984 bytes
"Remy Lebeau (TeamB)" <no.spam@no.spam.com> wrote in message
news:489892df$1@newsgroups.borland.com...
>Do not hold on to any HDC that you do not explicitally create yourself.
Then, yes, CreateCompatibleDC/DeleteDC can be used between messages
> That is the correct way to use it. Always re-select any previous GDI
> resources you replace when you are done using them.
>
>> case WM_PAINT:
>> hdc = GetDC(hwnd);
>
> You should be looking at the wParam value. If not 0, it contains an HDC
> that you need to draw to instead.
Sorry, my mistake. The code should be:
case WM_PAINT:
hdc = BeginPaint(hdc, &ps);
hBrushOld = SelectObject(hdc, hBrush);
GetClientRect(&rect);
Rectangle(hdc, 10, 20, 30, 40);
SelectObject(hdc, hBrushOld); //1
EndPaint(hdc, &ps);
break;
>> So, when is it necessary to restore default attributes?
>
> Always.
It's quite weird that a textbook which is considered as "classic" or "best"
by many people,
can contain so arguable material.
Thanks again...
Technical Details
Message-ID:
<4898a6fd$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!feeder.news-service.com!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<489877b5$1@newsgroups.borland.com> <489892df$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,fa1b3304c969ec75 X-Google-Attributes: gid10cc67,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit From: "UO" <uo@uott> Newsgroups: borland.public.cppbuilder.nativeapi References: <489877b5$1@newsgroups.borland.com> <489892df$1@newsgroups.borland.com> Subject: Re: Some HDC questions Date: Tue, 5 Aug 2008 22:16:18 +0300 Lines: 41 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2180 X-RFC2646: Format=Flowed; Response X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 NNTP-Posting-Host: 88.246.211.67 Message-ID: <4898a6fd$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1217963773 88.246.211.67 (5 Aug 2008 12:16:13 -0700) Path: arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!feeder.news-service.com!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail