Click here to Skip to main content
Click here to Skip to main content

Tagged as

Windows CE custom controls

, 5 Nov 2012
Rate this:
Please Sign up or sign in to vote.
Messagebox, mainmenu and contextmenu controls for Windows CE

Introduction

I have developed a program (c#, .netcf) for some PNA devices shipped with Windows CE 6.0. The text on the mainmenu, contextmenu and messagebox controls were unreadable due to their font size. There is no way to change these control's font and some other major properties. So I decided to write my own classes to get full control over these controls. If you have the same problem feel free to use and/or modify the shared code.

Using the code

The usage of the controls are fairly straightforward. You can see some examples in the sample project.

Custom MessageBox class: Use it as the same way as .NET MessageBox. Custom messagebox has the same constructor with the same parameters as the normal messagebox. So you can use this in your exiting code without any change. The only thing you must to do is place the messagebox class to the same namespace with the code what which will use it. If you want to use it from more different namespaces, you will have to create a messagebox class for each namespaces and from their show() method you can call the custom messagbox class show() method, otherwise the codes exits in the other namespaces will use the system default messagebox class.

MessageBox.Show("This is a custom messagebox","ATTENTION",MessageBoxButtons.AbortRetryIgnore,MessageBoxIcon.Asterisk,MessageBoxDefaultButton.Button1);
 

The newly created messagebox will looks like this:

Context Menu class:
Simply create a new CustomContextMenu instance. You can attach the menu to any type of controls.

CustomContextMenu contextMenu = new CustomContextMenu(this.dataGrid,new Font("Arial",13,FontStyle.Bold));

contextMenu.AddContextMenu("Context menu 1",menu_Click);

contextMenu.AddContextMenu("Context menu 2",menu_Click);

Main Menu class:
Simply create a new CustomMainMenu instance. Add eventhandlers to the menu which has no submenu. Do not forget to create a main menu before you add a submenu to it. (see below)

 
CustomMainMenu mainMenu = new CustomMainMenu(this,new Font("Arial",13,FontStyle.Bold));

mainMenu.AddMainMenu("MainMenu1","",menu_Click);

mainMenu.AddMainMenu("MainMenu2","",menu_Click);

mainMenu.AddMainMenu("MainMenu3","",null);

mainMenu.AddMainMenu("SubMainMenu1","MainMenu3",menu_Click);

mainMenu.AddMainMenu("SubMainMenu2","MainMenu3",menu_Click);

Happy coding!

Points of Interest

C#, MSSQL, Mobile devices

History

...

License

This article, along with any associated source code and files, is licensed under A Public Domain dedication

Share

About the Author

Csasztvan Zsolt
Software Developer
Hungary Hungary
I have developed for more than 6 years. My favorite platforms and languages are C#, Net, MSSQL, SQLCE, windows mobile and ce, ASP.NET.

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Mobile
Web04 | 2.8.140827.1 | Last Updated 5 Nov 2012
Article Copyright 2012 by Csasztvan Zsolt
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid