TCustomControl 光标刷新
我有一个可以缩放图像的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论