正如Delphi文档所说,TCustomControl没有继承的OnFocus事件,所以我需要捕获事件(?)并实现我自己的OnGetFocus / OnLostFocus事件处理程序(?).
当组件获得/失去焦点时,如何捕获事件?解决方法 控件接收或丢失输入焦点时触发的事件是
OnEnter
和 OnExit
,并从作为组件开发人员应覆盖的 DoEnter
和 DoExit
方法触发: type TMyControl = class(TCustomControl) protected procedure DoEnter; overrIDe; procedure DoExit; overrIDe; end;implementation{ TMyControl }procedure TMyControl.DoEnter;begin inherited; // the control received the input focus,so do what you need here; note // that it's recommended to call inherited insIDe this method (which as // described in the reference should only fire the OnEnter event Now)end;procedure TMyControl.DoExit;begin inherited; // the control has lost the input focus,so do what you need here; note // that it's recommended to call inherited insIDe this method (which as // described in the reference should only fire the OnExit event Now)end;总结
以上是内存溢出为你收集整理的捕获/创建TCustomControl Delphi的OnGetFocus / OnLostFocus事件全部内容,希望文章能够帮你解决捕获/创建TCustomControl Delphi的OnGetFocus / OnLostFocus事件所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)