65.9K
CodeProject is changing. Read more.
Home

Show a WinForm in FullScreen mode using C#

starIconstarIconstarIconstarIconemptyStarIcon

4.00/5 (1 vote)

Oct 10, 2006

CPOL

1 min read

viewsIcon

90482

downloadIcon

3260

This article contents source code and demo show how to set your WinForm in Full screen mode

Introduction

I have read some articles about FullScreen mode in WinForm using C#. Per example this one on codeproject with the name "Full Screen mode in C#". This example was not satisfized me. I have develope another one and i thing it can be really better, depend of your project!

Description

The source code contents two zip files, the first one is the source code for the FullScreenMode.dll and the second is a test programm to improve the full screen mode on a WinForm. You have to build the associated FullScreenMode project to get a new FullScreenMode.dll. There is one FullScreenMode.dll in the demo file. In the Demo programm, you can only press F11 to view the Form in Full screen mode. Pressed F11 again will reset to the normal Form.

FullScreenMode

The most important in the HandleTaskBar class is to show or hide the Windows taskbar using WinAPI (user32.dll). The methods showTaskBar() and hideTaskBar() will show or hide the TaskBar depend of the screen mode. The methods FindWinDow() and SetWindowPos() must be defined.

/// <summary>

/// Show the TaskBar.

/// </summary>

public static void showTaskBar()

{

     int hWnd = FindWindow("Shell_TrayWnd", "");

     SetWindowPos(hWnd, 0, 0, 0, 0, 0, SWP_SHOWWINDOW);

}

/// <summary>

/// Hide the TaskBar.

/// </summary>

public static void hideTaskBar()

{

      int hWnd = FindWindow("Shell_TrayWnd", "");

      SetWindowPos(hWnd, 0, 0, 0, 0, 0, SWP_HIDEWINDOW);

}


The source code is very easy to understand.

But any suggestion will be welcome.

Thanks!

Adiphe