Solved

Change the cursor so i will show on all my components

Posted on 2003-10-27
4
263 Views
Last Modified: 2010-04-05
Hi there!

When i load an *.ani cursor file into my program like this:
----------------------------------------------------------------
const
const1 = 1;
begin
Screen.Cursors[const1] := LoadCursorFromFile('ancur.ani');
Cursor := const1;
---------------------------------------------------------------------

It only shows when I hold my cursor over the form and not over buttons and such.... hmmm =) How can I make this happen?
I grant you 50 points for this question... be gratefull ;-)
0
Comment
Question by:Derox
  • 2
  • 2
4 Comments
 
LVL 22

Accepted Solution

by:
Ferruccio Accalai earned 50 total points
ID: 9627229
procedure TForm1.Button1Click(Sender: TObject);
var
i:Integer;
begin
for i := form1.ComponentCount-1 downto 0 do
if  (form1.Components[i] is tcontrol) then
      (form1.Components[i] as tcontrol).Cursor := Form1.Cursor;
end;
 
F&8 ;-)
0
 

Expert Comment

by:jgilm
ID: 9630393
With the code above in the answer, you are assigning the form's cursor value (namespace problem). To have the whole application use a cursor value do:

Screen.Cursor := Const1;
0
 
LVL 22

Expert Comment

by:Ferruccio Accalai
ID: 9632819
it was just a fast example jgilm.
In his question he said that he assigns a screen.cursor exactly as you said, so it was implicit in the answer.
Sometimes's better reading the whole question.
F68 ;-)
0
 

Expert Comment

by:jgilm
ID: 9636542
Actually Ferruccio68 I did read the entire question. No where did he mention he assigned "screen.cursor". This is different than loading the cursor and assigning it to the "list" of cursors (which his example did show "Screen.Cursors[const1] := ..."

His code was may have been a quick example, his description of the problems describes exactly what would happen by executing the code in his example. The form's cursor is being set. So when the mouse is over the form the cursor is cursor const1. When the mouse is over the control it changes to the crDefault cursor (or any other cursor set for that control). This is the problem and your solution changes that behavior by assigning the const1 cursor to all controls.

I merely posited another way of achieving the same result without changing all controls' cursor property. You don't even have to set the form's cursor. Just do Screen.Cursor := Const1 and the cursor will never change as long as the cursor is in the application. However, this also makes the cursor change for ALL forms in the application. This may not have been what he wanted.

I did make a typo in my original comment, that is I meant to talk about the code in the question (not the answer). Your code is valid, and I did not mean to say differently. Both of our answers satisify his basic need of having the same cursor show over the entire form.

Normally, I would not have replied since the questioner was already satisfied with your response, except that you accused me of not reading the whole question. And then you went on to say something he did not say in his question (that he assigned the screen.cursor, he did not). If he had assigned the screen.cursor, he would not have had the problem he was discussing.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Simple Delphi Question 9 83
Can Viruses spread while transferring Binary data with Winsock 2 66
find a node in VST 2 63
control image tags in a string ? 12 110
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…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Concerto provides fully managed cloud services and the expertise to provide an easy and reliable route to the cloud. Our best-in-class solutions help you address the toughest IT challenges, find new efficiencies and deliver the best application expe…

929 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

15 Experts available now in Live!

Get 1:1 Help Now