<dfn id="is4kg"></dfn>
  • <ul id="is4kg"></ul>
  • <abbr id="is4kg"></abbr>
  • <ul id="is4kg"></ul>
    <bdo id="is4kg"></bdo>
    以文本方式查看主題

    -  曙海教育集團論壇  (http://www.hufushizhe.com/bbs/index.asp)
    --  WinCE應用開發  (http://www.hufushizhe.com/bbs/list.asp?boardid=35)
    ----  WinCE應用開發——觸摸屏輸入  (http://www.hufushizhe.com/bbs/dispbbs.asp?boardid=35&id=1794)

    --  作者:wangxinxin
    --  發布時間:2010-11-26 9:10:54
    --  WinCE應用開發——觸摸屏輸入

    一,信息

    觸摸屏信息同鼠標信息,不過只有WM_LBUTTONDOWNWM_LBUTTONUP WM_MOUSEMOVE 三種。

    二,捕捉函數

    BOOL GetMouseMovePoints (PPOINT pptBuf, UINT nBufPoints,

    UINT *pnPointsRetrieved);

    三,實例

    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免费视频| 午夜电影在线观看国产1区| 18精品久久久无码午夜福利| 婷婷亚洲综合一区二区| 九九这里只有精品视频| 污污成人一区二区三区四区| 国产乱子伦农村xxxx| 3d动漫精品啪啪一区二区中文| 小莹的性荡生活37章| 久人人爽人人爽人人片AV| 欧美日韩一区二区三区久久| 又色又爽又黄的视频软件app| 香港三级电影在线观看| 国产韩国精品一区二区三区| 中文在线第一页| 日本亚洲色大成网站www久久| 亚洲日韩精品欧美一区二区| 男人j桶进女人p无遮挡在线观看 | 亚州一级毛片在线| 欧美最猛性xxxxx69交| 午夜看黄网站免费| 老太脱裤子小伙bbbaaa| 国产成人精品无码一区二区| 99热国产免费| 天堂资源中文在线| 中文字幕在线一区二区三区| 日本免费一区尤物| 亚洲va在线va天堂va手机| 欧美大香线蕉线伊人久久| 做床爱无遮挡免费视频91极品蜜桃臀在线播放 | 黄页网站在线观看免费| 国内精品久久久久久无码不卡| 中文字幕av一区乱码| 无翼乌口工全彩无遮挡里| 亚洲一区二区三区在线播放| 欧美影院一区二区| 人人妻人人澡人人爽人人dvd| 男性玩尿眼玩法| 四虎永久在线精品视频免费观看| 艹逼视频免费看|