Article View: borland.public.cppbuilder.nativeapi
Article #4758Re: Capture WM_NCPAINT?
From: Paw Suddergaard
Date: Tue, 29 Nov 2005 09:16
Date: Tue, 29 Nov 2005 09:16
56 lines
2750 bytes
2750 bytes
Hi,
Once again thanks for your reply!
Here is my code:
******************
.h:
******************
class TForm2 : public TForm
{
__published: // IDE-managed Components
private: // User declarations
MESSAGE void __fastcall WMNCPaint(TWMNCPaint &Message);
public: // User declarations
__fastcall TForm2(TComponent* Owner);
BEGIN_MESSAGE_MAP
VCL_MESSAGE_HANDLER(WM_NCPAINT, TWMNCPaint, WMNCPaint)
END_MESSAGE_MAP(TForm)
};
*****************
.cpp:
*****************
void __fastcall TForm2::WMNCPaint(TWMNCPaint &Message)
{
TForm::Dispatch(&Message);
TCanvas *ACanvas = new TCanvas;
try
{
// to retrieve the device context for the window
ACanvas->Handle = GetWindowDC(Handle);
ACanvas->Brush->Style = bsClear;//transparant background
ACanvas->Font->Style = TFontStyles() << fsBold;
// calculate the left coordinate for caption drawing
int intLeftShift = GetSystemMetrics(SM_CYMENU) +
GetSystemMetrics(SM_CXBORDER);
// calculate the top coordinate for caption drawing
int intTopShift = ((GetSystemMetrics(SM_CYCAPTION) -
abs(ACanvas->Font->Height)) / 2);
// output the caption string
ACanvas->TextOut(intLeftShift, intTopShift, "Test!");
}
__finally
{
// to release the device context
ReleaseDC(Handle, ACanvas->Handle);
delete ACanvas;
}
}
//---------------------------------------------------------------------------
Technical Details
Message-ID:
<438c19b9$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed.hal-mli.net!feeder1.hal-mli.net!news-out.newsfeeds.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mailReferences:
<43843bb9$1@newsgroups.borland.com> <43843d59$1@newsgroups.borland.com> <438b21c8$1@newsgroups.borland.com> <438b89a3$1@newsgroups.borland.com> <438c0d22$1@newsgroups.borland.com> <438c1578$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,95cf0255de9936de X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit Date: Tue, 29 Nov 2005 10:16:16 +0100 From: Paw Suddergaard <paw@top-house.dk> User-Agent: Mozilla Thunderbird 1.0.7 (Windows/20050923) X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: borland.public.cppbuilder.nativeapi Subject: Re: Capture WM_NCPAINT? References: <43843bb9$1@newsgroups.borland.com> <43843d59$1@newsgroups.borland.com> <438b21c8$1@newsgroups.borland.com> <438b89a3$1@newsgroups.borland.com> <438c0d22$1@newsgroups.borland.com> <438c1578$1@newsgroups.borland.com> In-Reply-To: <438c1578$1@newsgroups.borland.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 62.242.10.213 Message-ID: <438c19b9$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1133255097 62.242.10.213 (29 Nov 2005 01:04:57 -0700) Lines: 56 Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed.hal-mli.net!feeder1.hal-mli.net!news-out.newsfeeds.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail