Problem in hiding the taskbar using c#

srk1982
srk1982 used Ask the Experts™
on
i am using the below class to hid the task bar. but the problem is, after hiding there is no focus in that place. Its something like blocked. How to overcome this. Thanks.
public class Taskbar
    {
        [DllImport("user32.dll")]
        public static extern int FindWindow(string className, string windowText);
        [DllImport("user32.dll")]
        public static extern int ShowWindow(int hwnd, int command);
 
        public const int SW_HIDE = 0;
        public const int SW_SHOW = 1;
 
        public int _taskbarHandle;
        protected static int Handle
        {
            get
            {
                return FindWindow("Shell_TrayWnd", "");
            }
        }
        public Taskbar()
        {
            _taskbarHandle = FindWindow("Shell_TrayWnd", "");
        }
        public static void Show()
        {
            ShowWindow(Handle, SW_SHOW);
        }
        public static void Hide()
        {
            ShowWindow(Handle, SW_HIDE);
        }
    }

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Author

Commented:
Adding to my question....

I am not using any forms in my application. So i cannot make the form maximize and overcome the taskbar.

It shud be like, after i hide the taskbar, when external applications like notepad
is maximised to whole screen area in monitor.

Thanks.
Senior Consultant - Deloitte
Commented:
[DllImport("user32.dll")]
static extern bool SetForegroundWindow(IntPtr hWnd);



Process[] SameProcesses = Process.GetProcessesByName("notepad.exe");
Process SameProcess = SameProcesses[0];



Simply call it and pass in the window handle of the process you want to bring to front:
SetForegroundWindow(SameProcess.MainWindowHandle);

The .Net process object has a MainWindowHandle property. The process whose window you want to max must have such main window. The MainWindowHandle gives your the native handle of that window, so you can call a Win32 function "ShowWindow" with this handle.

You need declare it like
<DllImport("user32", CharSet=CharSet.Auto)>
Public Declare Function ShowWindow(ByVal hwnd as IntPtr, ByVal nCmdShow as Integer) as Boolean

you need check Win32 document to see how to pass the nCmdShow.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial