在Delphi 2007中,在鼠标移动事件中,我尝试使用以下命令更改鼠标光标:
procedure TFr_Board_Display.PaintBox_Proxy_BoardMouseMove(Sender: TObject;
Shift: TShiftState; X, Y: Integer);
begin
if left_mouse_button_down then begin
if some_condition then begin
Cursor := crDrag;
end
else begin
Cursor := crNoDrop;
end;
end
else begin
if some_other_condition then begin
Cursor := crHandPoint;
end
else begin
Cursor := crDefault;
end;
end;
end;
Run Code Online (Sandbox Code Playgroud)
例如.但是,当鼠标左键按下时,我移动鼠标,光标不会更改为crDrag或crNoDrop.执行代码(例如Cursor:= crDrag;)但光标不会改变.当鼠标左键向上,我移动鼠标时,光标没有任何问题.
(我最初尝试使用一些Drag&Drop事件和属性,但无法按照我想要的方式工作.)
编辑:澄清所需的行为和格式化的代码.
编辑:谢谢你,Gamecat,但我希望当鼠标左键关闭时光标改变,鼠标移动光标时应该在crDrag和crNoDrop之间来回切换.