Solved

Change the cursor so i will show on all my components

Posted on 2003-10-27
4
265 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

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…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

776 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