Solved

Change the cursor so i will show on all my components

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
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…

758 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

22 Experts available now in Live!

Get 1:1 Help Now