nuberun
asked on
Show window without focus vb.net
Hello all,
I've a notification window like messenger and I need to show it without losing the focus of the current application. How can I do that in vb.net?
What I'm using to show the window is the ShowWindow api.
Thanks in advance for your assistance.
I've a notification window like messenger and I need to show it without losing the focus of the current application. How can I do that in vb.net?
What I'm using to show the window is the ShowWindow api.
Thanks in advance for your assistance.
You can do it WITHOUT BringWindowToFront() by using the SW_SHOWNA flag.
Assuming Form7 was the form you wanted to show without losing focus then you would use code like this:
Private Declare Function ShowWindow Lib "user32" (ByVal handle As IntPtr, ByVal nCmdShow As Integer) As Integer
Private Const SW_SHOWNA = 8
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim f As New Form7
ShowWindow(f.Handle, SW_SHOWNA)
End Sub
Assuming Form7 was the form you wanted to show without losing focus then you would use code like this:
Private Declare Function ShowWindow Lib "user32" (ByVal handle As IntPtr, ByVal nCmdShow As Integer) As Integer
Private Const SW_SHOWNA = 8
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim f As New Form7
ShowWindow(f.Handle, SW_SHOWNA)
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
https://www.experts-exchange.com/questions/10314394/Show-a-window.html?sfQueryTermInfo=1+focu+show+window+without