定制WINDOWS CE用户界面
MSDN原文参考LINK:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnembedded/html/embedded04022002.asp
Windows CE .NET 提供为你的嵌入式设计定制用户界面的能力。如 POS terminals, ATM machines, or other 'fixed function' devices。也可以用Internet 浏览器和应用程序.以前版本的WINCE也可以定制用户界面,但带有明显的WINDOWS外观和感觉。现在WINCE 。NET改变了这个。
这里有一些选择,在为一个Windows CE .NET 设备定制界面时:
·
·
·
Microsoft在Windows CE .NET中提供了2种皮肤: Windows 95 外观和Windows XP 外观. 这些分别为通用控件,windows控件,和非客户区提供windows外观。“皮肤”文件在下面文件夹处:
\WINCE420\PUBLIC\COMMON\OAK\DRIVERS\SKINNABLEUI.
在skinnableui 文件夹下提供的代码可以改动(因为是在public树下),可以被你的设备所采用。
l
如何选择我们所需要的界面:
1.
2.
下面是两种界面的一个区别:
下面我们来举几个例子来告诉大家如何做一些界面的定制,有如下几个例子.
·
·
·
·
·
l
这个问题困扰我很久了,在桌面的控制面板可以自己选择,但不知道怎么用代码去实现,后来不小心看到MSDN有专门讲这一功能的,只需要改注册表就可以了。如下:
如果选择了XP SKIN,则在控制面板的"显示"选项中是无法更改一些窗口的颜色的.不过,我们倒是可以通过更改$(_WINCEROOT)\PUBLIC\COMMON\OAK\FILES\common.reg文件中的XP颜色参数来达到更改窗口颜色的目的.
原XP样式的颜色参数如下:
[HKEY_LOCAL_MACHINE\SYSTEM\GWE]
0
1
2
3
4
5
6
7
8
9
10 COLOR_ACTIVEBORDER
11 COLOR_INACTIVEBORDER
12 COLOR_APPWORKSPACE
13 COLOR_HIGHLIGHT
14 COLOR_HIGHLIGHTTEXT
15 COLOR_BTNFACE
16 COLOR_BTNSHADOW
17 COLOR_GRAYTEXT
18 COLOR_BTNTEXT
19 COLOR_INACTIVECAPTIONTEXT
20 COLOR_BTNHIGHLIGHT
21 COLOR_3DDKSHADOW
22 COLOR_3DLIGHT
23 COLOR_INFOTEXT
24 COLOR_INFOBK
25 COLOR_STATIC
26 COLOR_STATICTEXT
27 COLOR_GRADIENTACTIVECAPTION
28 COLOR_GRADIENTINACTIVECAPTION
这下改变的地方很多了吧,哈哈. 下面看第二个例子
改变TOOLBAR等相关图标(Modifying User Interface Bitmaps)
Another way to get a UI facelift is to alter some of the standard UI bitmaps.The bitmaps contain the toolbar button images used in standard Windows CE .NET applications, such as Microsoft® Windows Explorer. The toolbar bitmaps can be found in the following folder: \WINCE400\public\common\OAK\FILES.(这里意思比较简单,就不翻译了)
·
·
·
·
So how about the 'Close' button on an applications caption bar? Can we also modify how this looks? Yes, absolutely. Let's look at how to change the Windows XP look.
This isn't as simple as it first seems. There are two parts to the Close button. The first is the background bitmap, which can be found in C:\wince400\public\common\OAK\DRIVERS\SKINNABLEUI\GWEXP\GCACHEVIEWXP\RES—the file is Closebutton.bmp. This contains the button background in up, down, selected, and disabled form. So how does the white "X" get added to the button?
Right, lets roll up them sleeves and dig into some of the skinnableui source code… Perhaps the first stop on the tour of the code is the initialization function for the XP skin code. The code is wrapped into a class called CacheView_t. The initialization function is called Init( ). The CacheView_t::Init( ) function is located in SKINNABLEUI\GWEXP\GCACHEVIEWXP\gcacheviewxp.cpp. Let's take a look at some of the code. This is where the GDI object cache is setup.
// close button
HBITMAP hbmCloseButton = NULL;
hbmCloseButton = LoadBitmapW_I (hInstance, \
MAKEINTRESOURCE(GWES_CLOSEBUTTON));
ASSERT (hbmCloseButton);
g_cacheview.hdcCloseButton = Gdi::CreateCompatibleDC_I(NULL);
ASSERT(g_cacheview.hdcCloseButton);
Gdi::SelectObject_I(g_cacheview.hdcCloseButton, \
(HGDIOBJ)hbmCloseButton);
Here's what's happening: We're loading a bitmap resource "GWES_CLOSEBUTTON" and selecting this into a cached device context g_cacheview.hdcCloseButton, so that this is ready to use later. GWES_CLOSEBUTTON is defined in gcacheviewxp.res as follows:
GWES_CLOSEBUTTON BITMAP res\\CloseButton.bmp
The bitmap is getting loaded from SKINABLEUI\GWEXP\GCACHEVIEWXP\RES.
So, we've loaded the background bitmap. We now need to figure out where g_cacheview.hdcCloseButton is getting used. Since the caption bar is part of the non-client area, it's a safe bet that we will find the code we're looking for in the following folder: SKINNABLEUI\GWEXP\NCLIENTVIEWXP. Let's take a look at nclientviewxp.cpp.
Below is part of the DrawClose( ) function. We can clearly see the call to DrawCaptionButton( ) passing in the cached hdcCloseButton. (I've skipped some lines that aren't interesting for this part of the article.) We can then see the calls to SelectObject_I(hdc, hNewBrush), which selects a white brush into the device context. We then call DrawDiagonalLine( ) twice to place the cross onto the close button. This can, of course, be easily replaced with whatever background bitmap and foreground text/figure you want.
DrawCaptionButton(hdc, lprc, wControlState, g_cacheview.hdcCloseButton);
// … skip some lines…
hOldBrush = (HBRUSH)Gdi::SelectObject_I(hdc, hNewBrush);
DrawDiagonalLine(hdc, lprc, 1, 2, 0);
DrawDiagonalLine(hdc, lprc, -1, 2, 0);