我有一个类似于Team View软件的远程访问,我想根据“ Controled”部分的鼠标图标更改鼠标光标(在“ Controler”部分,服务器端),就像在Team View软件中所做的那样。
我的软件正在使用A,TPaintBox
因为我需要将其他必要的东西做得TPaintBox
很好才能正常工作。
TPaintBox
具有crDefault
默认光标。仅当鼠标位于鼠标中时,如何才能更改此控件(在“控件”部分)TPaintBox
?
这是用于“受控”部分(客户端)中的鼠标捕获图标的代码。
这是我的代码,直到现在尝试更改“控制器”部分(服务器端)中的鼠标图标:
//pbRec is name of TPaintBox used
procedure TForm2.pbRecMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
begin
if Form2.lblPoint.Caption = 'OCR_NORMAL' then
pbRec.Cursor := crDefault
else if Form2.lblPoint.Caption = 'OCR_HAND' then
pbRec.Cursor := crHandPoint
else if Form2.lblPoint.Caption = 'OCR_IBEAM' then
pbRec.Cursor := crIBeam;
end;
所有建议将受到欢迎。
如果您想在代码中更改光标,则将执行以下操作。
//Context: Timer.Interval = 50; :-)
procedure TForm57.Timer1Timer(Sender: TObject);
var
p: TPoint;
begin
if Ord(PaintBox1.Cursor) < Ord(crSizeAll) then PaintBox1.Cursor:= crArrow
else PaintBox1.Cursor:= Pred(PaintBox1.Cursor);
//Force Windows to change the cursor by sending a WM_SETCURSOR message.
PaintBox1.Parent.Perform(WM_SETCURSOR, PaintBox1.Parent.Handle, MakeLParam(HTCLIENT, WM_MOUSEMOVE));
(** //if you're viewing using a slow remote connection you make need to do this:
//Wiggle the mouse to force cursor change.
GetCursorPos(p);
SetCursorPos(p.x-1, p.y);
Sleep(100); //needed on slow remote connection.
SetCursorPos(p.x, p.y); (**)
end;
如果每次鼠标进入画板时都根据上下文更改光标,则在MouseMove事件中这样做非常浪费。
而是在OnMouseEnter
事件中进行更改。
procedure TForm57.PaintBox1MouseEnter(Sender: TObject);
begin
if .... then PaintBox1.Cursor:= crIBeam
else if .....
PaintBox1.Parent.Perform(WM_SETCURSOR, PaintBox1.Parent.Handle, MakeLParam(HTCLIENT, WM_MOUSEMOVE));
end;
如果您在远程连接上,则客户端远程端可能会缓存游标。在这种情况下,您可能需要在一侧Sleep(100)
摆动,然后向后摆动,以便客户端软件能够检测到鼠标移动并强制刷新光标。
如果您只是希望其中的光标PaintBox
是静态的,但与应用程序的其余部分不同,则可以正常工作:
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句