以文本方式查看主題

-  曙海教育集團(tuán)論壇  (http://www.scb-ycwb.com/bbs/index.asp)
--  WinCE應(yīng)用開發(fā)  (http://www.scb-ycwb.com/bbs/list.asp?boardid=35)
----  WinCE應(yīng)用開發(fā)——觸摸屏輸入  (http://www.scb-ycwb.com/bbs/dispbbs.asp?boardid=35&id=1794)

--  作者:wangxinxin
--  發(fā)布時(shí)間:2010-11-26 9:10:54
--  WinCE應(yīng)用開發(fā)——觸摸屏輸入

一,信息

觸摸屏信息同鼠標(biāo)信息,不過(guò)只有WM_LBUTTONDOWNWM_LBUTTONUP WM_MOUSEMOVE 三種。

二,捕捉函數(shù)

BOOL GetMouseMovePoints (PPOINT pptBuf, UINT nBufPoints,

UINT *pnPointsRetrieved);

三,實(shí)例

PenTrac.h
#define dim(x) (sizeof(x) / sizeof(x[0]))
struct decodeUINT {                             // Structure associates
    UINT Code;                                  // messages 
                                                // with a function. 
    LRESULT (*Fxn)(HWND, UINT, WPARAM, LPARAM);
}; 
struct decodeCMD {                              // Structure associates
    UINT Code;                                  // menu IDs with a 
    LRESULT (*Fxn)(HWND, WORD, HWND, WORD);     // function.
};
HWND InitInstance (HINSTANCE, LPWSTR, int);
int TermInstance (HINSTANCE, int);
LRESULT CALLBACK MainWndProc (HWND, UINT, WPARAM, LPARAM);
LRESULT DoPaintMain (HWND, UINT, WPARAM, LPARAM);
LRESULT DoMouseMain (HWND, UINT, WPARAM, LPARAM);
LRESULT DoDestroyMain (HWND, UINT, WPARAM, LPARAM);
PenTrac.cpp
#include <windows.h>                 // For all that Windows stuff
#include "pentrac.h"                 // Program-specific stuff
const TCHAR szAppName[] = TEXT ("PenTrac");
HINSTANCE hInst;                     // Program instance handle
const struct decodeUINT MainMessages[] = {
    WM_LBUTTONDOWN, DoMouseMain,
    WM_MOUSEMOVE, DoMouseMain,
    WM_DESTROY, DoDestroyMain,
};
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
                    LPWSTR lpCmdLine, int nCmdShow) {
    MSG msg;
    int rc = 0;
    HWND hwndMain;
    hwndMain = InitInstance (hInstance, lpCmdLine, nCmdShow);
    if (hwndMain == 0)
        return 0x10;
    while (GetMessage (&msg, NULL, 0, 0)) {
        TranslateMessage (&msg);
        DispatchMessage (&msg);
    }
    return TermInstance (hInstance, msg.wParam);
}
HWND InitInstance (HINSTANCE hInstance, LPWSTR lpCmdLine, int nCmdShow) {
    WNDCLASS wc;
    HWND hWnd;
#if defined(WIN32_PLATFORM_PSPC)
    hWnd = FindWindow (szAppName, NULL);
    if (hWnd) {
        SetForegroundWindow ((HWND)(((DWORD)hWnd) | 0x01));    
        return 0;
    }
#endif
    hInst = hInstance;
    wc.style = 0;                             // Window style
    wc.lpfnWndProc = MainWndProc;             // Callback function
    wc.cbClsExtra = 0;                        // Extra class data
    wc.cbWndExtra = 0;                        // Extra window data
    wc.hInstance = hInstance;                 // Owner handle
    wc.hIcon = NULL,                          // Application icon
    wc.hCursor = LoadCursor (NULL, IDC_ARROW);// Default cursor
    wc.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH);
    wc.lpszMenuName =  NULL;                  // Menu name
    wc.lpszClassName = szAppName;             // Window class name
    if (RegisterClass (&wc) == 0) return 0;
    hWnd = CreateWindowEx (WS_EX_NODRAG, szAppName, TEXT ("PenTrac"),
                         WS_VISIBLE | WS_CAPTION | WS_SYSMENU,
                         CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, 
                         CW_USEDEFAULT, NULL, NULL, hInstance, NULL);
    if (!IsWindow (hWnd)) return 0;
    ShowWindow (hWnd, nCmdShow);
    UpdateWindow (hWnd);
    return hWnd;
}
int TermInstance (HINSTANCE hInstance, int nDefRC) {
    return nDefRC;
}
LRESULT CALLBACK MainWndProc (HWND hWnd, UINT wMsg, WPARAM wParam,
                              LPARAM lParam) {
    INT i;
    for (i = 0; i < dim(MainMessages); i++) {
        if (wMsg == MainMessages[i].Code)
            return (*MainMessages[i].Fxn)(hWnd, wMsg, wParam, lParam);
    }
    return DefWindowProc (hWnd, wMsg, wParam, lParam);
}
LRESULT DoMouseMain (HWND hWnd, UINT wMsg, WPARAM wParam, 
                     LPARAM lParam) {
    POINT pt[64];
    POINT ptM;
    UINT i, uPoints = 0;
    HDC hdc;
    ptM.x = LOWORD (lParam);
    ptM.y = HIWORD (lParam);
    hdc = GetDC (hWnd);
    if (wMsg == WM_MOUSEMOVE) {
        if (wParam & MK_SHIFT) 
            GetMouseMovePoints (pt, 64, &uPoints);
        for (i = 0; i < uPoints; i++) {
            pt[i].x /= 4;  // Convert move pts to screen coords
            pt[i].y /= 4;
            MapWindowPoints (HWND_DESKTOP, hWnd, &pt[i], 1);
            SetPixel (hdc, pt[i].x,   pt[i].y, RGB (255, 0, 0));
            SetPixel (hdc, pt[i].x+1, pt[i].y, RGB (255, 0, 0));
            SetPixel (hdc, pt[i].x,   pt[i].y+1, RGB (255, 0, 0));
            SetPixel (hdc, pt[i].x+1, pt[i].y+1, RGB (255, 0, 0));
        }
    }
    SetPixel (hdc, ptM.x, ptM.y, RGB (0, 0, 0));
    SetPixel (hdc, ptM.x+1, ptM.y, RGB (0, 0, 0));
    SetPixel (hdc, ptM.x, ptM.y+1, RGB (0, 0, 0));
    SetPixel (hdc, ptM.x+1, ptM.y+1, RGB (0, 0, 0));
    ReleaseDC (hWnd, hdc);
    Sleep(25);
    return 0;
}
LRESULT DoDestroyMain (HWND hWnd, UINT wMsg, WPARAM wParam,
                       LPARAM lParam) {
    PostQuitMessage (0);
    return 0;
}

clip_image001


主站蜘蛛池模板: 一级女人18毛片免费| 亚洲精品福利网站| 100部毛片免费全部播放完整| 日本三区精品三级在线电影| 亚洲色大成网站www永久男同| 野花影院在线直播视频| 天堂在线中文在线| 亚州av综合色区无码一区| 精品欧洲AV无码一区二区男男 | 日韩国产第一页| 免费的三级毛片| 黄色软件网站大全| 在线观看精品视频一区二区三区 | 欧美成人精品一区二区| 国产一二三区视频| 18禁美女裸体免费网站| 成年人性生活免费视频| 亚洲国产成人久久综合一| 精品国产午夜肉伦伦影院| 国产精品久久久久久搜索| 两个人看的www在线| 欧美性大战久久久久久久| 又大又硬又爽又深免费看| 亚洲精品亚洲人成在线播放| 挺进白嫩老师下面视频| 亚洲国产精品成人综合久久久 | 女人张腿让男桶免费视频网站| 亚洲伦理一二三四| 精品一区二区三区无码视频| 国产成人精品一区二区三区无码| AV无码久久久久久不卡网站| 日本大片免a费观看视频| 亚洲春色第一页| 精品国偷自产在线视频| 国产成人免费网站| 91欧美在线视频| 性XXXXBBBBXXXXX国产| 久久精品人人爽人人爽| 欧美日韩视频一区三区二区| 免费黄色一级电影| 边做饭边被躁欧美三级|