Link to home
Start Free TrialLog in
Avatar of nuberun
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.
Avatar of nuberun
nuberun

ASKER

Avatar of Mike Tomlinson
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
ASKER CERTIFIED SOLUTION
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial