Solved

How to display 16 or 256 color cursors in Delphi ?

Posted on 1997-09-21
15
450 Views
Last Modified: 2011-09-20
I have a 16 color cursor saved as a resource in a .res file. Somewhere in my code I use LoadCursor API call to load my cursor. But when I try to use my nice cursor it is displayed black-and-white.

Am I doing something wrong ? How to display cursors more
than 2 colors ?

Any help, suggestions are welcome.

Levente
slv@mcse.hu
0
Comment
Question by:Levente
[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
  • 6
  • 6
  • 2
  • +1
15 Comments
 

Author Comment

by:Levente
ID: 1345731
Edited text of question
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1345732
How do you use the LoadCursor function? Can you give that piece of code, so I can look at it?
0
 
LVL 1

Expert Comment

by:sassas081597
ID: 1345733
Hi!
I don't know why do you have that trouble, but I can recommend you to use LoadImage or LoadCursorFromFile functions instead of LoadCursor. They do the same but can be adjusted more presizely.
You should also check if your cusror is painted and stored correctly.
0
Technology Partners: 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!

 

Author Comment

by:Levente
ID: 1345734
Here is the code:

var crHand = 10;

{$R BITMAPS.RES}    { This file contains the HAND cursor }

(...)
  Screen.Cursors[crHand]:=LoadCursor(hInstance,'HAND');
(...)
0
 

Author Comment

by:Levente
ID: 1345735
sassas,

Is LoadCursorFromFile a win16 Api call ? My Delphi doesn't seem to compile this. (I have Delphi 1 under win95.) My program need to work under win 3.x as well.
0
 
LVL 1

Expert Comment

by:sassas081597
ID: 1345736
Hi Levente
This function is used under win32s  - so it is 32Bit and its impossible to use it under D1.
And again, TRY TO REPAINT YOUR CURSOR. May be it was stored incorrectly.
Best wishes
0
 
LVL 3

Expert Comment

by:mirek071497
ID: 1345737
Hi All.
How can you create cursor with 16 or 256 colors. It is impossible !!!.

0
 
LVL 3

Expert Comment

by:mirek071497
ID: 1345738
Hi. Are you there ?

Answer It is impossible to create STandard cursor with more than two colors.
0
 

Author Comment

by:Levente
ID: 1345739
Hi Mirek,

Are you sure it is impossible to create a 16 color cursor !? I created one,  and I can assign to my default Win95 mouse cursor. And it works ! And I can see  all the 16 colors !!! Is it possible that Delphi 1 can't handle color  cursors ?! What do you mean by " it is impossible to create standard cursor with
more than two colors " ?

0
 
LVL 3

Expert Comment

by:mirek071497
ID: 1345740
When You run ImageEditor or ResourceWorkshop You can create cursor, but only with 2 colors. I don't know how can you create you'r 16colors Cursor
0
 
LVL 3

Expert Comment

by:mirek071497
ID: 1345741
Can you describe how Your 16-colors cursor was created ?
0
 

Author Comment

by:Levente
ID: 1345742
With Microangelo Stuido I created a new 16 color cursor. Then I drrew my cursor and saved it as a cursor resource. That's all.
0
 
LVL 3

Expert Comment

by:mirek071497
ID: 1345743
I was trying to create cursor indirect and i found so function CreateCursor can't create colored cursor however i found function CreateIconIndirect, which can create cursor with more colors. Unfortunatelly I can't get this working and I think so this may depend on SVGA chip or I have some mistakes. Can you mail to me your 16colored cursor for testing ? This can help me to help you.

mirek@izabell.itcomp.tpnet.pl
0
 
LVL 3

Accepted Solution

by:
mirek071497 earned 150 total points
ID: 1345744
Hi
Sorry for the long time, and thank you for the cursor.

I try load the cursor and all works fine. Mayby you have any mistake. Here is my code :

{ this is to loading from *.res files }
procedure TForm1.Button1Click(Sender: TObject);
begin
  Screen.Cursors[1] := LoadCursor( HInstance, PChar('CURSOR_1'));
  Screen.Cursor := 1;
end;

uses
  Windows;

{ this is to loading from *.cur files }
procedure TForm1.Button2Click(Sender: TObject);
begin
  Screen.Cursors[1] := LoadImage( 0, PChar('D:\FEL.CUR'), IMAGE_CURSOR, 0, 0, LR_LOADFROMFILE );
  Screen.Cursor := 1;
end;
0
 

Author Comment

by:Levente
ID: 1345745
Hi Mirek,

Sorry for the delay. and thank you for your code. I gave it a try and I had the  following result: using Delphi 1 or 2 my cursor *still* showed black-and-white. But when I compiled your code
in *Delphi 3* everything DID work. (I suppose you used Delphi 3, too) IMHO this behaviour must be a bug  in Delphi 1 and 2. This is not the first time I encountered  a weird Delphi bug ...

Thanks again,
Levente

0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

730 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