Article View: borland.public.cppbuilder.nativeapi
Article #16982Re: Animated Cursor
From: Fishface
Date: Sat, 12 Apr 2003 16:54
Date: Sat, 12 Apr 2003 16:54
54 lines
2501 bytes
2501 bytes
nicolasr wrote:
> I tried to setup the code in a simple test application.
> Assuming you have a new project and a cursor file
> MyAniCursor.ani in the project directory:
>
> Add a resource file to the project (f.e. resource.rc) and add this
> line to the file:
>
> MyAniCursor RCDATA "MyAniCursor.ani"
>
>
> then add this function to your project:
>
> #define crMyAniCursor 1
>
> void LoadMyAniCursor()
<snip>
That probably works fine, but you might rather do
something like this instead:
HICON LoadMyAniCursor()
{
HICON icon_error = reinterpret_cast<HICON>(-1);
HRSRC hrsrcicon = FindResource(HInstance, "MyAniCursor", RT_RCDATA);
if(!hrsrcicon) return icon_error;
DWORD rsrcsize = SizeofResource(HInstance, hrsrcicon);
if(!rsrcsize) return icon_error;
HGLOBAL hglobal = LoadResource(HInstance, hrsrcicon);
if(!hglobal) return icon_error;
PVOID pvoid = LockResource(hglobal);
if(!pvoid) return icon_error;
HICON hIcon = CreateIconFromResource(static_cast<PBYTE>(pvoid),
rsrcsize, TRUE, 0x00030000);
if(!hIcon) return icon_error;
return hIcon;
}
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
HICON icon = LoadMyAniCursor();
if(icon != INVALID_HANDLE_VALUE )
Screen->Cursors[crMyAniCursor] = icon;
}
void __fastcall TForm1::Button1Click(TObject *Sender)
{
Screen->Cursor = crMyAniCursor;
}
Technical Details
Message-ID:
<3e9844fc@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-06!sn-xit-01!sn-xit-09!supernews.com!iad-peer.news.verio.net!news.verio.net!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mailReferences:
<3e970095$1@newsgroups.borland.com> <3e97565d$1@newsgroups.borland.com> <3e976b3e$1@newsgroups.borland.com> <3e977dee@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,333f777e03b53e07 X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2003-04-12 09:57:29 PST From: "Fishface" <invalid@ddress.ok?> Newsgroups: borland.public.cppbuilder.nativeapi References: <3e970095$1@newsgroups.borland.com> <3e97565d$1@newsgroups.borland.com> <3e976b3e$1@newsgroups.borland.com> <3e977dee@newsgroups.borland.com> Subject: Re: Animated Cursor Date: Sat, 12 Apr 2003 09:54:36 -0700 Lines: 56 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 NNTP-Posting-Host: 209.102.127.81 Message-ID: <3e9844fc@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1050166524 209.102.127.81 (12 Apr 2003 09:55:24 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-06!sn-xit-01!sn-xit-09!supernews.com!iad-peer.news.verio.net!news.verio.net!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail