123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032 |
- #if _WIN32_WINNT < 0x0400
- #define _WIN32_WINNT 0x0400
- #endif
- #ifdef __cplusplus
- extern "C"
- {
- #endif
- #include "ButtonXP.h"
- extern HHOOK g_hPrevHookXP ;
- extern PCLASSXP g_pClassXP ;
- extern COLORREF g_crDialogbkColor;
- static COLORREF gChecks_crGradientXP[][4] =
- {
- {0x00A5B2B5, 0x00CED7D6, 0x00CED7D6, 0x00DEEFF7},
- {0x00CEF3FF, 0x0063CBFF, 0x0063CBFF, 0x0031B2FF},
- {0x00D6DFDE, 0x00EFF3F7, 0x00EFF3F7, 0x00FFFFFF},
- {0x0021A221, 0x0021A221, 0x00187A18, 0x00187A18},
- };
- UINT ButtonStyle2Format(DWORD style)
- {
- UINT uFormat = 0;
- if((style & BS_MULTILINE) != BS_MULTILINE)
- uFormat |= DT_SINGLELINE;
- if((style & BS_TOP) == BS_TOP)
- uFormat |= DT_TOP;
- else if((style & BS_BOTTOM) == BS_BOTTOM)
- uFormat |= DT_BOTTOM;
- else
- uFormat |= DT_VCENTER | DT_SINGLELINE;
- if((style & BS_LEFT) == BS_LEFT)
- uFormat |= DT_LEFT;
- else if((style & BS_RIGHT) == BS_RIGHT)
- uFormat |= DT_RIGHT;
- else
- uFormat |= DT_CENTER;
- uFormat |= DT_END_ELLIPSIS;
- return uFormat;
- }
- LRESULT ButtonOnSetIcon(PCLASSXP pCxp, WPARAM wParam, LPARAM lParam)
- {
- if (pCxp->hIconDisabled) DeleteObject(pCxp->hIconDisabled);
- pCxp->hIconDisabled =(HICON)CopyImage((HICON)lParam, IMAGE_ICON, 0,0,LR_MONOCHROME|LR_COPYRETURNORG);
- LRESULT nRet = CallWindowProc(pCxp->wpPrev, pCxp->hWnd, WM_SETICON, wParam, lParam);
- return nRet;
- }
- VOID WINAPI ButtonDrawPushText(PCLASSXP pCxp, HDC hDC, RECT rc)
- {
- RECT rcIcon, rcText;
- HANDLE hHandle;
- char szTemp[256];
- HICON hIcon;
- DWORD dwStyle;
- ICONINFO piconinfo;
- UINT uFormat;
- dwStyle = (DWORD)GetWindowLong(pCxp->hWnd, GWL_STYLE);
- if (pCxp->dwState & CXPS_DISABLED)
- hIcon = pCxp->hIconDisabled;
- else
- hIcon =(HICON) SendMessage(pCxp->hWnd, WM_GETICON, ICON_SMALL, 0);
- rcText = rc;
- if (hIcon)
- {
- GetIconInfo(hIcon,&piconinfo);
- rcIcon = rc;
- if (dwStyle & BS_TOP)
- {
-
- rcIcon.top = rc.bottom - piconinfo.yHotspot*2 - 4;
- rcText.bottom -= piconinfo.yHotspot*2 ;
- }
- else if (dwStyle & BS_VCENTER)
- {
-
- rcIcon.top = (rc.bottom-rc.top)/2-piconinfo.yHotspot;
-
- }
- else
- {
-
- rcIcon.top = rc.top+4;
- rcText.top += piconinfo.yHotspot*2 + 4;
- }
- if (dwStyle & BS_RIGHT)
- {
- rcIcon.left = 4;
-
- rcText.left += piconinfo.yHotspot*2 + 2;
- }
- else if(dwStyle & BS_LEFT)
- {
- rcIcon.left = rc.right - (piconinfo.yHotspot*2 + 4);
-
- rcText.right -= (piconinfo.yHotspot*2 + 2);
- }
- else
- {
- rcIcon.left = (rc.right - rc.left)/2-piconinfo.yHotspot + 2;
-
-
- }
- DrawIcon(hDC, rcIcon.left,rcIcon.top, hIcon);
- }
- uFormat = ButtonStyle2Format(dwStyle);
- if (GetWindowText(pCxp->hWnd, szTemp, sizeof(szTemp)))
- {
- if (pCxp->dwState & CXPS_PRESSED)
- OffsetRect(&rcText, 1, 1);
- SetTextColor(hDC,
- ((pCxp->dwState & CXPS_INDETERMINATE) || (pCxp->dwState & CXPS_DISABLED)) ?
- 0x0094A2A5: 0x00000000);
- hHandle = (HANDLE) SelectObject(hDC,
- (HGDIOBJ) SendMessage(pCxp->hWnd, WM_GETFONT, 0, 0));
-
- DrawText(hDC, szTemp, -1, &rcText, uFormat);
- SelectObject(hDC, (HGDIOBJ) hHandle);
- }
- }
- VOID WINAPI ButtonDrawPushButtonXP(PCLASSXP pCxp)
- {
- int i;
- RECT Rect, rc;
- MEMDCXP Mdcxp;
- HANDLE hHandle;
- COLORREF crColor;
- HDC hDC;
- static COLORREF s_crGradientXP[][4] =
- {
- {0x00C1CCD1, 0x00C1CCD1, 0x00EEF1F2, 0xFFEEF1F2},
- {0x00CFF0FF, 0x00CFF0FF, 0x000097E5, 0xFF0097E5},
- {0x00BDCBD6, 0x00C6CFD6, 0x00EFF3F7, 0xFFEFF3F7},
- {0x00FFE7CE, 0x00FFE7CE, 0x00EE8269, 0xFFEE8269},
- {0x00FFFFFF, 0x00FFFFFF, 0x00D6DFE2, 0xFFD6DFE2},
- {0x00DEE3E7, 0x00E7E7E7, 0x00DEE3E7, 0xFFDEE3E7},
- {0x00FBFCFC, 0x00FBFCFC, 0x00E6EBEC, 0xFFE6EBEC},
- };
-
- Mdcxp.hWnd = pCxp->hWnd;
- Mdcxp.bTransfer = FALSE;
- Mdcxp.hBitmap = NULL;
- GetMemDCXP(&Mdcxp);
- hDC = Mdcxp.hMemDC;
-
- GetWindowRect(pCxp->hWnd, &Rect);
- Rect.right -= Rect.left;
- Rect.bottom -= Rect.top;
- Rect.left = Rect.top = 0;
- rc = Rect;
-
- hHandle = (HANDLE) CreateSolidBrush(g_crDialogbkColor);
- FrameRect(hDC, &Rect, (HBRUSH) hHandle);
- DeleteObject((HGDIOBJ) hHandle);
-
- InflateRect(&Rect, -1, -1);
- hHandle = (HANDLE) CreateSolidBrush(
- (pCxp->dwState & CXPS_DISABLED) ? (g_crDialogbkColor - 0x00202020) : 0x00733C00);
- FrameRect(hDC, &Rect, (HBRUSH) hHandle);
- DeleteObject((HGDIOBJ) hHandle);
-
- InflateRect(&Rect, -1, -1);
- if (pCxp->dwState & CXPS_DISABLED)
- {
- i = -1;
-
- hHandle = (HANDLE) CreateSolidBrush(g_crDialogbkColor);
- FillRect(hDC, &Rect, (HBRUSH) hHandle);
- DeleteObject((HGDIOBJ) hHandle);
- }
- else
- {
- if (pCxp->dwState & CXPS_PRESSED)
- i = 0;
- else if (pCxp->dwState & CXPS_HOTLIGHT)
- i = 1;
- else if ((pCxp->dwState & CXPS_CHECKED) || (pCxp->dwState & CXPS_INDETERMINATE))
- i = 2;
- else if ((pCxp->dwState & CXPS_FOCUS) || (pCxp->dwState & CXPS_DEFAULT))
- i = 3;
- else
- i = 4;
- GradientRectXP(hDC, &Rect, s_crGradientXP[i]);
- }
-
- InflateRect(&Rect, -2, -2);
- if ((pCxp->dwState & CXPS_PRESSED) ||
- (pCxp->dwState & CXPS_CHECKED) ||
- (pCxp->dwState & CXPS_INDETERMINATE))
- i = 5;
- else if (!(pCxp->dwState & CXPS_DISABLED))
- i = 6;
- if ((i == 5) || (i == 6))
- GradientRectXP(hDC, &Rect, s_crGradientXP[i]);
-
- crColor = g_crDialogbkColor;
- SetPixel(hDC, 1, 1, crColor);
- SetPixel(hDC, 1, Rect.bottom + 2, crColor);
- SetPixel(hDC, Rect.right + 2, Rect.bottom + 2, crColor);
- SetPixel(hDC, Rect.right + 2, 1, crColor);
-
- crColor = (pCxp->dwState & CXPS_DISABLED) ?
- (g_crDialogbkColor - 0x00151515) : g_crDialogbkColor-0x00A57D52;
- SetPixel(hDC, 2, 2, crColor);
- SetPixel(hDC, 2, Rect.bottom + 1, crColor);
- SetPixel(hDC, Rect.right + 1, Rect.bottom + 1, crColor);
- SetPixel(hDC, Rect.right + 1, 2, crColor);
- crColor = (pCxp->dwState & CXPS_DISABLED) ?
- (g_crDialogbkColor - 0x00111111) : g_crDialogbkColor-0x00AD967B;
- SetPixel(hDC, 1, 2, crColor);
- SetPixel(hDC, 2, 1, crColor);
- SetPixel(hDC, Rect.right + 1, 1, crColor);
- SetPixel(hDC, Rect.right + 2, 2, crColor);
- SetPixel(hDC, Rect.right + 1, Rect.bottom + 2, crColor);
- SetPixel(hDC, Rect.right + 2, Rect.bottom + 1, crColor);
- SetPixel(hDC, 2, Rect.bottom + 2, crColor);
- SetPixel(hDC, 1, Rect.bottom + 1, crColor);
-
- if (pCxp->dwState & CXPS_FOCUS)
- {
- InflateRect(&Rect, 1, 1);
- DrawFocusRect(hDC, &Rect);
- }
- ButtonDrawPushText(pCxp,hDC,rc);
- Mdcxp.bTransfer = TRUE;
- ReleaseMemDCXP(&Mdcxp);
- }
- VOID WINAPI ButtonDrawCheckBoxXP(PCLASSXP pCxp)
- {
- int i;
- RECT Rect, rcText;
- MEMDCXP Mdcxp;
- HANDLE hHandle;
- char szTemp[256];
- COLORREF crColor;
- DWORD dwStyle;
- HDC hDC;
- Mdcxp.hWnd = pCxp->hWnd;
- Mdcxp.bTransfer = FALSE;
- Mdcxp.hBitmap = NULL;
- GetMemDCXP(&Mdcxp);
- hDC = Mdcxp.hMemDC;
- GetWindowRect(pCxp->hWnd, &Rect);
- Rect.right -= Rect.left;
- Rect.bottom -= Rect.top;
- Rect.left = Rect.top = 0;
- hHandle = CreateSolidBrush(g_crDialogbkColor);
- FillRect(hDC,&Rect, (HBRUSH)hHandle);
- DeleteObject(hHandle);
- dwStyle = GetWindowLong(pCxp->hWnd, GWL_STYLE);
- if (dwStyle & BS_LEFTTEXT)
- {
- rcText = Rect;
- rcText.right -= 18;
- Rect.left = Rect.right - 13;
- Rect.top = (Rect.bottom - 13) / 2;
- Rect.bottom = Rect.top + 13;
- }
- else
- {
- rcText = Rect;
- rcText.left += 18;
- Rect.left = 0;
- Rect.right = 13;
- Rect.top = (Rect.bottom - 13) / 2;
- Rect.bottom = Rect.top + 13;
- }
- hHandle = (HANDLE) CreateSolidBrush(
- (pCxp->dwState & CXPS_DISABLED) ? (GetSysColor(COLOR_BTNFACE) - 0x00202020) : 0x00845118);
- FrameRect(Mdcxp.hMemDC, &Rect, (HBRUSH) hHandle);
- DeleteObject((HGDIOBJ) hHandle);
- InflateRect(&Rect, -1, -1);
- if (!(pCxp->dwState & CXPS_DISABLED))
- {
- if (pCxp->dwState & CXPS_PRESSED)
- i = 0;
- else if (pCxp->dwState & CXPS_HOTLIGHT)
- i = 1;
- else
- i = 2;
- GradientRectXP(hDC, &Rect, gChecks_crGradientXP[i]);
- }
- InflateRect(&Rect, -2, -2);
- if ((pCxp->dwState & CXPS_INDETERMINATE) ||
- ((pCxp->dwState & CXPS_HOTLIGHT) && (!(pCxp->dwState & CXPS_PRESSED))))
- {
- if (pCxp->dwState & CXPS_INDETERMINATE)
- {
- if (pCxp->dwState & CXPS_DISABLED)
- crColor = 0x00BDCBCE;
- else if (pCxp->dwState & CXPS_PRESSED)
- crColor = 0x00188A18;
- else if (pCxp->dwState & CXPS_HOTLIGHT)
- crColor = 0x0021A221;
- else
- crColor = 0x0073C373;
- }
- else if (pCxp->dwState & CXPS_CHECKED)
- crColor = 0x00F7F7F7;
- else
- crColor = 0x00E7E7E7;
- hHandle = (HANDLE) CreateSolidBrush(crColor);
- FillRect(hDC, &Rect, (HBRUSH) hHandle);
- DeleteObject((HGDIOBJ) hHandle);
- }
- if (pCxp->dwState & CXPS_CHECKED)
- {
- hHandle = (HANDLE) SelectObject(hDC,
- CreatePen(PS_SOLID, 1, (pCxp->dwState & CXPS_DISABLED) ? 0x000BDCBCE : 0x0021A221));
- for (i = 3; i < 10; i++)
- {
- MoveToEx(hDC, Rect.left+i-3, Rect.top + ((i < 6) ? i - 1 : (9 - i)), NULL);
- LineTo(hDC, Rect.left+i-3, Rect.top + ((i < 6) ? i + 2 : (12 - i)));
- }
- DeleteObject(SelectObject(hDC,(HGDIOBJ) hHandle));
- }
- if (GetWindowText(pCxp->hWnd, szTemp, sizeof(szTemp)))
- {
- SetTextColor(hDC, GetSysColor((pCxp->dwState & CXPS_DISABLED) ? COLOR_GRAYTEXT: COLOR_BTNTEXT));
- hHandle = (HANDLE) SelectObject(hDC,
- (HGDIOBJ) SendMessage(pCxp->hWnd, WM_GETFONT, 0, 0));
- rcText.bottom = rcText.top + 1 + DrawText(hDC, szTemp, -1, &rcText,
- DT_CALCRECT | DT_SINGLELINE | DT_VCENTER);
-
- DrawText(hDC, szTemp, -1, &rcText, DT_SINGLELINE | DT_VCENTER);
- SelectObject(hDC, (HGDIOBJ) hHandle);
-
- if (pCxp->dwState & CXPS_FOCUS)
- {
- InflateRect(&rcText, 0, -1);
- DrawFocusRect(hDC, &rcText);
- }
- }
- Mdcxp.bTransfer = TRUE;
- ReleaseMemDCXP(&Mdcxp);
- }
- VOID WINAPI ButtonDrawRadioBoxXP(PCLASSXP pCxp)
- {
- RECT Rect,rc, rcText;
- MEMDCXP Mdcxp;
- HANDLE hHandle, hPen;
- char szTemp[256];
- COLORREF crColor;
- DWORD dwStyle;
- HDC hDC;
- Mdcxp.hWnd = pCxp->hWnd;
- Mdcxp.bTransfer = FALSE;
- Mdcxp.hBitmap = NULL;
- GetMemDCXP(&Mdcxp);
- hDC = Mdcxp.hMemDC;
- GetWindowRect(pCxp->hWnd, &Rect);
- Rect.right -= Rect.left;
- Rect.bottom -= Rect.top;
- Rect.left = Rect.top = 0;
- hHandle = CreateSolidBrush(g_crDialogbkColor);
- FillRect(hDC,&Rect, (HBRUSH)hHandle);
- DeleteObject(hHandle);
- dwStyle = GetWindowLong(pCxp->hWnd, GWL_STYLE);
- if (dwStyle & BS_LEFTTEXT)
- {
- rcText = Rect;
- rcText.right -= 15;
- Rect.left = Rect.right-15;
- Rect.top = (Rect.bottom -15)/2;
- Rect.bottom = Rect.top + 15;
- rc = Rect;
- }
- else
- {
- rcText = Rect;
- rcText.left += 15;
- Rect.right = 15;
- Rect.top = (Rect.bottom -15)/2;
- Rect.bottom = Rect.top + 15;
- rc = Rect;
- }
-
- if (!(pCxp->dwState & CXPS_DISABLED))
- {
- if (pCxp->dwState & CXPS_PRESSED)
- GradientRectXP(hDC, &rc, gChecks_crGradientXP[0]);
- else if (pCxp->dwState & CXPS_HOTLIGHT)
- GradientRectXP(hDC, &rc, gChecks_crGradientXP[1]);
- }
-
- InflateRect(&rc, -2, -2);
- if ((pCxp->dwState & CXPS_INDETERMINATE) ||
- ((pCxp->dwState & CXPS_HOTLIGHT) && (!(pCxp->dwState & CXPS_PRESSED))))
- {
- if (pCxp->dwState & CXPS_INDETERMINATE)
- {
- if (pCxp->dwState & CXPS_DISABLED)
- crColor = 0x00BDCBCE;
- else if (pCxp->dwState & CXPS_PRESSED)
- crColor = 0x00188A18;
- else if (pCxp->dwState & CXPS_HOTLIGHT)
- crColor = 0x0021A221;
- else
- crColor = 0x0073C373;
- }
- else if (pCxp->dwState & CXPS_CHECKED)
- crColor = 0x00F7F7F7;
- else
- crColor = 0x00E7E7E7;
- hHandle = (HANDLE) CreateSolidBrush(crColor);
- FillRect(hDC, &rc, (HBRUSH) hHandle);
- DeleteObject((HGDIOBJ) hHandle);
- }
- hHandle = SelectObject(hDC, GetStockObject(NULL_BRUSH));
- if (pCxp->dwState & CXPS_CHECKED)
- {
- GradientRectXP(hDC, &rc, gChecks_crGradientXP[3]);
- hPen = SelectObject(hDC, CreatePen(PS_SOLID, 1, g_crDialogbkColor));
- Ellipse(hDC, Rect.left+3, Rect.top+3,Rect.left+12,Rect.top+12);
- Ellipse(hDC, Rect.left+4, Rect.top+4,Rect.left+11,Rect.top+11);
- DeleteObject(SelectObject(hDC,hPen));
- }
- if (!(pCxp->dwState & CXPS_HOTLIGHT))
- {
- hPen = SelectObject(hDC,CreatePen(PS_SOLID, 3, g_crDialogbkColor));
- Ellipse(hDC, Rect.left, Rect.top,Rect.left+14,Rect.top+14);
- DeleteObject(SelectObject(hDC,hPen));
- }
- hPen = SelectObject(hDC, CreatePen(PS_SOLID, 1, (pCxp->dwState & CXPS_DISABLED) ? (GetSysColor(COLOR_BTNFACE) - 0x00202020) : 0x00845118));
- Ellipse(hDC, Rect.left+2, Rect.top+2,Rect.left+13,Rect.top+13);
- DeleteObject(SelectObject(hDC,hPen));
- SelectObject(hDC, hHandle);
- if (GetWindowText(pCxp->hWnd, szTemp, sizeof(szTemp)))
- {
- SetTextColor(hDC, GetSysColor((pCxp->dwState & CXPS_DISABLED) ? COLOR_GRAYTEXT: COLOR_BTNTEXT));
- hHandle = (HANDLE) SelectObject(hDC,
- (HGDIOBJ) SendMessage(pCxp->hWnd, WM_GETFONT, 0, 0));
- DrawText(hDC, szTemp, -1, &rcText, dwStyle);
- SelectObject(hDC, (HGDIOBJ) hHandle);
-
- if (pCxp->dwState & CXPS_FOCUS)
- {
- InflateRect(&rcText, -1, -1);
- DrawFocusRect(hDC, &rcText);
- }
- }
- Mdcxp.bTransfer = TRUE;
- ReleaseMemDCXP(&Mdcxp);
- }
- VOID WINAPI ButtonDrawGroupBoxXP(PCLASSXP pCxp)
- {
- RECT Rect;
- char szTemp[256];
- HANDLE hHandle,hBrush;
- DWORD dwStyle;
- HDC hDC = GetWindowDC(pCxp->hWnd);
- GetWindowRect(pCxp->hWnd, &Rect);
- Rect.right -= Rect.left;
- Rect.bottom -= Rect.top;
- Rect.left = Rect.top = 0;
- hBrush = SelectObject(hDC, GetStockObject(NULL_BRUSH));
- RoundRect(hDC, Rect.left,Rect.top+6,Rect.right,Rect.bottom,
- 6,6);
- SelectObject(hDC, hBrush);
- dwStyle = (DWORD)GetWindowLong(pCxp->hWnd, GWL_STYLE);
- if (GetWindowText(pCxp->hWnd, szTemp, sizeof(szTemp)))
- {
- SetTextColor(hDC,
- ((pCxp->dwState & CXPS_INDETERMINATE) || (pCxp->dwState & CXPS_DISABLED)) ?
- 0x0094A2A5: 0x00000000);
- hHandle = (HANDLE) SelectObject(hDC,
- (HGDIOBJ) SendMessage(pCxp->hWnd, WM_GETFONT, 0, 0));
-
- Rect.left+=5;
- DrawText(hDC, szTemp, -1, &Rect, DT_LEFT);
- SelectObject(hDC, (HGDIOBJ) hHandle);
- }
- ReleaseDC(pCxp->hWnd,hDC);
- }
- VOID WINAPI ButtonDrawStateBoxXP(PCLASSXP pCxp)
- {
- HICON hIcon;
- RECT Rect;
- char szTemp[256];
- HANDLE hHandle;
- DWORD dwStyle;
- int nSaveDC;
- HDC hDC = GetWindowDC(pCxp->hWnd);
-
- nSaveDC = SaveDC(hDC);
- dwStyle = (DWORD)GetWindowLong(pCxp->hWnd, GWL_STYLE);
- if(dwStyle & SS_ICON)
- {
- hIcon = (HICON)SendMessage(pCxp->hWnd,STM_GETICON,0L,0L);
- if(hIcon)
- DrawIcon(hDC, Rect.left, Rect.top, hIcon);
- }
- else
- {
- if (GetWindowText(pCxp->hWnd, szTemp, sizeof(szTemp)))
- {
- SetTextColor(hDC,
- ((pCxp->dwState & CXPS_INDETERMINATE) || (pCxp->dwState & CXPS_DISABLED)) ?
- 0x0094A2A5: 0x00000000);
- hHandle = (HANDLE) SelectObject(hDC,
- (HGDIOBJ) SendMessage(pCxp->hWnd, WM_GETFONT, 0, 0));
-
- DrawText(hDC, szTemp, -1, &Rect, dwStyle);
- SelectObject(hDC, (HGDIOBJ) hHandle);
- }
- }
- RestoreDC(hDC, nSaveDC );
- }
- LRESULT ButtonWindowProc(PCLASSXP pCxp, UINT message,WPARAM wParam, LPARAM lParam)
- {
- LONG lReturn, lFound;
- TRACKMOUSEEVENT Tme;
- HWND hParent;
- typedef VOID (WINAPI *DRAWXP)(PCLASSXP);
- static DRAWXP s_DrawXP[] =
- {
- ButtonDrawPushButtonXP,
- ButtonDrawCheckBoxXP,
- ButtonDrawRadioBoxXP,
- ButtonDrawGroupBoxXP,
- ButtonDrawStateBoxXP,
- };
- HWND hWnd = pCxp->hWnd;
- switch (message)
- {
- case WM_SETICON:
- return ButtonOnSetIcon(pCxp, wParam,lParam);
- case BM_SETSTYLE:
- CXPM_SETSTATE(pCxp->dwState, CXPS_DEFAULT, wParam & BS_DEFPUSHBUTTON);
- s_DrawXP[pCxp->dwType](pCxp);
- break;
- case BM_SETSTATE:
- lReturn = (LONG) CallWindowProc(pCxp->wpPrev, hWnd, message, wParam, lParam);
- CXPM_SETSTATE(pCxp->dwState, CXPS_PRESSED, wParam);
- s_DrawXP[pCxp->dwType](pCxp);
- return lReturn;
- case BM_SETCHECK:
- lReturn = (LONG) CallWindowProc(pCxp->wpPrev, hWnd, message, wParam, lParam);
- CXPM_SETSTATE(pCxp->dwState, CXPS_CHECKED, (wParam == BST_CHECKED));
- CXPM_SETSTATE(pCxp->dwState, CXPS_INDETERMINATE, (wParam == BST_INDETERMINATE));
- s_DrawXP[pCxp->dwType](pCxp);
- return lReturn;
- case WM_SETTEXT:
- lReturn = (LONG) DefWindowProc(hWnd, message, wParam, lParam);
- s_DrawXP[pCxp->dwType](pCxp);
- return lReturn;
- case WM_PAINT:
- lReturn = DefWindowProc(pCxp->hWnd, message, wParam, lParam);
- s_DrawXP[pCxp->dwType](pCxp);
- return lReturn;
- case WM_LBUTTONUP:
- if(pCxp->dwType == CXPT_PUSHBUTTON)
- {
- ReleaseCapture();
- hParent = GetParent(hWnd);
- if(hParent != NULL) SendMessage(hParent,WM_COMMAND,MAKEWPARAM(GetDlgCtrlID(hWnd),BN_CLICKED),(LPARAM)hWnd);
- pCxp->dwState &= ~CXPS_PRESSED;
- s_DrawXP[pCxp->dwType](pCxp);
- return 0;
- }
- break;
- case WM_LBUTTONDOWN:
- case WM_LBUTTONDBLCLK:
- if(pCxp->dwType == CXPT_PUSHBUTTON)
- {
- SetFocus(hWnd);
- pCxp->dwState |= CXPS_PRESSED;
- s_DrawXP[pCxp->dwType](pCxp);
- return 0;
- }
- break;
- case WM_ERASEBKGND:
- if(pCxp->dwType == CXPT_CHECKBOX) return TRUE;
- if(pCxp->dwType == CXPT_RADIOBOX) return TRUE;
- if(pCxp->dwType == CXPT_STATEBOX) return TRUE;
- if(pCxp->dwType == CXPT_GROUPBOX) return TRUE;
- break;
- case WM_MOUSELEAVE:
- if (pCxp->dwState & CXPS_HOTLIGHT)
- {
- pCxp->dwState &= ~CXPS_HOTLIGHT;
-
- lFound = 1;
- }
- if (pCxp->dwState & CXPS_PRESSED)
- {
- pCxp->dwState &= ~CXPS_PRESSED;
- lFound = 1;
- }
- s_DrawXP[pCxp->dwType](pCxp);
- return 0;
- }
-
- lReturn = (LONG) CallWindowProc(pCxp->wpPrev, hWnd, message, wParam, lParam);
-
- switch (message)
- {
- case WM_MOUSEMOVE:
- if (((pCxp->dwState & CXPS_HOTLIGHT) == 0) && ((wParam & MK_LBUTTON) == 0))
- {
- pCxp->dwState |= CXPS_HOTLIGHT;
- s_DrawXP[pCxp->dwType](pCxp);
-
- Tme.cbSize = sizeof(TRACKMOUSEEVENT);
- Tme.dwFlags = TME_LEAVE;
- Tme.hwndTrack = hWnd;
- TrackMouseEvent(&Tme);
- }
- break;
- case WM_ENABLE:
- CXPM_SETSTATE(pCxp->dwState, CXPS_DISABLED, !wParam);
- s_DrawXP[pCxp->dwType](pCxp);
- break;
- case WM_SETFOCUS:
- SendMessage((HWND)wParam, WM_KILLFOCUS,0,0);
- pCxp->dwState |= CXPS_FOCUS;
- s_DrawXP[pCxp->dwType](pCxp);
- break;
- case WM_KILLFOCUS:
- pCxp->dwState &= ~CXPS_FOCUS;
- s_DrawXP[pCxp->dwType](pCxp);
- break;
- case WM_NCDESTROY:
- DeleteClassXP(hWnd);
- }
- return lReturn;
- }
- #ifdef __cplusplus
- }
- #endif
|