Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

loading a Cursor  from a cursor (.cur) file

Posted on 1997-08-06
9
Medium Priority
?
841 Views
Last Modified: 2010-04-04
I want to change the cursor in my app for one I have designed but I cannot seem to get the LoadCursorFromFile API call working,

Could somebody please post an example of how to do this. Also my copy of the delphi image editor will not let me set the cursor hot spot - is this a bug?

I have delphi 2.01
0
Comment
Question by:essbb
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
9 Comments
 
LVL 5

Expert Comment

by:ronit051397
ID: 1340716
1. By the Image Editor which comes with Delphi, create a new resource file on the same directory of the project. Name it as test.res.
2. Draw a cursor and name it as CURSOR_1.
3. Open a new Project.
 In the project file write:

program Project1;

uses
Forms,
Unit1 in 'Unit1.pas' {Form1};

{$R *.RES}
{$test.res}

begin
  Application.Initialize;
  Application.CreateForm(TForm1, Form1);
  Application.Run;
end.

5.Place a button on the form.
6. Write the following code:
unit Unit1;
interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;

type
TForm1 = class(TForm)
Button1: TButton;
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.FormCreate(Sender: TObject);
begin
  screen.cursors[1]:=LoadCursor(hInstance, pChar('CURSOR_1'));
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  DestroyCursor(Screen.Cursors[1]);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  Form1.Cursor:=1;
end;

end.


0
 

Author Comment

by:essbb
ID: 1340717
Thanks For the answer

Is there any way of loading an existing cursor file (i.e a .cur) into the resource file?

I am not using image editor to create my cursors because it will not let me set the hot spot!
0
 
LVL 3

Expert Comment

by:mirek071497
ID: 1340718
Bad !
When You load *.cur into the Image Editor then in Menu Cursor select Set Hot Spot.

When You lad *.res and Open Cursor then you have the same menu.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 5

Expert Comment

by:ronit051397
ID: 1340719
Correction:
you should write:
{$R *.RES}
{$R test.res}
and as mirek said you do have a hot spot setting in the image editor.
0
 

Author Comment

by:essbb
ID: 1340720
I know about the option on the cursor menu!
The problem is that it does not rememeber the values that I put in. If I change the settings for a new cursor from 0,0 to say 10,10 then when I select test cursor the hot spot is still at 0,0!

Also I would  like to use colour in the cursor and image editor does not support this. B&W cursors only.

0
 
LVL 5

Accepted Solution

by:
ronit051397 earned 200 total points
ID: 1340721
1. The HotSpost in the ImageEditor works, I checked.
2. Yes, The ImageEditor supports only B&W cursors.
3. On a buttonclick event write:
screen.cursors[1]:=LoadCursorFromFile('c:\something.cur');
form1.cursor:=1;
4. In the first method you don't need the res file for the installation becuase it is included in the exe file you create.
In the second method you need the cur file to be installed as well as the exe file.

0
 

Author Comment

by:essbb
ID: 1340722
Yep that did the trick!

I have tested image editor again and It still will not let me set the hot spot!!

Any Idea what may be causing this? If it works fine on yours then it cannot be a bug with image editor. Do you have delphi 2.01?
0
 
LVL 5

Expert Comment

by:ronit051397
ID: 1340723
No, Version 2.0
0
 
LVL 5

Expert Comment

by:ronit051397
ID: 1340724
The Delphi ImageEditor has some other bugs.
Try to use ImageEditor of the VisualC++ package. But I think it creates only B&W cursors.
0

Featured Post

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question