Click here to Skip to main content
15,885,767 members
Articles / Programming Languages / C#
Article

Show a WinForm in FullScreen mode using C#

Rate me:
Please Sign up or sign in to vote.
4.00/5 (1 vote)
16 Apr 2008CPOL1 min read 88.2K   3.3K   26   17
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.

C#
/// <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

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
Germany Germany
.Net, C#, VB Development

Comments and Discussions

 
SuggestionPer my test, it's better not to hide/unhide the form Pin
Leon Zeng20-Jun-14 21:14
Leon Zeng20-Jun-14 21:14 
GeneralThis is Great!!! Pin
tonymark0915-Jun-10 23:37
tonymark0915-Jun-10 23:37 
GeneralUnable to unzip it! Pin
yudyzhao14-Apr-08 1:02
yudyzhao14-Apr-08 1:02 
GeneralRe: Unable to unzip it! Pin
S.Captive7-Jun-09 7:54
S.Captive7-Jun-09 7:54 
GeneralThanks for you help Pin
JackChen198718-Oct-07 15:44
JackChen198718-Oct-07 15:44 
Generalzip file unreadable Pin
m_s_t22-Sep-07 11:09
m_s_t22-Sep-07 11:09 
GeneralRe: zip file unreadable Pin
Adiphe22-Sep-07 22:03
Adiphe22-Sep-07 22:03 
QuestionDifference? Pin
termi10-Oct-06 4:37
termi10-Oct-06 4:37 
AnswerRe: Difference? Pin
Adiphe10-Oct-06 4:43
Adiphe10-Oct-06 4:43 
GeneralRe: Difference? Pin
termi10-Oct-06 19:47
termi10-Oct-06 19:47 
GeneralRe: Difference? Pin
Adiphe11-Oct-06 0:04
Adiphe11-Oct-06 0:04 
GeneralRe: Difference? Pin
termi11-Oct-06 4:44
termi11-Oct-06 4:44 
AnswerRe: Difference? [modified] Pin
Adiphe11-Oct-06 5:15
Adiphe11-Oct-06 5:15 
GeneralRe: Difference? Pin
Hercules011-Apr-09 0:00
Hercules011-Apr-09 0:00 
GeneralRe: Difference? Pin
Adiphe1-Apr-09 6:47
Adiphe1-Apr-09 6:47 
Generalerrate links Pin
MrBabba10-Oct-06 4:33
MrBabba10-Oct-06 4:33 
GeneralRe: errate links Pin
Adiphe10-Oct-06 5:01
Adiphe10-Oct-06 5:01 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.