开发者

How to avoid the focus on Delphi application?

开发者 https://www.devze.com 2022-12-22 21:36 出处:网络
I need develop an application (Delphi) that never receive the focus, I use the DLL to display the video on second monitor (I found in Torrys Delphi - Dr.SAGURA Media Player v.1.0) that receive the foc

I need develop an application (Delphi) that never receive the focus, I use the DLL to display the video on second monitor (I found in Torrys Delphi - Dr.SAGURA Media Player v.1.0) that receive the focus every time play the video, how avoid this ?

I try :

procedure TForm.WMActivate(var Msg: TWMActivate);  
begin  
  WA_ACTIVE :
  begin  
    Msg.Result := 0;// cancel focus  
  end; 开发者_如何转开发 
end;

Unsuccessful !

Thanks Jean Alysson


  • In your project DPR set Application.MainFormOnTaskBar := False.
  • Override the form's OnShow and OnActivate events and add this to both of them: ShowWindow(Application.Handle, SW_HIDE);
  • Override your form's CreateParams procedure and add WS_EX_NOACTIVATE to Params.ExStyle.

The first two items hide the application from the taskbar and the Alt+Tab list and the last keeps it from gaining focus when it's shown and when clicking on it.


What's the intention behind not be focusable? You want to avoid the user from closing/minimize/maximize the window? Maybe your need can be acomplished understanding the real problem.

Maybe having a sevice instead of a regular application can make the trick.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号