123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- // EditXP.cpp: implementation of the EditXP class.
- //
- //////////////////////////////////////////////////////////////////////
- /**************以下设置必需包含在每个子类中**********************/
- //头部
- ////////////////////////////////////////////////////////////////////////////////////////////////////
- // 编译预处理
- #if _WIN32_WINNT < 0x0400
- #define _WIN32_WINNT 0x0400
- #endif
- // 强制使用 C 语言方式编译
- #ifdef __cplusplus
- extern "C"
- {
- #endif // __cplusplus
- #include "EditXP.h"
- //////////////////////////////////////////////////////////////////////////////////////////////////
- // 全局变量
- extern HHOOK g_hPrevHookXP ; // 窗口消息 HOOK 句柄
- extern PCLASSXP g_pClassXP ; // 窗口的 CLASSXP 结构指针
- extern COLORREF g_crDialogbkColor; // 窗口背景颜色
- //////////////////////////////////////////////////////////////
- /****************************************************************/
- ////////////////////////////////////////////////////////////////////////////////////////////////////
- // 绘制编辑框
- VOID WINAPI EditDrawEditBoxXP(PCLASSXP pCxp)
- {
- HDC hDC;
- RECT Rect;
- LONG lExStyle;
- HANDLE hHandle;
- lExStyle = GetWindowLong(pCxp->hWnd, GWL_EXSTYLE);
- if ((GetWindowLong(pCxp->hWnd, GWL_STYLE) & WS_BORDER) ||
- (lExStyle & WS_EX_CLIENTEDGE) || (lExStyle & WS_EX_STATICEDGE))
- {
- // 由于绘制的东西很少,所以直接绘制而不使用 MEMDCXP 方式
- hDC = GetWindowDC(pCxp->hWnd);
- // 获取窗口大小
- GetWindowRect(pCxp->hWnd, &Rect);
- Rect.right -= Rect.left;
- Rect.bottom -= Rect.top;
- Rect.top = Rect.left = 0;
- // 绘制外框
- hHandle = (HANDLE) CreateSolidBrush(
- (pCxp->dwState & CXPS_DISABLED) ? (GetSysColor(COLOR_BTNFACE) - 0x00202020) : 0x00BD9E7B);
- FrameRect(hDC, &Rect, (HBRUSH) hHandle);
- DeleteObject((HGDIOBJ) hHandle);
- // 绘制内框
- if ((lExStyle & WS_EX_CLIENTEDGE) || (lExStyle & WS_EX_STATICEDGE))
- {
- InflateRect(&Rect, -1, -1);
- // hHandle = (HANDLE) GetSysColorBrush(
- // (pCxp->dwState & CXPS_DISABLED) || (pCxp->dwState & CXPS_READONLY) ? COLOR_BTNFACE : COLOR_WINDOW);
- if ((pCxp->dwState & CXPS_DISABLED) || (pCxp->dwState & CXPS_READONLY))
- hHandle = (HANDLE) GetSysColorBrush(COLOR_WINDOW);
- else
- hHandle = (HANDLE) GetSysColorBrush(g_crDialogbkColor);
- FrameRect(hDC, &Rect, (HBRUSH) hHandle);
- if ((lExStyle & WS_EX_CLIENTEDGE) && (lExStyle & WS_EX_STATICEDGE))
- {
- InflateRect(&Rect, -1, -1);
- FrameRect(hDC, &Rect, (HBRUSH)hHandle);
- }
- }
- // 释放设备场景
- ReleaseDC(pCxp->hWnd, hDC);
- }
- }
- ////////////////////////////////////////////////////////////////////////////////////////////////////
- LRESULT EditWindowProc(PCLASSXP pCxp, UINT message,WPARAM wParam, LPARAM lParam)
- {
- LONG lReturn;
- HWND hWnd = pCxp->hWnd;
- switch(message)
- {
- case WM_NCPAINT:
- case WM_PAINT:
- lReturn = (LONG) DefWindowProc(hWnd, message, wParam, lParam);
- EditDrawEditBoxXP(pCxp);
- return lReturn;
- case EM_SETREADONLY:
- CXPM_SETSTATE(pCxp->dwState, CXPS_READONLY, wParam);
- EditDrawEditBoxXP(pCxp);
- break;
- }
- // 调用原来的回调函数
- lReturn = (LONG) CallWindowProc(pCxp->wpPrev, hWnd, message, wParam, lParam);
- switch (message)
- {
- case WM_DESTROY: // 窗口销毁
- DeleteClassXP(hWnd);
- }
- return lReturn;
- return lReturn;
- }
- /**************以下设置必需包含在每个子类中**********************/
- //尾部
- #ifdef __cplusplus
- }
- #endif // __cplusplus
- /*****************************************************************/
|