Board index » delphi » Loading Custom Cursors in D3

Loading Custom Cursors in D3

Tried to RTFM, but it was not clear on how to load a custom cursor
into a Delphi 3 app.

The Help says
"This example shows how to add custom cursors to an application.  It
assumes that a custom cursor with the name NewCursor has been added to
the resources (.RC file) of the application. The following code makes
this cursor available to the application via the constant crMyCursor,
and sets it as the global cursor to the application.

const

  crMyCursor = 5;
procedure TForm1.FormCreate(Sender: TObject);
begin
  Screen.Cursors[crMyCursor] := LoadCursor(HInstance, 'NewCursor');
  Cursor := crMyCursor;
end;
"
I tried this, but failed to get it to work. I figured out that I could
use the Image Editor to edit a new cursor into the application's .RES
file with the name 'NewCursor'. but how do I use the LoadCursor
procedure to get to use this resource file. I don't fully understand
the HInstance argument to that function.  

Is that my problem or can someone explain in a little more detail how
to load a custom cursor.

Many thanks,
Alan Murphy  
To reply remove two '.null's from
murphy.n...@enterprise.net.null
http://homepages.enterprise.net/murphy/

 

Re:Loading Custom Cursors in D3


The problem is that you don't want to insert any custum resources in the
applications.RES file because it
will always get removed on compile. this file is build with all visual
code ect..
  Make your self a separate Res file and just use the {$R ?????.Res} in
your app /
also the File names are to Be all Uppercase.
Quote
Alan Murphy wrote:
> Tried to RTFM, but it was not clear on how to load a custom cursor
> into a Delphi 3 app.

> The Help says
> "This example shows how to add custom cursors to an application.  It
> assumes that a custom cursor with the name NewCursor has been added to
> the resources (.RC file) of the application. The following code makes
> this cursor available to the application via the constant crMyCursor,
> and sets it as the global cursor to the application.

> const

>   crMyCursor = 5;
> procedure TForm1.FormCreate(Sender: TObject);
> begin
>   Screen.Cursors[crMyCursor] := LoadCursor(HInstance, 'NewCursor');
>   Cursor := crMyCursor;
> end;
> "
> I tried this, but failed to get it to work. I figured out that I could
> use the Image Editor to edit a new cursor into the application's .RES
> file with the name 'NewCursor'. but how do I use the LoadCursor
> procedure to get to use this resource file. I don't fully understand
> the HInstance argument to that function.

> Is that my problem or can someone explain in a little more detail how
> to load a custom cursor.

> Many thanks,
> Alan Murphy
> To reply remove two '.null's from
> murphy.n...@enterprise.net.null
> http://homepages.enterprise.net/murphy/

Re:Loading Custom Cursors in D3


The message <38d14812.54939...@news.enterprise.net>
  from  murphy.n...@enterprise.net.null (Alan Murphy) contains these words:

Quote
> Tried to RTFM, but it was not clear on how to load a custom cursor
> into a Delphi 3 app.

Hi Allan,
This is a reprint of my reply to the thread "Custom Cursor Woes"
which has probably gone off your server by now. Here is an
outline of what you need.

{=================================================
 Global Constants at the Beginning of your program
 =================================================}
const crMagnify= 1 ;    //custom cursor: Magifier
      crPBrush = 2 ;    //custom cursor: PaintBrush  
.............

{======================================================
 Assign the cursors to the Screen Object in Form Create
 ======================================================}
.............
Screen.Cursors[crMagnify] := LoadCursor(HInstance, 'CURSOR1');
Screen.Cursors[crPBrush]  := LoadCursor(HInstance, 'CURSOR2');
.............

{=======================
 Later On In your Program
 You can assign them to
 different components
 ========================}
..................
PaintBox1.Cursor:=crPBrush;
..................

Use the Image Editor to make the cursors. If your program is Myprog.exe
they go in the file Myprog.res. Stick to upper case for the names of
the cursors in the resource file. It has been a while since I did this
but I think they are case sensitive. After you have updated the resource
file, you need to restart Delphi (Delphi 3, this may not apply in later
versions) for the change to be recorded.

--
regards Andreas Kyriacou

Don't criticize a man until you've walked a mile in his shoes,
that way when you criticize him you're a mile away and have his shoes.
--------------------------
http://www.andrikkos.co.uk

Other Threads