[英]How to hide caret in Delphi TEdit?
I want to remove the caret from a TEdit control in Delphi. 我想从Delphi中的TEdit控件中删除插入符号。 I have made the component
Enabled := False
but the caret still appears. 我已经使组件
Enabled := False
但是插入符号仍然出现。 My question is how to remove the caret from a disabled TEdit control? 我的问题是如何从禁用的TEdit控件中删除插入符号?
I assume that you mean TEdit
control. 我假设你的意思是
TEdit
控制。
The solution is HideCaret
function, the only problem is where to call it. 解决方案是
HideCaret
功能,唯一的问题是在哪里调用它。 The 2 event handlers below worked fine for me: 下面的2个事件处理程序对我来说很好:
procedure TForm18.Edit1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
HideCaret(Edit1.Handle);
end;
procedure TForm18.Edit1MouseEnter(Sender: TObject);
begin
HideCaret(Edit1.Handle);
end;
Place a TApplicationEvents
control on the form and in the OnIdle
event, hide the caret, as follows. 在表单上放置一个
TApplicationEvents
控件,并在OnIdle
事件中隐藏插入符,如下所示。 Set the event to nil so it only fires once. 将事件设置为nil,因此它只触发一次。
procedure TFormMain.AppEventsIdle(Sender: TObject; var Done: Boolean);
begin
AppEvents.OnIdle := nil;
HideCaret(Memo1.Handle);
end;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.