123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233 |
- // ListXP.cpp: implementation of the CListXP class.
- //
- //////////////////////////////////////////////////////////////////////
- /**************以下设置必需包含在每个子类中**********************/
- //头部
- ////////////////////////////////////////////////////////////////////////////////////////////////////
- // 编译预处理
- #if _WIN32_WINNT < 0x0400
- #define _WIN32_WINNT 0x0400
- #endif
- #if WINVER < 0x0500
- #define WINVER 0x0500
- #endif // WINVER < 0x0500
- // 强制使用 C 语言方式编译
- #ifdef __cplusplus
- extern "C"
- {
- #endif // __cplusplus
- #include "SpinXP.h"
- #include "ScrollXP.H"
- #include <CommCtrl.H>
- //////////////////////////////////////////////////////////////////////////////////////////////////
- // 全局变量
- extern HHOOK g_hPrevHookXP ; // 窗口消息 HOOK 句柄
- extern PCLASSXP g_pClassXP ; // 窗口的 CLASSXP 结构指针
- extern COLORREF g_crDialogbkColor; // 窗口背景颜色
- //////////////////////////////////////////////////////////////
- /****************************************************************/
- ////////////////////////////////////////////////////////////////////////////////////////////////////
- // 绘制旋转控件
- VOID WINAPI SpinDrawSpinBox(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);
- hWnd = pCxp->hWnd;
- // hDC = GetWindowDC(hWnd);
- hDC = Mdcxp.hMemDC;
- if(hDC == NULL) return;
- if((pCxp->dwState & CXPU_ALIGNLEFT) || (pCxp->dwState & CXPU_ALIGNRIGHT))
- {
- pEditCxp = GetClassXP((HWND) SendMessage(hWnd, UDM_GETBUDDY, 0, 0));
- CXPM_SETSTATE(pCxp->dwState, CXPS_DISABLED, pEditCxp->dwState & CXPS_DISABLED);
- }
- else
- pEditCxp = NULL;
- GetClientRect(hWnd, &Rect);
- if (pEditCxp)
- {
- #ifdef CXP_BKCOLOR
- // 绘制外框
- hHandle = (HANDLE) CreateSolidBrush(
- (pCxp->dwState & CXPS_DISABLED) ? (CXP_BKCOLOR - 0x00202020) : 0x00BD9E7B);
- #else // CXP_BKCOLOR
- // 绘制外框
- hHandle = (HANDLE) CreateSolidBrush(
- (pCxp->dwState & CXPS_DISABLED) ? (GetSysColor(COLOR_BTNFACE) - 0x00202020) : 0x00BD9E7B);
- #endif // CXP_BKCOLOR
- FrameRect(hDC, &Rect, (HBRUSH)hHandle);
- DeleteObject((HGDIOBJ) hHandle);
- #ifdef CXP_BKCOLOR
- hHandle = (HANDLE) SelectObject(hDC, CreatePen(PS_SOLID, 1,
- (pCxp->dwState & CXPS_DISABLED) || (pEditCxp->lState & CXPE_READONLY) ?
- CXP_BKCOLOR : GetSysColor(COLOR_WINDOW)));
- #else // CXP_BKCOLOR
- hHandle = (HANDLE) SelectObject(hDC, CreatePen(PS_SOLID, 1,
- GetSysColor((pCxp->dwState & CXPS_DISABLED) || (pEditCxp->dwState & CXPE_READONLY) ?
- COLOR_BTNFACE : COLOR_WINDOW)));
- #endif // CXP_BKCOLOR
- MoveToEx(hDC, (pCxp->dwState & CXPU_ALIGNLEFT) ? Rect.right - 1 : 0, 1, NULL);
- LineTo(hDC, (pCxp->dwState & CXPU_ALIGNLEFT) ? Rect.right - 1 : 0, Rect.bottom - 1);
- DeleteObject(SelectObject(hDC, hHandle));
- InflateRect(&Rect, -1, -1);
- }
- FillRect(hDC, &Rect, GetSysColorBrush(COLOR_WINDOW));
- InflateRect(&Rect, -1, -1);
- if (pCxp->dwState & CXPS_HORIZON)
- Rect.left += (Rect.right - Rect.left) / 2;
- else
- Rect.top += (Rect.bottom - Rect.top) / 2;
- i = pCxp->dwState | CXPH_SMALLARROW;
- if (pCxp->dwState & CXPU_UPPART)
- {
- i &= ~CXPS_HOTLIGHT;
- i &= ~CXPS_PRESSED;
- }
-
- i |= (pCxp->dwState & CXPS_HORIZON) ? CXPH_RIGHTWARDS : CXPH_DOWNWARDS;
- // DropThumbXP(Mdcxp.hMemDC, &Rect, i);
- ScrollDrowThumbXP(hDC, Rect, i);
- i = pCxp->dwState | CXPH_SMALLARROW;
- i |= (pCxp->dwState & CXPS_HORIZON) ? CXPH_LEFTWARDS : CXPH_UPWARDS;
- if (!(pCxp->dwState & CXPU_UPPART))
- {
- i &= ~CXPS_HOTLIGHT;
- i &= ~CXPS_PRESSED;
- }
- if (pCxp->dwState & 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;
- RECT Rect;
- HWND hWnd = pCxp->hWnd;
- switch (message)
- {
- case WM_PAINT:
- case WM_NCPAINT:
- SendMessage(hWnd,WM_SETREDRAW,FALSE,0);
- lReturn = (LONG) CallWindowProc(pCxp->wpPrev, hWnd, message, wParam, lParam);
- SendMessage(hWnd,WM_SETREDRAW,TRUE,0);
- SpinDrawSpinBox(pCxp);
- return lReturn;
- // return CXPC_DRAWCLASSXP | CXPC_PRECALLDEFPROC;
- case WM_LBUTTONDBLCLK:
- return TRUE;
- case WM_LBUTTONDOWN:
- pCxp->dwState |= CXPS_PRESSED;
- SendMessage(hWnd,WM_SETREDRAW,FALSE,0);
- lReturn = (LONG) CallWindowProc(pCxp->wpPrev, hWnd, message, wParam, lParam);
- SendMessage(hWnd,WM_SETREDRAW,TRUE,0);
- SpinDrawSpinBox(pCxp);
- return lReturn;
- // return CXPC_DRAWCLASSXP | CXPC_PRECALLWNDPROC;
- case WM_LBUTTONUP:
- pCxp->dwState &= ~CXPS_PRESSED;
- SendMessage(hWnd,WM_SETREDRAW,FALSE,0);
- lReturn = (LONG) CallWindowProc(pCxp->wpPrev, hWnd, message, wParam, lParam);
- SendMessage(hWnd,WM_SETREDRAW,TRUE,0);
- SpinDrawSpinBox(pCxp);
- return lReturn;
- // return CXPC_DRAWCLASSXP | CXPC_PRECALLWNDPROC;
- case WM_MOUSEMOVE:
- GetClientRect(hWnd, &Rect);
- if (pCxp->dwState & CXPU_UPPART)
- {
- if (((pCxp->dwState & CXPS_HORIZON) && (LOWORD(lParam) > Rect.right / 2)) ||
- (!(pCxp->dwState & CXPS_HORIZON) && (HIWORD(lParam) > Rect.bottom / 2)))
- {
- pCxp->dwState &= ~CXPU_UPPART;
- SendMessage(hWnd,WM_SETREDRAW,FALSE,0);
- lReturn = (LONG) CallWindowProc(pCxp->wpPrev, hWnd, message, wParam, lParam);
- SendMessage(hWnd,WM_SETREDRAW,TRUE,0);
- SpinDrawSpinBox(pCxp);
- return lReturn;
- // return CXPC_DRAWCLASSXP | CXPC_PRECALLWNDPROC | CXPC_CALLCOMMON;
- }
- }
- else
- {
- if (((pCxp->dwState & CXPS_HORIZON) && (LOWORD(lParam) <= Rect.right / 2)) ||
- (!(pCxp->dwState & CXPS_HORIZON) && (HIWORD(lParam) <= Rect.bottom / 2)))
- {
- pCxp->dwState |= CXPU_UPPART;
- SendMessage(hWnd,WM_SETREDRAW,FALSE,0);
- lReturn = (LONG) CallWindowProc(pCxp->wpPrev, hWnd, message, wParam, lParam);
- SendMessage(hWnd,WM_SETREDRAW,TRUE,0);
- SpinDrawSpinBox(pCxp);
- return lReturn;
- //return CXPC_DRAWCLASSXP | CXPC_PRECALLWNDPROC | CXPC_CALLCOMMON;
- }
- }
- return DefWindowProc(hWnd, message, wParam, lParam);
- // return CXPC_CALLCOMMON;
- 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);
- SpinDrawSpinBoxXP(pCxp);
- return lReturn;
- }
- */
- // 调用原来的回调函数
- lReturn = (LONG) CallWindowProc(pCxp->wpPrev, hWnd, message, wParam, lParam);
- if (message == WM_NCDESTROY) // 窗口销毁
- DeleteClassXP(hWnd);
- return lReturn;
- }
- /**************以下设置必需包含在每个子类中**********************/
- //尾部
- #ifdef __cplusplus
- }
- #endif // __cplusplus
- /*****************************************************************/
|