Home > Native Code, Windows Mobile > Non-fullscreen form in Windows CE

Non-fullscreen form in Windows CE

By default, all of form you created in .NET CF for Pocket PC and Smartphone are full screen. I don’t know why but this seem there are something related to MS rules when they design the OS. But in some application, I do want to make some non-fullscreen form (I mean the “floating form”) in .NET CF. And I found out it’s pretty simple. In this post, I will show the way to do it in .NET CF. ’cause I only use WinCE API, you can archive this in Native projects in even simpler way…

First of all, we need some Invoke declerations:

[DllImport("coredll.dll", SetLastError = true)]
static extern int GetWindowLong(IntPtr hWnd, int nIndex);

static extern int SetWindowLong(IntPtr hWnd, int nIndex, long dwNewLong);

static extern bool MoveWindow(IntPtr hWnd, int X, int Y, int nWidth, int nHeight, bool bRepaint);

private const long WS_BORDER = 0x00800000;
private const long WS_CAPTION = 0x00C00000;
private const long WS_POPUP = 0x80000000;
private const long WS_SYSMENU = 0x00080000;
private const int GWL_STYLE = (-16);

private const long WS_MINIMIZEBOX = 0x00020000;

You should call this method in the constructor, right after InitializeCompenent():

private void ModifyWindowStyle()
  // modify window style
  long style = GetWindowLong(hWnd, GWL_STYLE);

  style |= (long)(
     & ~WS_CAPTION

  SetWindowLong(hWnd, (int)GWL_STYLE, style);

public Form1()



And we are going to move the window (leftEdge, topEdge, width, height is depend on you):

protected override void OnActivated(EventArgs e)
  Win32.MoveWindow(Handle, leftEdge, topEdge, width, height, true);

This code can be used for both PPC and Smartphone application!

  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: