我在我的应用程序中实现了这个chevron tool bar,它的效果非常好;但是,当我点击菜单上的任何项目时,我的应用程序失去了焦点。即使我将鼠标移到窗体的角落,光标也不会更改为调整大小手柄。我需要点击表单或应用程序才能重新获得我不想要做的重点。调用菜单项后调用MainForm.Setfocus没有帮助。我希望将重点放在我的应用程序上,这样我的用户在完成他们需要做的事情之前不需要点击表单。
关于如何重新关注表单和/或应用程序的任何想法?
由于
答案 0 :(得分:-1)
拦截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;