有关wince下校准界面的修改

来源:互联网 发布:足球队服设计软件 编辑:程序博客网 时间:2024/05/16 03:43
1、在WINCE系统下有默认带有一个校准程序,应用程序可以通过调用API "TouchCalibrate()"来启动校准程序。

如果在你调用"TouchCalibrate"后编译出错或者调用不成功的话可以自己收到加载此函数如:

typedef  BOOL  (WINAPI *_TouchCalibrate)(); HINSTANCE  hinstance = LoadLibrary(_T("coredll.dll")); if  (hinstance == NULL) {   return; } //定义一个函数指针_TouchCalibrate TouchCalibrate = NULL; //获取函数入口地址TouchCalibrate = (_TouchCalibrate)GetProcAddress(hinstance , L"TouchCalibrate"); if (TouchCalibrate == NULL) {   return; } TouchCalibrate (); FreeLibrary(hinstance );

2、修改校准界面
$_WINCEROOT\PUBLIC\COMMON\OAK\DRIVERS\CALIBRUI文件下有calibrui.cpp和calibrui.rc
CalibrUi.cpp主要函数的功能我介绍下。要改它,肯定要先清楚它是做什么的。
TouchCalibrateUI_Initialize做初始化。保存两个全局变量。
TouchCalibrateUI_DrawMainScreen打印校准操作说明信息。
TouchCalibrateUI_HandleUserInputMessage捕捉屏幕事件并做相应操作。
TouchCalibrateUI_DrawConfirmationScreen打印新校准测定之后,提示是否保存。
TouchCalibrateUI_WaitForConfirmation等待用户决定并打印相关信息。
这面五个函数是按被调用启动的先顺序列出来的。
TouchCalibrateUI_DrawMainScreen和TouchCalibrateUI_DrawConfirmationScreen都调用了TouchCalibrateDrawScreenText。


TouchCalibrateDrawScreenText是用来把字符串打到屏幕上。我主要在这个函数中做了相应的更改。如改屏幕背景色,改打印出来的字的颜色等。
好了现在知道了上面的函数的作用,那要修改界面就好办了。
如:在上面加载位图

staticvoidTouchCalibrateDrawScreenText(HDChdc,intcLines,UINTIdStringBase){intVertSpacing = 0;TCHARbuf[C_CALIBRATION_MSG_BUF_CHARS];intcChars;intxText, yText;SIZESize;inti;//Clear the screen.Rectangle(hdc, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN));        //-----加载位图-----lanyzh-Str-----------------------------------------     HDC hdcImage = CreateCompatibleDC(hdc);        HBITMAP hbm = NULL;      hbm = SHLoadDIBitmap(L"\\Nand flash\\APP\\UI\\BT_Background.bmp");    if (hbm != NULL && hdcImage != NULL)      {          BITMAP bm;          SelectObject(hdcImage, hbm);          GetObject(hbm, sizeof(bm), &bm);          StretchBlt(hdc, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN), hdcImage, 0, 0, bm.bmWidth, bm.bmHeight, SRCCOPY);            DeleteObject(hbm);          hbm = NULL;          DeleteObject(hdcImage);           hdcImage = NULL;        }        //-------------------End-----------------------------------------//Display each line of instructions.for ( i = 0; i < cLines; i++ )    {if ( LoadString(s_hinst, IdStringBase+i, buf, C_CALIBRATION_MSG_BUF_CHARS) == 0 )        {continue;        }cChars = _tcslen(buf);//Figure text position.TextSize(hdc, buf, cChars, &Size);xText = GetSystemMetrics(SM_CXSCREEN)/2 - Size.cx/2;//Center horizontally//If first pass through, figure vertical spacing,//else just skip to the next line.if ( VertSpacing == 0 ){VertSpacing = Size.cy + Size.cy/10;yText = VertSpacing;// Skip a line at the top}else{yText += VertSpacing;}//Draw this line.ExtTextOut(  hdc,  xText, yText,  NULL, NULL, //  rectangle options  buf, cChars,  NULL);    }return;}