作者:太阳下的泪
转自:http://blog.sina.com.cn/s/blog_5be1061c0100bgy8.html
MSDN原文参考LINK:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnembedded/html/embedded04022002.asp
Windows CE .NET 提供为你的嵌入式设计定制用户界面的能力。如 POSterminals, 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有专门讲这一功能的,只需要改注册表就可以了。如下:
如果选择了XPSKIN,则在控制面板的"显示"选项中是无法更改一些窗口的颜色的.不过,我们倒是可以通过更改$(_WINCEROOT)\PUBLIC\COMMON\OAK\FILES\common.reg文件中的XP颜色参数来达到更改窗口颜色的目的.
原XP样式的颜色参数如下:
[HKEY_LOCAL_MACHINE\SYSTEM\GWE]
0
1
2
3
4
5
6
7
8
9
10COLOR_ACTIVEBORDER
11 COLOR_INACTIVEBORDER
12COLOR_APPWORKSPACE
13COLOR_HIGHLIGHT
14COLOR_HIGHLIGHTTEXT
15COLOR_BTNFACE
16COLOR_BTNSHADOW
17COLOR_GRAYTEXT
18COLOR_BTNTEXT
19 COLOR_INACTIVECAPTIONTEXT
20COLOR_BTNHIGHLIGHT
21COLOR_3DDKSHADOW
22COLOR_3DLIGHT
23COLOR_INFOTEXT
24COLOR_INFOBK
25COLOR_STATIC
26COLOR_STATICTEXT
27 COLOR_GRADIENTACTIVECAPTION
28 COLOR_GRADIENTINACTIVECAPTION
这下改变的地方很多了吧,哈哈. 下面看第二个例子
改变TOOLBAR等相关图标(Modifying User InterfaceBitmaps)
Another way to get a UI facelift is to alter some of thestandard UI bitmaps.The bitmaps contain the toolbar button imagesused in standard Windows CE .NET applications, such as Microsoft®Windows Explorer. The toolbar bitmaps can be found in the followingfolder: \WINCE400\public\common\OAK\FILES.(这里意思比较简单,就不翻译了)
·
·
·
·
So how about the 'Close' button on an applicationscaption 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 aretwo parts to the Close button. The first is the background bitmap,which can be found inC:\wince400\public\common\OAK\DRIVERS\SKINNABLEUI\GWEXP\GCACHEVIEWXP\RES—thefile is Closebutton.bmp. This contains the button background in up,down, selected, and disabled form. So how does the white "X" getadded to the button?
Right, lets roll up them sleeves and dig into someof the skinnableui source code… Perhaps the first stop on thetour of the code is the initialization function for the XP skincode. The code is wrapped into a class calledCacheView_t.The initialization function is called Init( ). TheCacheView_t::Init( ) function is located inSKINNABLEUI\GWEXP\GCACHEVIEWXP\gcacheviewxp.cpp. Let's take a lookat some of the code. This is where the GDI object cache issetup.
// 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 bitmapresource "GWES_CLOSEBUTTON" and selecting this into a cached devicecontext g_cacheview.hdcCloseButton, so that this is ready to uselater. GWES_CLOSEBUTTON is defined in gcacheviewxp.res asfollows:
GWES_CLOSEBUTTON BITMAP res\\CloseButton.bmp
The bitmap is getting loaded fromSKINABLEUI\GWEXP\GCACHEVIEWXP\RES.
So, we've loaded the background bitmap. We now needto figure out where g_cacheview.hdcCloseButton is getting used.Since the caption bar is part of the non-client area, it's a safebet that we will find the code we're looking for in the followingfolder: SKINNABLEUI\GWEXP\NCLIENTVIEWXP. Let's take a look atnclientviewxp.cpp.
Below is part of the DrawClose( ) function.We can clearly see the call toDrawCaptionButton( ) passingin the cached hdcCloseButton. (I've skipped some lines that aren'tinteresting for this part of the article.) We can then see thecalls to SelectObject_I(hdc, hNewBrush), which selects a whitebrush into the device context. We then call DrawDiagonalLine() twice to place the cross onto the close button. This can, ofcourse, be easily replaced with whatever background bitmap andforeground 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);