Delphi应用程序失去焦点

| 我在我的应用程序中实现了该V形工具栏,并且效果非常好;但是,当我单击菜单上的任何项目时,我的应用程序都会失去焦点。即使将鼠标移到窗体的一角,光标也不会更改为调整大小手柄。我需要单击表格或应用程序以重新获得我不想做的重点。调用菜单项后调用MainForm.Setfocus没有帮助。我希望将焦点自动放在我的应用程序上,这样我的用户在做他们需要做的事情之前不需要单击表单。 关于如何重新关注表格和/或应用程序的任何想法吗? 谢谢     
已邀请:
拦截WM_KillFocus消息。 伪码 在此终端上没有Delphi,回家后将填写空白。
type
  TForm1 = class(TForm)
  ...
  protected
    procedure WMKillFocus(message: TWM_Killfocus); message WM_KillFocus;
  ...

procedure TForm1.WMKillFocus(message: TWM_Killfocus);
begin
  //do stuff to prevent the focus from shifting.
  //do *NOT* call SetFocus, it confuses Windows/Delphi and leads to suffering
  //Call PostMessage or handle the KillFocus message
  //From MSDN
  //While processing this message, do not make any function calls that display
  //or activate a window. This causes the thread to yield control and can
  //cause the application to stop responding to messages. For more information 
  //see Message Deadlocks. 
  //Also don\'t use SendMessage, PostMessage is OK though.        

  //Suggestion:
  PostMessage(Self.handle, WM_SETFOCUS, 0, 0); 
end;
    

要回复问题请先登录注册