thekguy
thekguy

Reputation: 127

Set the visibility for a process window

To check if a window is visibile i have to use:

[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool IsWindowVisible(IntPtr hWnd);

But how do i change the visiblity? True/False

EDIT:

Hiding works:

            Process P;
            P = Process.GetProcessesByName("javaw")[2];
            ShowWindow(P.MainWindowHandle, 0);

But showing does not:

            Process P;
            P = Process.GetProcessesByName("javaw")[2];
            ShowWindow(P.MainWindowHandle, 5);

EDIT:

            ShowWindow(FindWindow(null, "WINDOWNAME"), 0);

0 invisibvle 5 visible

WORKS

Upvotes: 1

Views: 1252

Answers (1)

Sam
Sam

Reputation: 3480

You can use ShowWindow:

[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool ShowWindow(IntPtr hWnd, ShowWindowCommands nCmdShow);

Upvotes: 3

Related Questions