Article View: borland.public.cppbuilder.nativeapi
Article #16040Re: Creating an icon (short)
From: Hans Galema
Date: Sun, 01 Jun 2003 10:03
Date: Sun, 01 Jun 2003 10:03
62 lines
2915 bytes
2915 bytes
Chris wrote:
> i.hbmMask = Black->Picture->Bitmap->Handle;
Black is a TImage ? What does it contain ?
Did a google advanced newsgroups search on
text: ICONINFO CreateIconIndirect
groups: *cppbuilder*
found something what could be of use.
Hans.
Van:PaoloItaly (paolo@sirius.tecnoparco.it)
Onderwerp:Re: text on the tray
View: Complete Thread (3 bijdragen)
Original Format
Discussies:borland.public.cppbuilder.winapi
Datum:2002-04-22 04:09:01 PST
draw text in a TBitmap with TextOut and the trasform the bitmap in icon
Graphics::TIcon *BitmapToIcon(Graphics::TBitmap *Bitmap, int IconSizeX, int
IconSizeY)
{
ICONINFO IconInfo;
Graphics::TBitmap *IconBitmap, *MaskBitmap;
int x, y;
TColor TransparentColor;
Graphics::TIcon *Result
if(IconSizeX == -1)
{
IconSizeX = ::GetSystemMetrics(SM_CXICON);
IconSizeY = ::GetSystemMetrics(SM_CYICON);
}
IconBitmap = new Graphics::TBitmap;
IconBitmap->Width = IconSizeX;
IconBitmap->Height = IconSizeY;
IconBitmap->Canvas->StretchDraw(Rect(0, 0, IconSizeX, IconSizeY), Bitmap);
IconBitmap->TransparentColor = Bitmap->TransparentColor;
TransparentColor = (TColor)(IconBitmap->TransparentColor & 0xFFFFFF);
MaskBitmap = new Graphics::TBitmap;
MaskBitmap->Assign(IconBitmap);
for(y= 0; y < IconSizeY - 1 ;y++)
for(x= 0; x < IconSizeX - 1 ;x++)
if(IconBitmap->Canvas->Pixels[x][y] == TransparentColor)
IconBitmap->Canvas->Pixels[x][y] = clBlack;
IconInfo.fIcon = true;
IconInfo.hbmMask = MaskBitmap->MaskHandle;
IconInfo.hbmColor = IconBitmap->Handle;
Result = new Graphics::TIcon;
Result->Handle = ::CreateIconIndirect(&IconInfo);
delete MaskBitmap;
delete IconBitmap;
return Result;
}
Ciao
Technical Details
Message-ID:
<3ed9cf52$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-01!sn-xit-08!supernews.com!small1.nntp.aus1.giganews.com!border1.nntp.aus1.giganews.com!nntp.giganews.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mailReferences:
<3ed974e4$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,1a231bbe6eb7638e X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2003-06-01 03:16:10 PST Date: Sun, 01 Jun 2003 12:03:12 +0200 From: Hans Galema <j.m.galema.dontusethis@maartens.nl> User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.3.1) Gecko/20030425 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: borland.public.cppbuilder.nativeapi Subject: Re: Creating an icon (short) References: <3ed974e4$1@newsgroups.borland.com> In-Reply-To: <3ed974e4$1@newsgroups.borland.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 129.125.108.11 Message-ID: <3ed9cf52$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1054461778 129.125.108.11 (1 Jun 2003 03:02:58 -0700) Lines: 63 Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-01!sn-xit-08!supernews.com!small1.nntp.aus1.giganews.com!border1.nntp.aus1.giganews.com!nntp.giganews.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail