微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 嵌入式设计 > 定制 Windows CE .NET 用户界面

定制 Windows CE .NET 用户界面

时间:02-24 来源:互联网 点击:

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.

// 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);

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

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top