简体   繁体   中英

Creating a color def file or choosing a theme for Windows Mobile 6.5 Application

I developing an application in C# on Windows mobile 6.5 and .NET 3.5 CF. I'm using multiple forms and would like to have a common color scheme that is easily changed by just changing a color definition file or some simple option in VS 2008.

I've looked around and it doesn't seem to be any clear solution. I've tried digging down to where the colors are defined to see it I could add my own that would be a global variable, or even in the designer files, but there is not mention of color, the only way I can change the color is in the properties window.

A simple way to do this is to use Form inheritance. Create a template form (named "TemplateForm.frm" or whatever), color/style is as you wish, then add one (invisible) instance of each type of control (a Button, a Checkbox, a Label etc.) that you're using on all of your other forms.

Then edit your existing forms so that they inherit from TemplateForm (instead of inheriting from Form ). Add a method to TemplateForm 's Load event that iterates through all the controls on the form (this needs to be recursive, of course) and styles each one (font, colors etc.) to match the corresponding (invisible template) control of that type on the parent form.

An other approach, probably not better, is to modify the system colors in the registry in [HKEY_LOCAL_MACHINE\\System\\GWE] "SysColor". I've used it, but I'm not a fan as it is sometime hard to get a good set of colors that work, and it changes it everywhere in the system. @MusiGenesis appoach affords you finer control.

see Customizing System Colors

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM