Solved

Change the cursor so i will show on all my components

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

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

Suggested Solutions

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

830 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