/********************************************************************* * * _RADIO_Callback */ static void _RADIO_Callback (WM_MESSAGE* pMsg) { RADIO_Handle hObj; RADIO_Obj* pObj; hObj = pMsg->hWin; pObj = RADIO_H2P(hObj); /* Let widget handle the standard messages */ if (WIDGET_HandleActive(hObj, pMsg) == 0) { return; } switch (pMsg->MsgId) { case WM_PAINT: GUI_DEBUG_LOG("RADIO: _Callback(WM_PAINT)\n"); _OnPaint(hObj, pObj); return; case WM_GET_RADIOGROUP: pMsg->Data.v = pObj->GroupId; return; case WM_TOUCH: _OnTouch(hObj, pObj, pMsg); break; case WM_KEY: _OnKey(hObj, pMsg); break; case WM_DELETE: GUI_ARRAY_Delete(&pObj->TextArray); break; } WM_DefaultProc(pMsg); }
LRESULT CALLBACK CScrollBarWindow::_WindowProcCallback(_In_ HWND wndHandle, _In_ UINT uMsg, _In_ WPARAM wParam, _In_ LPARAM lParam) { switch (uMsg) { case WM_PAINT: { HDC dcHandle = nullptr; PAINTSTRUCT ps; dcHandle = BeginPaint(wndHandle, &ps); // paint itself at first _OnPaint(dcHandle, &ps); // paint all children _pBtnUp->_OnPaint(dcHandle, &ps); _pBtnDn->_OnPaint(dcHandle, &ps); EndPaint(wndHandle, &ps); } return 0; } return DefWindowProc(wndHandle, uMsg, wParam, lParam); }
/********************************************************************* * * cbWindow */ static void _cbWindow(WM_MESSAGE * pMsg) { WM_HWIN hWin = pMsg->hWin; switch (pMsg->MsgId) { case WM_PAINT: _OnPaint(); break; } WM_DefaultProc(pMsg); }
/** * @brief callback for background button * @param pMsg: pointer to data structure of type WM_MESSAGE * @retval None */ static void _cbButton(WM_MESSAGE * pMsg) { switch (pMsg->MsgId) { case WM_PAINT: _OnPaint(pMsg->hWin); break; default: /* The original callback */ BUTTON_Callback(pMsg); break; } }
/********************************************************************* * * _cbCallback */ static void _cbCallback(WM_MESSAGE * pMsg) { int i; int NCode, Id; WM_HWIN hDlg, hItem; hDlg = pMsg->hWin; switch (pMsg->MsgId) { case WM_PAINT: _OnPaint(); return; case WM_INIT_DIALOG: for (i = 0; i < 3; i++) { hItem = WM_GetDialogItem(hDlg, GUI_ID_SLIDER0 + i); SLIDER_SetRange(hItem, 0, 255); SLIDER_SetValue(hItem, _aColorSep[i]); /* Init EDIT-widgets */ hItem = WM_GetDialogItem(hDlg, GUI_ID_EDIT0 + i); EDIT_SetDecMode(hItem, _aColorSep[i], 0, 255, 0, 0); } break; case WM_KEY: switch (((WM_KEY_INFO*)(pMsg->Data.p))->Key) { case GUI_KEY_ESCAPE: ; break; case GUI_KEY_ENTER: GUI_EndDialog(hDlg, 0); break; } break; case WM_NOTIFY_PARENT: Id = WM_GetId(pMsg->hWinSrc); /* Id of widget */ NCode = pMsg->Data.v; /* Notification code */ switch (NCode) { case WM_NOTIFICATION_RELEASED: /* React only if released */ if (Id == GUI_ID_OK) { /* OK Button */ GUI_EndDialog(hDlg, 0); } if (Id == GUI_ID_CANCEL) { /* Cancel Button */ GUI_EndDialog(hDlg, 1); } break; case WM_NOTIFICATION_VALUE_CHANGED: /* Value has changed */ _OnValueChanged(hDlg, Id); break; } break; default: WM_DefaultProc(pMsg); } }
/********************************************************************* * * _cbButton * * Purpose: * 1. Calls the owner draw function if the WM_PAINT message has been send * 2. Calls the original callback for further messages * 3. After processing the messages the function evaluates the pressed-state * if the WM_TOUCH message has been send */ static void _cbButton(WM_MESSAGE *pMsg) { switch (pMsg->MsgId) { case WM_PAINT: _OnPaint(pMsg->hWin); break; default: _pcbCallback(pMsg); /* The original callback */ break; } if (pMsg->MsgId == WM_TOUCH) { if (BUTTON_IsPressed(pMsg->hWin)) { if (!_Pressed) { _Pressed = 1; } } else { _Pressed = 0; } } }
LRESULT CALLBACK CCandidateWindow::_WindowProcCallback(_In_ HWND wndHandle, UINT uMsg, _In_ WPARAM wParam, _In_ LPARAM lParam) { switch (uMsg) { case WM_CREATE: { HDC dcHandle = nullptr; dcHandle = GetDC(wndHandle); if (dcHandle) { HFONT hFontOld = (HFONT)SelectObject(dcHandle, Global::defaultlFontHandle); GetTextMetrics(dcHandle, &_TextMetric); _cxTitle = _TextMetric.tmMaxCharWidth * _wndWidth; SelectObject(dcHandle, hFontOld); ReleaseDC(wndHandle, dcHandle); } } return 0; case WM_DESTROY: _DeleteShadowWnd(); return 0; case WM_WINDOWPOSCHANGED: { WINDOWPOS* pWndPos = (WINDOWPOS*)lParam; // move shadow if (_pShadowWnd) { _pShadowWnd->_OnOwnerWndMoved((pWndPos->flags & SWP_NOSIZE) == 0); } // move v-scroll if (_pVScrollBarWnd) { _pVScrollBarWnd->_OnOwnerWndMoved((pWndPos->flags & SWP_NOSIZE) == 0); } _FireMessageToLightDismiss(wndHandle, pWndPos); } break; case WM_WINDOWPOSCHANGING: { WINDOWPOS* pWndPos = (WINDOWPOS*)lParam; // show/hide shadow if (_pShadowWnd) { if ((pWndPos->flags & SWP_HIDEWINDOW) != 0) { _pShadowWnd->_Show(FALSE); } // don't go behaind of shadow if (((pWndPos->flags & SWP_NOZORDER) == 0) && (pWndPos->hwndInsertAfter == _pShadowWnd->_GetWnd())) { pWndPos->flags |= SWP_NOZORDER; } _pShadowWnd->_OnOwnerWndMoved((pWndPos->flags & SWP_NOSIZE) == 0); } // show/hide v-scroll if (_pVScrollBarWnd) { if ((pWndPos->flags & SWP_HIDEWINDOW) != 0) { _pVScrollBarWnd->_Show(FALSE); } _pVScrollBarWnd->_OnOwnerWndMoved((pWndPos->flags & SWP_NOSIZE) == 0); } } break; case WM_SHOWWINDOW: // show/hide shadow if (_pShadowWnd) { _pShadowWnd->_Show((BOOL)wParam); } // show/hide v-scroll if (_pVScrollBarWnd) { _pVScrollBarWnd->_Show((BOOL)wParam); } break; case WM_PAINT: { HDC dcHandle = nullptr; PAINTSTRUCT ps; dcHandle = BeginPaint(wndHandle, &ps); _OnPaint(dcHandle, &ps); _DrawBorder(wndHandle, CANDWND_BORDER_WIDTH*2); EndPaint(wndHandle, &ps); } return 0; case WM_SETCURSOR: { POINT cursorPoint; GetCursorPos(&cursorPoint); MapWindowPoints(NULL, wndHandle, &cursorPoint, 1); // handle mouse message _HandleMouseMsg(HIWORD(lParam), cursorPoint); } return 1; case WM_MOUSEMOVE: case WM_LBUTTONDOWN: case WM_MBUTTONDOWN: case WM_RBUTTONDOWN: case WM_LBUTTONUP: case WM_MBUTTONUP: case WM_RBUTTONUP: { POINT point; POINTSTOPOINT(point, MAKEPOINTS(lParam)); // handle mouse message _HandleMouseMsg(uMsg, point); } // we processes this message, it should return zero. return 0; case WM_MOUSEACTIVATE: { WORD mouseEvent = HIWORD(lParam); if (mouseEvent == WM_LBUTTONDOWN || mouseEvent == WM_RBUTTONDOWN || mouseEvent == WM_MBUTTONDOWN) { return MA_NOACTIVATE; } } break; case WM_POINTERACTIVATE: return PA_NOACTIVATE; case WM_VSCROLL: _OnVScroll(LOWORD(wParam), HIWORD(wParam)); return 0; } return DefWindowProc(wndHandle, uMsg, wParam, lParam); }
/********************************************************************* * * _cbCallback */ static void _cbCallback(WM_MESSAGE * pMsg) { WM_KEY_INFO * pKeyInfo; WM_HWIN hItem; WM_HWIN hDlg; int NCode; int Id; int i; hDlg = pMsg->hWin; switch (pMsg->MsgId) { case WM_PAINT: _OnPaint(); return; case WM_INIT_DIALOG: // // Init SLIDER and EDIT widgets // for (i = 0; i < 3; i++) { hItem = WM_GetDialogItem(hDlg, GUI_ID_SLIDER0 + i); SLIDER_SetRange(hItem, 0, 255); SLIDER_SetValue(hItem, _aColorSep[i]); hItem = WM_GetDialogItem(hDlg, GUI_ID_EDIT0 + i); EDIT_SetDecMode(hItem, _aColorSep[i], 0, 255, 0, 0); } // // Init CHECKBOX // hItem = WM_GetDialogItem(hDlg, GUI_ID_CHECK0); CHECKBOX_SetText(hItem, "Auto"); CHECKBOX_SetState(hItem, _Auto); break; case WM_KEY: pKeyInfo = (WM_KEY_INFO *)(pMsg->Data.p); switch (pKeyInfo->Key) { case GUI_KEY_ESCAPE: break; case GUI_KEY_ENTER: GUI_EndDialog(hDlg, 0); break; } break; case WM_NOTIFY_PARENT: Id = WM_GetId(pMsg->hWinSrc); NCode = pMsg->Data.v; switch (NCode) { case WM_NOTIFICATION_RELEASED: if (Id == GUI_ID_OK) { GUI_EndDialog(hDlg, 0); } if (Id == GUI_ID_CANCEL) { GUI_EndDialog(hDlg, 1); } break; case WM_NOTIFICATION_VALUE_CHANGED: switch (Id) { case GUI_ID_CHECK0: hItem = WM_GetDialogItem(hDlg, Id); _Auto = CHECKBOX_GetState(hItem); break; default: _OnValueChanged(hDlg, Id); break; } break; } break; default: WM_DefaultProc(pMsg); } }
/********************************************************************* * * _LISTBOX_Callback */ static void _LISTBOX_Callback(WM_MESSAGE*pMsg) { LISTBOX_Handle hObj = pMsg->hWin; LISTBOX_Obj* pObj = LISTBOX_H2P(hObj); WM_SCROLL_STATE ScrollState; /* Let widget handle the standard messages */ if (WIDGET_HandleActive(hObj, pMsg) == 0) { /* Owner needs to be informed about focus change */ if (pMsg->MsgId == WM_SET_FOCUS) { if (pMsg->Data.v == 0) { /* Lost focus ? */ _NotifyOwner(hObj, LISTBOX_NOTIFICATION_LOST_FOCUS); } } return; } switch (pMsg->MsgId) { case WM_NOTIFY_PARENT: switch (pMsg->Data.v) { case WM_NOTIFICATION_VALUE_CHANGED: if (pMsg->hWinSrc == WM_GetScrollbarV(hObj)) { WM_GetScrollState(pMsg->hWinSrc, &ScrollState); pObj->ScrollStateV.v = ScrollState.v; LISTBOX__InvalidateInsideArea(hObj); _NotifyOwner(hObj, WM_NOTIFICATION_SCROLL_CHANGED); } else if (pMsg->hWinSrc == WM_GetScrollbarH(hObj)) { WM_GetScrollState(pMsg->hWinSrc, &ScrollState); pObj->ScrollStateH.v = ScrollState.v; LISTBOX__InvalidateInsideArea(hObj); _NotifyOwner(hObj, WM_NOTIFICATION_SCROLL_CHANGED); } break; case WM_NOTIFICATION_SCROLLBAR_ADDED: LISTBOX_UpdateScrollers(hObj); break; } break; case WM_PAINT: _OnPaint(hObj, pObj, pMsg); break; case WM_PID_STATE_CHANGED: { const WM_PID_STATE_CHANGED_INFO* pInfo = (const WM_PID_STATE_CHANGED_INFO*)pMsg->Data.p; if (pInfo->State) { int Sel; Sel = _GetItemFromPos(hObj, pObj, pInfo->x, pInfo->y); if (Sel >= 0) { _ToggleMultiSel(hObj, pObj, Sel); LISTBOX_SetSel(hObj, Sel); } _NotifyOwner(hObj, WM_NOTIFICATION_CLICKED); return; } } break; case WM_TOUCH: _OnTouch(hObj, pMsg); return; #if GUI_SUPPORT_MOUSE case WM_MOUSEOVER: if (_OnMouseOver(hObj, pObj, pMsg) == 0) return; break; #endif case WM_DELETE: _FreeAttached(pObj); break; /* No return here ... WM_DefaultProc needs to be called */ case WM_KEY: if (((const WM_KEY_INFO*)(pMsg->Data.p))->PressedCnt > 0) { int Key; Key = ((const WM_KEY_INFO*)(pMsg->Data.p))->Key; if (LISTBOX_AddKey(hObj, Key)) { return; } } break; case WM_SIZE: LISTBOX_UpdateScrollers(hObj); WM_InvalidateWindow(hObj); break; } WM_DefaultProc(pMsg); }