久久中文视频-久久中文网-久久中文亚洲国产-久久中文字幕久久久久-亚洲狠狠成人综合网-亚洲狠狠婷婷综合久久久久

Rss & SiteMap

曙海教育集團(tuán)論壇 http://www.bjzhda.cn

曙海教育集團(tuán)論壇
共1 條記錄, 每頁(yè)顯示 10 條, 頁(yè)簽: [1]
[瀏覽完整版]

標(biāo)題:WinCE應(yīng)用開發(fā)——觸摸屏輸入

1樓
wangxinxin 發(fā)表于:2010-11-26 9:10:54

一,信息

觸摸屏信息同鼠標(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

共1 條記錄, 每頁(yè)顯示 10 條, 頁(yè)簽: [1]

Copyright © 2000 - 2009 曙海教育集團(tuán)
Powered By 曙海教育集團(tuán) Version 2.2
Processed in .01563 s, 2 queries.
主站蜘蛛池模板: 国产午夜伦伦伦午夜伦 | 国产成人在线播放 | 日韩在线视频线视频免费网站 | 99视频九九精品视频在线观看 | 中国一级做a爰片久久毛片 中日韩欧美一级毛片 | 欧美一区二区三区国产精品 | 中文字幕日韩精品中文区 | 久久久久国产精品 | 亚洲一区欧美二区 | 国产三级香港在线观看 | 亚洲精品一区二区 | 无套内谢孕妇毛片免费看 | 日本免费网站视频www区 | 成人看的一级毛片 | 男女精品视频 | 草久久久| 国产成人综合95精品视频免费 | 在线精品免费视频 | 国产精品日韩一区二区三区 | 精品国产品欧美日产在线 | 国产日产欧产精品精品推荐在线 | 亚洲国产系列久久精品99人人 | 久久综合中文字幕一区二区三区 | 欧美一线高本道高清在线 | 国产欧美日韩精品在线 | 中文字幕av一区二区三区 | 欧美另类视频videosbest18 | 99在线观看| 亚洲高清免费在线观看 | 国产亚洲精品激情一区二区三区 | 中国国产一国产一级毛片视频 | 久久精品视频一区二区三区 | 久久久久久久性高清毛片 | 欧毛片 | 97久久精品视频 | 美女被免费网站视频软件 | 欧美一级成人一区二区三区 | av毛片在线看 | 91国内精品久久久久影院优播 | 亚洲一区二区三区在线播放 | 91精品福利手机国产在线 |