KeyMouse demo

This commit is contained in:
2025-11-06 01:06:34 +08:00
parent f945901c18
commit a68366efb2
+50 -1
View File
@@ -198,6 +198,51 @@ static void MainWindow_OnMouseMove(HWND hwnd, int x, int y, UINT keyFlags){
ReleaseDC(hwnd, hdc);
}
static void MainWindow_OnRButtonDown(HWND hwnd, BOOL fDoubleClick, int x, int y, UINT keyFlags){
char s[100];
HDC hdc = GetDC(hwnd);
int size =0;
if(fDoubleClick){
size = snprintf(s, sizeof(s)/sizeof(s[0])
, "WM_RBUTTONDBLCLK ==> Db = %d, x = %d, y = %d, flags = %d "
, fDoubleClick
, x
, y
, keyFlags
);
c_WinGuiUtil_MoveWindowToScreenCenter(hwnd);
}else{
size = snprintf(s, sizeof(s)/sizeof(s[0])
, "WM_RBUTTONDOWN ==> Db = %d, x = %d, y = %d, flags = %d "
, fDoubleClick
, x
, y
, keyFlags
);
}
SetBkColor(hdc, GetSysColor(COLOR_WINDOW));
TextOut(hdc, xVal, yVal + 140, s, size);
ReleaseDC(hwnd, hdc);
}
static void MainWindow_OnRButtonUp(HWND hwnd, int x, int y, UINT keyFlags){
char s[100];
HDC hdc = GetDC(hwnd);
int size =0;
size = snprintf(s, sizeof(s)/sizeof(s[0])
, "WM_RBUTTONUP ==> x = %d, y = %d, flags = %d "
, x
, y
, keyFlags
);
SetBkColor(hdc, GetSysColor(COLOR_WINDOW));
TextOut(hdc, xVal, yVal + 160, s, size);
ReleaseDC(hwnd, hdc);
}
/* -------------------------------------------------------------------------------------------------------------- */
/* */
@@ -214,6 +259,9 @@ c_WinGuiApp_EventBegin(WndProc)
c_WinGuiApp_OnEvent(WM_LBUTTONUP, MainWindow_OnLButtonUp)
c_WinGuiApp_OnEvent(WM_DESTROY, MainWindow_OnDestroy)
c_WinGuiApp_OnEvent(WM_PAINT, MainWindow_OnPaint)
c_WinGuiApp_OnEvent(WM_RBUTTONDBLCLK, MainWindow_OnRButtonDown)
c_WinGuiApp_OnEvent(WM_RBUTTONDOWN, MainWindow_OnRButtonDown)
c_WinGuiApp_OnEvent(WM_RBUTTONUP, MainWindow_OnRButtonUp)
c_WinGuiApp_EventEnd
/* -------------------------------------------------------------------------------------------------------------- */
@@ -241,7 +289,8 @@ static HWND Create(HINSTANCE hInstance, int nCmdShow){
HWND hWindow = CreateWindowEx(0, MAIN_WINDOW_CLASSNAME, MAIN_WINDOW_CLASSNAME,
WS_OVERLAPPEDWINDOW,
800, 600,
CW_USEDEFAULT, CW_USEDEFAULT,
800, 300,
// CW_USEDEFAULT, CW_USEDEFAULT,
NULL, NULL, hInstance, NULL);
if(!hWindow) return NULL;
c_WinGuiApp.hMainWindow = hWindow;