Solved

Change the cursor so i will show on all my components

Posted on 2003-10-27
4
268 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
[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
  • 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

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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Help on project with Soap 10 70
Tembedded WB animatid gifs not animated on some pcs 2 94
Convert MS Word document to a PDF file 9 138
MS Access from Delphi 31 104
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…
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…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

751 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