🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #17071

Re: Animated Cursor

#17071
From: nicolasr
Date: Sat, 12 Apr 2003 02:46
65 lines
2692 bytes
Hi,

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()
{
   //build the filename for the cursor file
   AnsiString fileName = ExtractFilePath(Application->ExeName) +
"MyAniCursor.ani";

   //locate the cursor resource,
   //you should add some error checking on the return values...
   HRSRC ResourceHandle = FindResource(HInstance, "MyAniCursor",
RT_RCDATA);
   HGLOBAL GlobalHandle = LoadResource(HInstance, ResourceHandle);
   PVOID Data = LockResource(GlobalHandle);

   //create the empty cursor file
   int FileHandle = FileCreate(fileName);

   //write the data from the resource to the file
   FileWrite
   (
      FileHandle,
      Data,
      SizeofResource(HInstance, ResourceHandle)
   );

   FileClose(FileHandle);

   //finally load the cursor from the file
   //and add it to the default cursors.
   //The default cursor constants are all negative, custom
   //cursors should have positive constants
   HCURSOR h = LoadCursorFromFile(fileName.c_str());
   if(h)
      Screen->Cursors[crMyAniCursor] = h;
}


//this example constructor initializes the cursor
//and sets the current cursor to your animated cursor

__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
   LoadMyAniCursor();
   Screen->Cursor = crMyAniCursor;
}


regards,
Nick
Technical Details
Message-ID: <3e977dee@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-06!sn-xit-09!sn-xit-08!supernews.com!newsfeed.news2me.com!border1.nntp.aus1.giganews.com!nntp.giganews.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <3e970095$1@newsgroups.borland.com> <3e97565d$1@newsgroups.borland.com> <3e976b3e$1@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-11 19:49:25 PST
From: "nicolasr" <nicolasrNOSPAMATSIGNgmx.net>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <3e970095$1@newsgroups.borland.com> <3e97565d$1@newsgroups.borland.com> <3e976b3e$1@newsgroups.borland.com>
Subject: Re: Animated Cursor
Date: Sat, 12 Apr 2003 04:46:38 +0200
Lines: 67
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2720.3000
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
NNTP-Posting-Host: 80.133.170.191
Message-ID: <3e977dee@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1050115566 80.133.170.191 (11 Apr 2003 19:46:06 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-06!sn-xit-09!sn-xit-08!supernews.com!newsfeed.news2me.com!border1.nntp.aus1.giganews.com!nntp.giganews.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail