// ListXP.cpp: implementation of the CListXP class. // ////////////////////////////////////////////////////////////////////// /**************以下设置必需包含在每个子类中**********************/ //头部 //////////////////////////////////////////////////////////////////////////////////////////////////// // 编译预处理 #if _WIN32_WINNT < 0x0400 #define _WIN32_WINNT 0x0400 #endif // 强制使用 C 语言方式编译 #ifdef __cplusplus extern "C" { #endif // __cplusplus #include "SpinXP.h" #include "ScrollXP.H" ////////////////////////////////////////////////////////////////////////////////////////////////// // 全局变量 extern HHOOK g_hPrevHookXP ; // 窗口消息 HOOK 句柄 extern PCLASSXP g_pClassXP ; // 窗口的 CLASSXP 结构指针 extern COLORREF g_crDialogbkColor; // 窗口背景颜色 ////////////////////////////////////////////////////////////// /****************************************************************/ //////////////////////////////////////////////////////////////////////////////////////////////////// // 绘制旋转控件 VOID WINAPI SpinDrawSpinBoxXP(const PCLASSXP pCxp) { RECT Rect; int i; // MEMDCXP Mdcxp; HANDLE hHandle; PCLASSXP pEditCxp; HDC hDC; HWND hWnd; // 获取内存兼容设备场景 // Mdcxp.hWnd = pCxp->hWnd; // Mdcxp.bTransfer = FALSE; // Mdcxp.hBitmap = NULL; // GetMemDCXP(&Mdcxp); hDC = GetDC(); hWnd = pCxp->hWnd; if ((pCxp->lState & CXPU_ALIGNLEFT) || (pCxp->lState & CXPU_ALIGNRIGHT)) { pEditCxp = GetClassXP((HWND) SendMessage(hWnd, UDM_GETBUDDY, 0, 0)); SetState(pCxp->lState, CXPS_DISABLED, pEditCxp->lState & CXPS_DISABLED); } else pEditCxp = NULL; GetClientRect(hWnd, &Rect); if (pEditCxp) { #ifdef CXP_BKCOLOR // 绘制外框 hHandle = (HANDLE) CreateSolidBrush( (pCxp->lState & CXPS_DISABLED) ? (CXP_BKCOLOR - 0x00202020) : 0x00BD9E7B); #else // CXP_BKCOLOR // 绘制外框 hHandle = (HANDLE) CreateSolidBrush( (pCxp->lState & CXPS_DISABLED) ? (GetSysColor(COLOR_BTNFACE) - 0x00202020) : 0x00BD9E7B); #endif // CXP_BKCOLOR FrameRect(hDC, &Rect, hHandle); DeleteObject((HGDIOBJ) hHandle); #ifdef CXP_BKCOLOR hHandle = (HANDLE) SelectObject(hDC, CreatePen(PS_SOLID, 1, (pCxp->lState & CXPS_DISABLED) || (pEditCxp->lState & CXPE_READONLY) ? CXP_BKCOLOR : GetSysColor(COLOR_WINDOW))); #else // CXP_BKCOLOR hHandle = (HANDLE) SelectObject(hDC, CreatePen(PS_SOLID, 1, GetSysColor((pCxp->lState & CXPS_DISABLED) || (pEditCxp->lState & CXPE_READONLY) ? COLOR_BTNFACE : COLOR_WINDOW))); #endif // CXP_BKCOLOR MoveToEx(Mdcxp.hMemDC, (pCxp->lState & CXPU_ALIGNLEFT) ? Rect.right - 1 : 0, 1, NULL); LineTo(Mdcxp.hMemDC, (pCxp->lState & CXPU_ALIGNLEFT) ? Rect.right - 1 : 0, Rect.bottom - 1); DeleteObject(SelectObject(Mdcxp.hMemDC, hHandle)); InflateRect(&Rect, -1, -1); } FillRect(hDC, &Rect, GetSysColorBrush(COLOR_WINDOW)); InflateRect(&Rect, -1, -1); if (pCxp->lState & CXPS_HORIZON) Rect.left += (Rect.right - Rect.left) / 2; else Rect.top += (Rect.bottom - Rect.top) / 2; i = pCxp->lState | CXPH_SMALLARROW; if (pCxp->lState & CXPU_UPPART) { i &= ~CXPS_HOTLIGHT; i &= ~CXPS_PRESSED; } i |= (pCxp->lState & CXPS_HORIZON) ? CXPH_RIGHTWARDS : CXPH_DOWNWARDS; // DropThumbXP(Mdcxp.hMemDC, &Rect, i); ScrollDrowThumbXP(hDC, &Rect, i); i = pCxp->lState | CXPH_SMALLARROW; i |= (pCxp->lState & CXPS_HORIZON) ? CXPH_LEFTWARDS : CXPH_UPWARDS; if (!(pCxp->lState & CXPU_UPPART)) { i &= ~CXPS_HOTLIGHT; i &= ~CXPS_PRESSED; } if (pCxp->lState & CXPS_HORIZON) { Rect.right = Rect.left; Rect.left = pEditCxp ? 2 : 1; } else { Rect.bottom = Rect.top; Rect.top = pEditCxp ? 2: 1; } // DropThumbXP(Mdcxp.hMemDC, &Rect, i); ScrollDrowThumbXP(hDC, &Rect, i); // 还原并释放内存设备场景 // Mdcxp.bTransfer = TRUE; // ReleaseMemDCXP(&Mdcxp); ReleaseDC(hWnd, hDC); } //////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////// LRESULT SpinWindowProc(PCLASSXP pCxp, UINT message,WPARAM wParam, LPARAM lParam) { SCROLLINFO sif; LONG lReturn; HWND hWnd = pCxp->hWnd; switch (message) { case WM_PAINT: case WM_NCPAINT: lReturn = (LONG) CallWindowProc(pCxp->wpPrev, hWnd, message, wParam, lParam); SpinDrawListBoxXP(pCxp); return lReturn; case WM_LBUTTONDOWN: lReturn = (LONG) CallWindowProc(pCxp->wpPrev, hWnd, message, wParam, lParam); pCxp->lState |= CXPS_PRESSED; SpinDrawListBoxXP(pCxp); return lReturn; case WM_LBUTTONUP: lReturn = (LONG) CallWindowProc(pCxp->wpPrev, hWnd, message, wParam, lParam); pCxp->lState &= ~CXPS_PRESSED; SpinDrawListBoxXP(pCxp); return lReturn; case WM_MOUSEMOVE: GetClientRect(pCxp->hWnd, &Rect); if (pCxp->lState & CXPU_UPPART) { if (((pCxp->lState & CXPS_HORIZON) && (LOWORD(lParam) > Rect.right / 2)) || (!(pCxp->lState & CXPS_HORIZON) && (HIWORD(lParam) > Rect.bottom / 2))) { pCxp->lState &= ~CXPU_UPPART; lReturn = (LONG) CallWindowProc(pCxp->wpPrev, hWnd, message, wParam, lParam); SpinDrawListBoxXP(pCxp); return lReturn; } } else { if (((pCxp->lState & CXPS_HORIZON) && (LOWORD(lParam) <= Rect.right / 2)) || (!(pCxp->lState & CXPS_HORIZON) && (HIWORD(lParam) <= Rect.bottom / 2))) { pCxp->lState |= CXPU_UPPART; lReturn = (LONG) CallWindowProc(pCxp->wpPrev, hWnd, message, wParam, lParam); SpinDrawListBoxXP(pCxp); return lReturn; } } return DefWindowProc(hWnd, message, wParam, lParam); case WM_ERASEBKGND: return TRUE; } /* switch (message) { case WM_PAINT: case WM_NCPAINT: pCxp->dwState |= CXPS_NOPAINT; lReturn = (LONG) CallWindowProc(pCxp->wpPrev, hWnd, message, wParam, lParam); SpinDrawListBoxXP(pCxp); return lReturn; } */ // 调用原来的回调函数 lReturn = (LONG) CallWindowProc(pCxp->wpPrev, hWnd, message, wParam, lParam); if (message == WM_NCDESTROY) // 窗口销毁 DeleteClassXP(hWnd); return lReturn; } /**************以下设置必需包含在每个子类中**********************/ //尾部 #ifdef __cplusplus } #endif // __cplusplus /*****************************************************************/