Click here to Skip to main content
15,893,508 members
Articles / Mobile Apps / Windows Mobile

Full screen feature in .NET Compact Framework

Rate me:
Please Sign up or sign in to vote.
4.00/5 (8 votes)
14 Mar 2005CPOL 133.2K   879   57   26
Enable full screen mode in .NET compact framework applications.

Introduction

This was the conversion from my previous posted topic Having full screen without accessing the SHFullScreen API. Basically, it remain accessing the same set of native API by means of p/invoke (Platform Invoke).

  • FindWindow
  • MoveWindow
  • GetWindowRect
  • SystemParametersInfo

Using the code

In this conversion, I moved the InitFullScreen and DoFullScreen function into a new class FSEngine. Therefore, all you need to do are the below three steps, then you will be ready to ROCK! :p

First, refer the FSEngine in your project.

VB.NET
Private fse As FSEngine

Second, instantiate and initialize the FSEngine class.

VB.NET
' INSTANTIATE THE FSEngine
fse = New FSEngine
' INITIALIZE THE fse
fse.InitFullScreen()

Third, switch between full screen and normal mode.

VB.NET
' SET FULL SCREEN MODE
If fse.DoFullScreen(True) = 0 Then
    ' RESIZE YOUR MAIN WINDOW
End If

' RESTORE FROM FULL SCREEN MODE
If fse.DoFullScreen(False) = 0 Then
    ' RESIZE YOUR MAIN WINDOW
End If

Please refer to previous topic on Full screen for more information.

License

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


Written By
Software Developer
Australia Australia
Passion to be a software architect and solution researcher in enterprise solutions by simplify and unify the existing complex manual paper works into an automated environment friendly, comprehensive and dynamic workflow process system.

Comments and Discussions

 
GeneralMy vote of 4 Pin
b0bi25-Jul-11 1:06
b0bi25-Jul-11 1:06 
GeneralThanks Pin
bigbro_198521-Mar-10 11:07
professionalbigbro_198521-Mar-10 11:07 
GeneralThanks again Pin
adrienf_6912-Nov-09 5:05
adrienf_6912-Nov-09 5:05 
GeneralThanks Pin
minity31-Jul-08 11:17
minity31-Jul-08 11:17 
GeneralAn other way to full screen Pin
Andy Zhang17-Oct-07 20:25
Andy Zhang17-Oct-07 20:25 
GeneralRe: An other way to full screen Pin
[ .:: masterik ::. ]6-Dec-07 10:06
[ .:: masterik ::. ]6-Dec-07 10:06 
GeneralEasy way to full screen in C# Pin
omanni29-Aug-07 4:12
omanni29-Aug-07 4:12 
GeneralFSEngine remains active Pin
CHP791323-Feb-07 4:07
CHP791323-Feb-07 4:07 
Generalthe code in C# Pin
alex_boyer9-Feb-06 23:43
alex_boyer9-Feb-06 23:43 
GeneralRe: the code in C# Pin
CT CHANG13-Feb-06 15:12
CT CHANG13-Feb-06 15:12 
GeneralRe: the code in C# Pin
danyoh13-Dec-06 19:02
danyoh13-Dec-06 19:02 
GeneralRe: the code in C# Pin
ram krishna pattnayak25-Mar-08 22:23
ram krishna pattnayak25-Mar-08 22:23 
Thanks alex_boyer for the nice code in C#
I follow your code and do some changes in my requirement i want hide the sip key icon and start button on form load in C# ,my application is working on button click but it not work in Form load ,please help me immediately.I send my code please refer it and give me some suggestion.

using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
namespace SIPkey
{
class FSEngine
{

private const int SPI_SETWORKAREA = 47;

private const int SPI_GETWORKAREA = 48;

private const int SPIF_UPDATEINIFILE = 0x01;

private IntPtr hWndInputPanel;

private IntPtr hWndSipButton;

private IntPtr hWndTaskBar;

private RECT rtDesktop;

private RECT rtNewDesktop;

private RECT rtInputPanel;

private RECT rtSipButton;

private RECT rtTaskBar;

[DllImport("coredll.dll")]
extern private static IntPtr FindWindowW(string lpClassName, string lpWindowName);

[DllImport("coredll.dll")]
extern private static int MoveWindow(IntPtr hWnd, int X, int Y, int nWidth, int nHeight, int bRepaint);

[DllImport("coredll.dll")]
extern private static int SetRect(ref RECT lprc, int xLeft, int yTop, int xRight, int yBottom);

[DllImport("coredll.dll")]
extern public static int GetWindowRect(IntPtr hWnd, ref RECT lpRect);

[DllImport("coredll.dll")]
extern private static int SystemParametersInfo(int uiAction, int uiParam, ref RECT pvParam, int fWinIni);

public int InitFullScreen()
{
// // Declare & Instatiate local variable
int Result = 0;
try
{
if ((SystemParametersInfo(SPI_GETWORKAREA, 0, ref rtDesktop, 0) == 1))
{
// // Successful obtain the system working area (Desktop)
SetRect(ref rtNewDesktop, 0, 0, 240, 320);
}
// // Find the Input panel window handle
hWndInputPanel = FindWindowW("SipWndClass", null);
// // Checking...
if ((hWndInputPanel.ToInt64() != 0))
{
// // Get the original Input panel window size
GetWindowRect(hWndInputPanel, ref rtInputPanel);
}
// // Find the SIP Button window handle
hWndSipButton = FindWindowW("MS_SIPBUTTON", null);
// // Checking...
if ((hWndSipButton.ToInt64() != 0))
{
// // Get the original Input panel window size
GetWindowRect(hWndSipButton, ref rtSipButton);
}
// // Find the Taskbar window handle
hWndTaskBar = FindWindowW("HHTaskBar", null);
// // Checking...
if ((hWndTaskBar.ToInt64() != 0))
{
// // Get the original Input panel window size
GetWindowRect(hWndTaskBar, ref rtTaskBar);
}
}
catch (Exception ex)
{
// // PUT YOUR ERROR LOG CODING HERE
// // Set return value
Result = 1;
}
// // Return result code
return Result;
}

public int DoFullScreen(bool mode)
{
// // Declare & Instatiate local variable
int Result = 0;
try
{
if ((mode == true))
{
// // Update window working area size
SystemParametersInfo(SPI_SETWORKAREA, 0, ref rtNewDesktop, SPIF_UPDATEINIFILE);
if ((hWndInputPanel.ToInt64() != 0))
{
// // Reposition the input panel
//MoveWindow(hWndInputPanel, 0, (rtNewDesktop.bottom
//- (rtInputPanel.bottom - rtInputPanel.top)), (rtInputPanel.right - rtInputPanel.left), (rtInputPanel.bottom - rtInputPanel.top), 0);
}
if ((hWndSipButton.ToInt64() != 0))
{
// // Hide the SIP button
MoveWindow(hWndSipButton, 0, rtNewDesktop.bottom, (rtSipButton.right - rtSipButton.left), (rtSipButton.bottom - rtSipButton.top), 0);
}
}
else
{
// // Update window working area size
SystemParametersInfo(SPI_SETWORKAREA, 0, ref rtDesktop, SPIF_UPDATEINIFILE);

// // Restore the input panel
if ((hWndInputPanel.ToInt64() != 0))
{
//MoveWindow(hWndInputPanel, rtInputPanel.left, (rtDesktop.bottom - ((rtInputPanel.bottom - rtInputPanel.top)- (rtTaskBar.bottom - rtTaskBar.top))), (rtInputPanel.right - rtInputPanel.left), (rtInputPanel.bottom - rtInputPanel.top), 0);
//MoveWindow(hWndInputPanel, 0,26,220,254, 0);
}
if ((hWndSipButton.ToInt64() != 0))
{
// // Restore the SIP button
MoveWindow(hWndSipButton, rtSipButton.left, rtSipButton.top, (rtSipButton.right - rtSipButton.left), (rtSipButton.bottom - rtSipButton.top), 0);
// MoveWindow(hWndInputPanel, 0, 26, 220, 254, 0);
}
}
}
catch (Exception ex)
{
// // PUT YOUR ERROR LOG CODING HERE
// // Set return value
Result = 1;
}
// // Return result code
return Result;
}

[StructLayout(LayoutKind.Sequential)]
public struct RECT
{

public int left;

public int top;

public int right;

public int bottom;
}

}
}
/////////////////////
I Call the key board hiding code in button click
private void button1_Click(object sender, EventArgs e)
{
if (fs.DoFullScreen(true) == 0)
{
if (inputPanel1.Enabled == true)
{
inputPanel1.Enabled = false;
}

fs.DoFullScreen(true);
}

}
For restoring the keyboard
private void button2_Click(object sender, EventArgs e)
{
// fs.InitFullScreen();
fs.DoFullScreen(false);

}
but i want the thing in form load but in form load when i call these it not working please help me.

Ram Krishna Pattnayak
Software Developer(SDS)
Sun-Dew Solutions Pvt.Ltd
www.sundewsolutions.com
kolkata

QuestionRe: the code in C# Pin
alex_boyer25-Mar-08 22:48
alex_boyer25-Mar-08 22:48 
GeneralRe: the code in C# Pin
ram krishna pattnayak26-Mar-08 0:32
ram krishna pattnayak26-Mar-08 0:32 
GeneralRe: the code in C# Pin
alex_boyer26-Mar-08 7:09
alex_boyer26-Mar-08 7:09 
GeneralRe: the code in C# Pin
zkshadow7-Jul-09 16:33
zkshadow7-Jul-09 16:33 
QuestionFSEngine in C# Pin
jamo778-Jan-06 21:28
jamo778-Jan-06 21:28 
GeneralFrom microsoft docs... save you some time Pin
Jason Allen Smith21-Jun-05 10:40
sussJason Allen Smith21-Jun-05 10:40 
GeneralRe: From microsoft docs... save you some time Pin
Anonymous12-Jul-05 7:29
Anonymous12-Jul-05 7:29 
GeneralThis does not work all time Pin
xbertx123-May-06 10:57
xbertx123-May-06 10:57 
GeneralRe: This does not work all time Pin
c01mr18-Jan-07 4:54
c01mr18-Jan-07 4:54 
GeneralRe: This does not work all time Pin
entraped.isoLated31-Jul-07 0:32
entraped.isoLated31-Jul-07 0:32 
GeneralGood job. Pin
SpeedySpeedy22-Mar-05 21:29
SpeedySpeedy22-Mar-05 21:29 
GeneralRe: Good job. Pin
c01mr18-Jan-07 4:53
c01mr18-Jan-07 4:53 

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.