Solved

VCL Bug???

Posted on 2001-08-15
6
291 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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: 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.

Question has a verified solution.

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

Suggested Solutions

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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

737 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