Link to home
Start Free TrialLog in
Avatar of sundayboys
sundayboys

asked on

VCL Bug???

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???
Avatar of comptebidon81
comptebidon81

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

Try repainting the image/cursor ?
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.
ASKER CERTIFIED SOLUTION
Avatar of DMN
DMN

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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
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.