TCustomControl 光标刷新

发布于 2024-11-05 18:26:41 字数 805 浏览 0 评论 0原文

我有一个可以缩放图像的 TCustomControl。放大时,控件光标设置为 crZoomIn (+),缩小时,控件光标设置为 crZoomOut (-)。

测试时,控件光标设置正确,但光标不会自行刷新直到鼠标移出控件然后返回控件

如何刷新或更新光标,而无需将鼠标移出控件然后返回控件?

{编辑]

更改光标的代码是:

procedure TBitmapEditor.ZoomIn;
begin
  if Magnification = 1 then
    Magnification := 2
  else if Magnification < 32 then
    Magnification := Magnification + 2;
  Cursor := crZoomIn;
  Perform( CM_CURSORCHANGED, 0, 0 );
end;

procedure TBitmapEditor.ZoomOut;
begin
  if Magnification = 2 then
    Magnification := 1
  else if Magnification > 1 then
    Magnification := Magnification - 2;
  Cursor := crZoomOut;
  Perform( CM_CURSORCHANGED, 0, 0 );
end;

Perform( CM_CURSORCHANGED, 0, 0 );不会更改光标,但我认为光标设置正确,因为当我按照描述移动鼠标时,光标会正确更改。

I have a TCustomControl that zoom's an image. When zooming in the controls cursor is set to crZoomIn (+) and when zooming out the controls cursor is set to crZoomOut (-).

When testing, the controls cursor is set correctly, but the cursor does not refresh itself until the mouse is moved out of the control and then back onto the control.

How can I refresh or update the cursor without having to move the mouse out of the control then back onto the control?

{EDIT]

The code to change the cursor is:

procedure TBitmapEditor.ZoomIn;
begin
  if Magnification = 1 then
    Magnification := 2
  else if Magnification < 32 then
    Magnification := Magnification + 2;
  Cursor := crZoomIn;
  Perform( CM_CURSORCHANGED, 0, 0 );
end;

procedure TBitmapEditor.ZoomOut;
begin
  if Magnification = 2 then
    Magnification := 1
  else if Magnification > 1 then
    Magnification := Magnification - 2;
  Cursor := crZoomOut;
  Perform( CM_CURSORCHANGED, 0, 0 );
end;

Perform( CM_CURSORCHANGED, 0, 0 ); does not change the cursor, but the cursor is set correctly I think because when I move the mouse as described the cursor changes correctly.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文