Shape Focus Prevention

When I launch the VB.NET Winforms application, I do not want it to steal focus from other open applications. FYI, my application is launched from the command line, but this should not change. I saw question 577076 , but that does not work.

What is the best way to do this?

+1
source share
3 answers

Here is what I did to make this work:

I added the following code to the Form1.vb file:

Protected Overloads Overrides ReadOnly Property ShowWithoutActivation() As Boolean  
    Get  
        Return True  
    End Get  
End Property

But there is still no success.

Then I unchecked the Enable Application Platform checkbox on the Application tab of the project properties.

Success!!!

+4
source

ShowWithoutActivation . , , , , . , , . , . 0, 100, . , .

+1

. , :

protected CreateParams CreateParams {
  get {
    CreateParams baseParams = base.CreateParams;
    const int WS_EX_NOACTIVATE = 0x08000000;   
    const int WS_EX_TOOLWINDOW = 0x00000080;    
    baseParams.ExStyle |= (int) (WS_EX_NOACTIVATE | WS_EX_TOOLWINDOW); 
    return baseParams;
  }
}
...

VB.Net, ...

0

Source: https://habr.com/ru/post/1710639/


All Articles