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

以文本方式查看主題

-  曙海教育集團論壇  (http://www.xinguifushi.cn/bbs/index.asp)
--  WinCE應用開發  (http://www.xinguifushi.cn/bbs/list.asp?boardid=35)
----  WinCE應用開發——觸摸屏輸入  (http://www.xinguifushi.cn/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


主站蜘蛛池模板: 色成人亚洲 | 欧美 日韩 国产 在线 | 久久久国产在线 | 亚洲精品线在线观看 | 亚洲精品成人久久 | www午夜| 日韩一区二区在线视频 | 美国一级视频 | 亚洲精品二区中文字幕 | 国产精选91热在线观看 | 欧洲欧美成人免费大片 | 国产精品视_精品国产免费 国产精品视频久 | 日韩欧美一级毛片视频免费 | 美女免费黄网站 | 国产合集91合集久久日 | 国产小呦 | 国产在线一区在线视频 | 最新亚洲一区二区三区四区 | 男人在线网址 | 99精品国产成人一区二区 | 色老久久 | 在线成人a毛片免费播放 | 黄色毛片a| 亚洲日产综合欧美一区二区 | 人与拘一级a毛片 | 欧美一级在线观看视频 | 国产一区二区精品久久凹凸 | 美女一级毛片免费观看 | 欧美亚洲国产激情一区二区 | 九九99re在线视频精品免费 | 国产成人在线观看免费网站 | 精品中文字幕一区在线 | 国产午夜不卡在线观看视频666 | 久久亚洲国产高清 | 亚洲精品高清视频 | 国产人成精品综合欧美成人 | 国产精品久久视频 | 国产欧美va欧美va香蕉在线观 | 精品a在线观看 | 成免费网站 | 国产视频网站在线观看 |