Board index » delphi » Why can I use my own cursor?

Why can I use my own cursor?

Here's a part of my code:
***********
implementation
{$R *.DFM}

const   crMyCursor = 5;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Screen.Cursors[crMyCursor] := LoadCursor(HInstance,'Newcursor');
  Cursor := crMyCursor;
end;
**********
Where my cursor's name is 'Newcursor'  in my ressource file.
Where crMyCursor is a new and unused index of Cursor[  ] .
My purpose is to run my application with my own cursor.
My application runs like nothing has changed!

 

Re:Why can I use my own cursor?


Here's a part of my code:
***********
implementation
{$R *.DFM}

const   crMyCursor = 5;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Screen.Cursors[crMyCursor] := LoadCursor(HInstance,'Newcursor');
  Cursor := crMyCursor;
end;
**********
Where my cursor's name is 'Newcursor'  in my ressource file.
Where crMyCursor is a new and unused index of Cursor[  ] .
My purpose is to run my application with my own cursor.
My application runs like nothing has changed!

my e-mail address: yva...@hotmail.com

Re:Why can I use my own cursor?


Such a problem appears for several reason on my experience :
I. You have to place your cursor to a .RES-file (which has unique name, e.g.
chhhsrt.res) and include it by {$R chhhsrt.res} statement. Everithing else
let stay the same.
The problem appears when .RES - file has the same name as e.g. a project.
When linking, Delphi override this file so your cursor disappers.
II. Try rename your cursor to  'NEWCURSOR' (capital letters) in resource
file and then use LoadCursor(hInstance,'NEWCURSOR');

If the problem will not run away - to be continued.

Maks.

Quote
>implementation
>{$R *.DFM}

>const   crMyCursor = 5;

>procedure TForm1.FormCreate(Sender: TObject);
>begin
>  Screen.Cursors[crMyCursor] := LoadCursor(HInstance,'Newcursor');
>  Cursor := crMyCursor;
>end;
>**********
>Where my cursor's name is 'Newcursor'  in my ressource file.
>Where crMyCursor is a new and unused index of Cursor[  ] .
>My purpose is to run my application with my own cursor.
>My application runs like nothing has changed!

>my e-mail address: yva...@hotmail.com

Re:Why can I use my own cursor?


Quote
votrenom wrote:

> Here's a part of my code:
> ***********
> implementation
> {$R *.DFM}

> const   crMyCursor = 5;

> procedure TForm1.FormCreate(Sender: TObject);
> begin
>   Screen.Cursors[crMyCursor] := LoadCursor(HInstance,'Newcursor');
>   Cursor := crMyCursor;
> end;
> **********
> Where my cursor's name is 'Newcursor'  in my ressource file.
> Where crMyCursor is a new and unused index of Cursor[  ] .
> My purpose is to run my application with my own cursor.
> My application runs like nothing has changed!

You have to put "Newcursor" into the unit resource file (not the
application resource) and refer it after the implementation as
{$R *.RES}

Hope this is of some help.
Tibor

--------------------------------------
Tibor F. Liska     MTA SZTAKI
                   Lagymanyosi utca 11
                   1111 Budapest
                   Hungary
Fax:    +36-1-209-5288
Tel:    +36-1-209-5284
E-mail: li...@sztaki.hu
--------------------------------------

Other Threads