tags:

views:

290

answers:

4

Hi there,

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

+3  A: 
  • 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.

Craig Peterson
Ok Craig, thanks by explanation to solve my problem, your solution works very well, and thanks to show me the way to write my doubts :-)
Jean Alysson
A: 

Why create a visible form if you don't want to receive focus? If you show a Window on the screen then surely it's focus bait?

David Heffernan
I use the application to display the video on second monitor, instaled in the same computer.
Jean Alysson
A: 

Thanks Craig,

it works, but when I use ALT+TAB and return to my application, the form is focused again.
Are there some way to avoid the focus in any time ?

Thanks
Jean Alysson

Jean Alysson
Jean, I've updated my answer with a couple of more steps that solve the problems you mentioned. FYI, in the future you should use the "Add comment" link rather than using the "Your Answer" edit. That way the original poster gets notification that someone's responded to them.
Craig Peterson
...and in addition: 1) your post will always appear where it belongs (after Craig's answer), which is not the case when you post a separate answer 2) others won't have difficulties to follow this thread because they might assume that this IS an answer which it IS NOT. Note that this is not a forum. The order of answers can change with the number of votes given for each answer.
Smasher
A: 

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.

Daniel Luyo
I use the application to display the video on second monitor, instaled in the same computer.
Jean Alysson