Solved

How to display 16 or 256 color cursors in Delphi ?

Posted on 1997-09-21
15
444 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
  • 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
 

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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
This video discusses moving either the default database or any database to a new volume.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

746 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now