定制 Windows CE .NET 用户界面
ization 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. Here's what's happening: We're loading a bitmap resource "GWES_CLOSEBUTTON" and selecting this into a cached device context The bitmap is getting loaded from SKINABLEUI\GWEXP\GCACHEVIEWXP\RES. So, we've loaded the background bitmap. We now need to figure out where 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. Modifying the Appearance of Windows CE .NET Controls Ok, so we've looked at changing colors and replacing some of the standard bitmaps. These are quick and effective ways of changing the appearance of a device. Now comes the interesting bit: altering the drawing code for some of the standard windows and controls. Here's a list of the items within Windows CE .NET that support skinning: Window Controls · Scroll bar · Button—radio, check, push · Combo box (edit and list) · List box · Static controls · Group box Non-Client Area · Caption bar/window border Common Controls · Command band/command bar · Header control · Trackbar (slider) · Progress bar Skinning of the above items requires modification to source code (and in some cases, modifying bitmaps). We have two options for creating a new skin for Windows CE .NET. The first option is to make a copy of the contents of either C:\wince400\public\common\OAK\DRIVERS\SKINNABLEUI (GWE COMMCTRL) or (GWEXP COMMCTRLXP), and create a new skin project folder, perhaps called MYGWE and MYCOMMCTRL. We will also need to modify the DIRS file in C:\wince400\public\common\OAK\DRIVERS\SKINNABLEUI to include my new project files into the build. Then we need to replace the standard operating system build components with my new components. This is achieved through setting the SYSGEN_REPLACESKIN=1 environment variable (using Platform/Settings/Environment). Lets examine the use of these environment variables. Here's a section of cesysgen.bat (part of the build system). We can see the first line checks for SYSGEN_REPLACESKIN. If this is set, t// 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);
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
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.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);
嵌入式新闻 嵌入式资料 嵌入式培训 嵌入式linux 嵌入式系统 嵌入式开发 嵌入式 相关文章:
- 煤矿井下综合自动化系统中的应用(04-06)
- 软件Overlay:程序编写与调试(01-20)
- USB数据通信接□模块的程序设计(10-17)
- 东江产业园:力争2017年产值达千亿(09-30)
- 硅谷数模的SlimPort扩大了Nexus7的显示屏选择(08-01)
- Lonworks控制网络技术在城市排水泵站自动化中的应用(06-06)