Mega Code Archive

 
Categories / Delphi / Hardware
 

Why doesnt the cursor updates when I change it OnMouseDown

Title: Why doesn't the cursor updates when I change it OnMouseDown? Question: Did you ever try to assign a cursor to a control, for example OnMouseDown event? Answer: Probably you've tried, but without any luck. For some strange reason the code executed will not immediately use the cursor if a control has the mouse cursor capture (as is in this case). So, a solution to update immediately the cursor it's by sending a message like the following example: procedure TForm1.Panel1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin with TPanel(Sender) do begin Cursor := crHandPoint; Perform(WM_SETCURSOR, Handle, HTCLIENT); end; end;