Solved

VCL Bug???

Posted on 2001-08-15
6
290 Views
Last Modified: 2010-05-18
try this code:
procedure TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
   Label1.Caption:='down';
   Image1.Cursor:=crHandPoint;
end;

result:
Label1.caption changed immediately,but Image1.Cursor changed after Image1MouseUp event,why???bug???

How to Change Cursor immediately???
0
Comment
Question by:sundayboys
6 Comments
 

Expert Comment

by:comptebidon81
ID: 6387929
There has to be an OnMouseOver event in order for your programm to detect that te mouse is currently over the Image. You could try to use Screen.Cursor := crHandPoint and set the last cursor back after. This will take effect immediately.

GunDamn
0
 
LVL 3

Expert Comment

by:rondi
ID: 6388428

Try repainting the image/cursor ?
0
 
LVL 34

Expert Comment

by:Slick812
ID: 6389241
I've had some sucess with other controls by calling Appication.ProcessMessages right after the "Control1.Cursor := crHandPoint" , don't remember trying it on a TImage.
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 4

Accepted Solution

by:
DMN earned 30 total points
ID: 6390640
You can use Screen.Cursor instead of Image1.Cursor:

procedure TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  Label1.Caption:='down';
  Screen.Cursor:=crHandPoint;
end;
0
 
LVL 21

Expert Comment

by:gemarti
ID: 6390692
Well your question really is why is this happening and is it a bug right?

I don't think it is a bug. You see the OnMouseDown event for the Image object  is receiving the event, thus it is the handler. Before it's property (Cursor) can be changed the memory must be flushed and replaced with the updated property values.

I think this is why you don't actually see the cursor change until you release the mouse button. Once you release the mouse button the component is no longer receiving a WM_MOUSEDOWN Message and it can therefore update it's memory.

Probably not the most technical explaination...but this is what is happening.

Your other question was answered. To change the cursor immediately you should do so in an OnMouseMove event.

GEM
0
 
LVL 12

Expert Comment

by:rwilson032697
ID: 6390994
You can force the cursor to change immeditately by doing this:

var
  CPos : TPoint;

...

  // Force cursor change
  GetCursorPos(CPos);
  SetCursorPos(CPos.X, CPos.y);

Cheers,

Raymond.
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…

820 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