123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227 |
- #if _WIN32_WINNT < 0x0400
- #define _WIN32_WINNT 0x0400
- #endif
- #ifdef __cplusplus
- extern "C"
- {
- #endif
- #include "ScrollXP.h"
- extern HHOOK g_hPrevHookXP ;
- extern PCLASSXP g_pClassXP ;
- extern COLORREF g_crDialogbkColor;
- #define SCROLLAREA 0
- #define SCROLLTOPARROW 1
- #define SCROLLBOTTOMARROW 2
- #define SCROLLLEFTARROW 3
- #define SCROLLRIGHTARROW 4
- #define SCROLLTHUMB 5
- #define SCROLLAREANULL 6
- #define SCROLLALL 7
- VOID WINAPI ScrollDrowThumbXP(HDC hDC, RECT Rect, LONG lState)
- {
- int i;
- HANDLE hHandle;
- static COLORREF s_crGradientXP[][4] =
- {
- {0x00EFF3F7, 0x00DEE7E7, 0x00DEE3E7, 0x00DEE3E7},
- {0x00DEAEA5, 0x00F7CBBD, 0x00DE8273, 0x00F7C7B5},
- {0x00EFC7B5, 0x00E7AE94, 0x00DEA284, 0x00DEA68C},
- {0x00FFE3D6, 0x00F7CBBD, 0x00F7C3AD, 0x00F7C7B5},
- {0x00F7F7F7, 0x00EFF3F7, 0x00EFF3F7, 0x00EFF3F7},
- {0x00DEC3BD, 0x00DEB6AD, 0x00FFE3DE, 0x00F7E3DE},
- {0x00EFDBCE, 0x00EFCFC6, 0x00E7CFC6, 0x00E7CBBD},
- {0x00FFEFE7, 0x00FFE7DE, 0x00FFE3DE, 0x00F7E3DE},
- {0x00F7F7F7, 0x00E7EFEF, 0x00E7EBEF, 0x00DEE7E7},
- {0x00F78E6B, 0x00F79684, 0x00EF9E8C, 0x00EFDFD6},
- {0x00FFFFFF, 0x00FFE3CE, 0x00FFDFC6, 0x00FFDBBD},
- {0x00FFEBE7, 0x00FFCFBD, 0x00FFCBB5, 0x00F7CBAD},
- {0x00EFF3F7, 0x00DEE7E7, 0x00EFF3F7, 0x00DEE3E7},
- {0x00DEAEA5, 0x00F7CBBD, 0x00DEAEA5, 0x00F7C7B5},
- {0x00EFC7B5, 0x00E7AE94, 0x00EFC7B5, 0x00DEA68C},
- {0x00FFE3D6, 0x00F7CBBD, 0x00FFE3D6, 0x00F7C7B5},
- {0x00DEE7E7, 0x00DEE7E7, 0x00DEE3E7, 0x00DEE3E7},
- {0x00F7CBBD, 0x00F7CBBD, 0x00DE8273, 0x00F7C7B5},
- {0x00EFC7B5, 0x00EFC7B5, 0x00E7AE94, 0x00DEA68C},
- {0x00F7CBBD, 0x00F7CBBD, 0x00F7C3AD, 0x00F7C7B5},
- };
- if (lState & CXPH_HASFRAME)
- {
-
-
- Rect.right--;Rect.bottom--;
- FrameRect(hDC, &Rect, (HBRUSH )GetStockObject(WHITE_BRUSH));
- hHandle = (HANDLE) SelectObject(hDC,
- CreatePen(PS_SOLID, 1, (lState & CXPS_DISABLED) ? 0x00BDCFCE : 0x00D6B69C));
- MoveToEx(hDC, Rect.right, Rect.top + 2, NULL);
- LineTo(hDC, Rect.right, Rect.bottom - 2);
- LineTo(hDC, Rect.right - 2, Rect.bottom);
- LineTo(hDC, Rect.left + 1, Rect.bottom);
- LineTo(hDC, Rect.left - 1, Rect.bottom - 2);
- DeleteObject(SelectObject(hDC, (HGDIOBJ) hHandle));
- InflateRect(&Rect, -1, -1);
- }
-
- if (lState & CXPS_DISABLED)
- i = 0;
- else if (lState & CXPS_PRESSED)
- i = 1;
- else if (lState & CXPS_HOTLIGHT)
- i = 2;
- else
- i = 3;
- if(lState & CXPH_AREA)
- {
- i += 12;
- if(lState & CXPS_HORIZON)
- {i += 4;
- GradientRectXP(hDC, &Rect, s_crGradientXP[i]);
-
-
- }
- else
- {
- GradientRectXP(hDC, &Rect, s_crGradientXP[i]);
- }
- return;
- }
- else
- {
- GradientRectXP(hDC, &Rect, s_crGradientXP[i]);
-
- SetPixel(hDC, Rect.left, Rect.top, s_crGradientXP[i + 4][0]);
- SetPixel(hDC, Rect.right - 1, Rect.top, s_crGradientXP[i + 4][1]);
- SetPixel(hDC, Rect.left, Rect.bottom - 1, s_crGradientXP[i + 4][2]);
- SetPixel(hDC, Rect.right - 1, Rect.bottom - 1, s_crGradientXP[i + 4][3]);
-
- InflateRect(&Rect, -1, -1);
- GradientRectXP(hDC, &Rect, s_crGradientXP[i + 8]);
- }
-
- Rect.left += (Rect.right - Rect.left) / 2;
- Rect.top += (Rect.bottom - Rect.top) / 2;
-
- if (lState & CXPH_DROPHANDLE)
- {
- hHandle = (HANDLE) SelectObject(hDC, CreatePen(PS_SOLID, 1, 0x00FFF7EF));
- for (i = -4; i <= 2; i += 2)
- {
- if (lState & CXPS_HORIZON)
- {
- MoveToEx(hDC, Rect.left + i, Rect.top - 3, NULL);
- LineTo(hDC, Rect.left + i, Rect.top + 3);
- }
- else
- {
- MoveToEx(hDC, Rect.left - 3, Rect.top + i, NULL);
- LineTo(hDC, Rect.left + 3, Rect.top + i);
- }
- }
- DeleteObject(SelectObject(hDC, (HGDIOBJ) hHandle));
- hHandle = (HANDLE) SelectObject(hDC, CreatePen(PS_SOLID, 1, 0x00FFB28C));
- for (i = -3; i <= 3; i += 2)
- {
- if (lState & CXPS_HORIZON)
- {
- MoveToEx(hDC, Rect.left + i, Rect.top - 2, NULL);
- LineTo(hDC, Rect.left + i, Rect.top + 4);
- }
- else
- {
- MoveToEx(hDC, Rect.left - 2, Rect.top + i, NULL);
- LineTo(hDC, Rect.left + 4, Rect.top + i);
- }
- }
- DeleteObject(SelectObject(hDC, (HGDIOBJ) hHandle));
- }
- else
- {
- hHandle = (HANDLE) SelectObject(hDC,
- CreatePen(PS_SOLID, 1, (lState & CXPS_DISABLED) ? 0x00C6CBCE : 0x0084614A));
- if (lState & CXPH_SMALLARROW)
- {
- if (lState & CXPH_LEFTWARDS)
- {
- MoveToEx(hDC, Rect.left - 2, Rect.top, NULL);
- LineTo(hDC, Rect.left - 2, Rect.top + 1);
- MoveToEx(hDC, Rect.left - 1, Rect.top - 1, NULL);
- LineTo(hDC, Rect.left - 1, Rect.top + 2);
- MoveToEx(hDC, Rect.left, Rect.top - 2, NULL);
- LineTo(hDC, Rect.left, Rect.top + 3);
- MoveToEx(hDC, Rect.left + 1, Rect.top - 3, NULL);
- LineTo(hDC, Rect.left + 1, Rect.top);
- MoveToEx(hDC, Rect.left + 1, Rect.top + 1, NULL);
- LineTo(hDC, Rect.left + 1, Rect.top + 4);
- }
- else if (lState & CXPH_UPWARDS)
- {
- MoveToEx(hDC, Rect.left - 3, Rect.top + 1, NULL);
- LineTo(hDC, Rect.left, Rect.top + 1);
- MoveToEx(hDC, Rect.left + 1, Rect.top + 1, NULL);
- LineTo(hDC, Rect.left + 4, Rect.top + 1);
- MoveToEx(hDC, Rect.left - 2, Rect.top, NULL);
- LineTo(hDC, Rect.left + 3, Rect.top);
- MoveToEx(hDC, Rect.left - 1, Rect.top - 1, NULL);
- LineTo(hDC, Rect.left + 2, Rect.top - 1);
- MoveToEx(hDC, Rect.left, Rect.top - 2, NULL);
- LineTo(hDC, Rect.left + 1, Rect.top - 2);
- }
- else if (lState & CXPH_RIGHTWARDS)
- {
- MoveToEx(hDC, Rect.left + 2, Rect.top, NULL);
- LineTo(hDC, Rect.left + 2, Rect.top + 1);
- MoveToEx(hDC, Rect.left + 1, Rect.top - 1, NULL);
- LineTo(hDC, Rect.left + 1, Rect.top + 2);
- MoveToEx(hDC, Rect.left, Rect.top - 2, NULL);
- LineTo(hDC, Rect.left, Rect.top + 3);
- MoveToEx(hDC, Rect.left - 1, Rect.top - 3, NULL);
- LineTo(hDC, Rect.left - 1, Rect.top);
- MoveToEx(hDC, Rect.left - 1, Rect.top + 1, NULL);
- LineTo(hDC, Rect.left - 1, Rect.top + 4);
- }
- else if (lState & CXPH_DOWNWARDS)
- {
- MoveToEx(hDC, Rect.left - 3, Rect.top - 1, NULL);
- LineTo(hDC, Rect.left, Rect.top - 1);
- MoveToEx(hDC, Rect.left + 1, Rect.top - 1, NULL);
- LineTo(hDC, Rect.left + 4, Rect.top - 1);
- MoveToEx(hDC, Rect.left - 2, Rect.top, NULL);
- LineTo(hDC, Rect.left + 3, Rect.top);
- MoveToEx(hDC, Rect.left - 1, Rect.top + 1, NULL);
- LineTo(hDC, Rect.left + 2, Rect.top + 1);
- MoveToEx(hDC, Rect.left, Rect.top + 2, NULL);
- LineTo(hDC, Rect.left + 1, Rect.top + 2);
- }
- }
- else if (lState & CXPH_LARGEARROW)
- {
- if (lState & CXPH_LEFTWARDS)
- {
- MoveToEx(hDC, Rect.left + 1, Rect.top - 4, NULL);
- LineTo(hDC, Rect.left - 3, Rect.top);
- LineTo(hDC, Rect.left + 2, Rect.top + 5);
- MoveToEx(hDC, Rect.left + 1, Rect.top - 3, NULL);
- LineTo(hDC, Rect.left - 2, Rect.top);
- LineTo(hDC, Rect.left + 2, Rect.top + 4);
- MoveToEx(hDC, Rect.left + 2, Rect.top - 3, NULL);
- LineTo(hDC, Rect.left - 1, Rect.top);
- LineTo(hDC, Rect.left + 3, Rect.top + 4);
- }
- else if (lState & CXPH_UPWARDS)
- {
- MoveToEx(hDC, Rect.left - 4, Rect.top + 1, NULL);
- LineTo(hDC, Rect.left, Rect.top - 3);
- LineTo(hDC, Rect.left + 5, Rect.top + 2);
- MoveToEx(hDC, Rect.left - 3, Rect.top + 1, NULL);
- LineTo(hDC, Rect.left, Rect.top - 2);
- LineTo(hDC, Rect.left + 4, Rect.top + 2);
- MoveToEx(hDC, Rect.left - 3, Rect.top + 2, NULL);
- LineTo(hDC, Rect.left, Rect.top - 1);
- LineTo(hDC, Rect.left + 4, Rect.top + 3);
- }
- else if (lState & CXPH_RIGHTWARDS)
- {
- MoveToEx(hDC, Rect.left - 1, Rect.top - 4, NULL);
- LineTo(hDC, Rect.left + 3, Rect.top);
- LineTo(hDC, Rect.left - 2, Rect.top + 5);
- MoveToEx(hDC, Rect.left - 1, Rect.top - 3, NULL);
- LineTo(hDC, Rect.left + 2, Rect.top);
- LineTo(hDC, Rect.left - 2, Rect.top + 4);
- MoveToEx(hDC, Rect.left - 2, Rect.top - 3, NULL);
- LineTo(hDC, Rect.left + 1, Rect.top);
- LineTo(hDC, Rect.left - 3, Rect.top + 4);
- }
- else if (lState & CXPH_DOWNWARDS)
- {
- MoveToEx(hDC, Rect.left - 4, Rect.top - 2, NULL);
- LineTo(hDC, Rect.left, Rect.top + 2);
- LineTo(hDC, Rect.left + 5, Rect.top - 3);
- MoveToEx(hDC, Rect.left - 3, Rect.top - 2, NULL);
- LineTo(hDC, Rect.left, Rect.top + 1);
- LineTo(hDC, Rect.left + 4, Rect.top - 3);
- MoveToEx(hDC, Rect.left - 3, Rect.top - 3, NULL);
- LineTo(hDC, Rect.left, Rect.top);
- LineTo(hDC, Rect.left + 4, Rect.top - 4);
- }
- }
- DeleteObject(SelectObject(hDC, (HGDIOBJ) hHandle));
- }
- }
- void ScrollDrawButton(PCLASSXP pCxp, HDC hDC, RECT Rect,
- DWORD dwStyle, int nType)
- {
- PSCROLLXP pXP;
- pXP = (PSCROLLXP)pCxp->pData;
- }
- void ScrollCalVertical(PCLASSXP pCxp, SCROLLINFO sif, RECT Rect)
- {
- PSCROLLXP pXP;
- pXP = (PSCROLLXP)pCxp->pData;
- if(pXP->m_bDragging)sif.nPos = pXP->m_nThumbTrackPos;
- int ThumbWidth = 30;
- if(ThumbWidth > pXP->m_AreaRect.bottom - pXP->m_AreaRect.top)
- ThumbWidth = (pXP->m_AreaRect.bottom - pXP->m_AreaRect.top)/2;
- double height = pXP->m_AreaRect.bottom - pXP->m_AreaRect.top - ThumbWidth;
- double range = sif.nMax - sif.nMin;
- double per = height / range;
- int pos = (int)(per * (sif.nPos - sif.nMin));
-
- if( range <= 0)
- return;
- pXP->m_ThumbRect.left = Rect.left;
- pXP->m_ThumbRect.top = pXP->m_AreaRect.top + pos;
- pXP->m_ThumbRect.right = Rect.right;
- pXP->m_ThumbRect.bottom = pXP->m_ThumbRect.top + ThumbWidth;
- InflateRect(&pXP->m_ThumbRect, -2, -1);
- }
- void ScrollDrawVertical(PCLASSXP pCxp, long nType)
- {
- BOOL IsWindowEnable;
- RECT Rect;
- HWND hWnd;
- PSCROLLXP pXP;
- HDC hDC;
- long lState;
- pXP = (PSCROLLXP)pCxp->pData;
- hWnd = pCxp->hWnd;
- GetWindowRect(hWnd, &Rect);
- Rect.right -= Rect.left;
- Rect.bottom -= Rect.top;
- Rect.left = Rect.top = 0;
- long lSmall = 0;
- IsWindowEnable = IsWindowEnabled(hWnd);
- SCROLLINFO sif;
- ZeroMemory(&sif, sizeof(SCROLLINFO));
- sif.cbSize = sizeof(SCROLLINFO);
- sif.fMask = SIF_ALL;
- if(!GetScrollInfo(hWnd, SB_CTL, &sif))
- return;
- if(sif.nMin == sif.nMax)
- return;
- MEMDCXP Mdcxp;
- Mdcxp.hWnd = hWnd;
- Mdcxp.bTransfer = FALSE;
- Mdcxp.hBitmap = NULL;
- GetMemDCXP(&Mdcxp);
- hDC = Mdcxp.hDC;
- if (Rect.bottom-Rect.left < 2*(Rect.right-Rect.left))
- lSmall = CXPH_SMALLARROW;
- pXP->m_TopArrowRect = Rect;
- pXP->m_TopArrowRect.bottom = Rect.top+Rect.right-Rect.left;
- if (nType == SCROLLTOPARROW || nType == SCROLLALL)
- { if(pXP->m_bMouseDownArrowForback)
- ScrollDrowThumbXP(hDC, pXP->m_TopArrowRect, CXPH_LARGEARROW|CXPH_UPWARDS|CXPS_PRESSED|lSmall);
- else
- ScrollDrowThumbXP(hDC, pXP->m_TopArrowRect, CXPH_LARGEARROW|CXPH_UPWARDS|lSmall);
- }
- pXP->m_BottomArrowRect = Rect;
- pXP->m_BottomArrowRect.top = Rect.bottom-(Rect.right-Rect.left);
- if (nType == SCROLLBOTTOMARROW || nType == SCROLLALL)
- { if(pXP->m_bMouseDownArrowForwad)
- ScrollDrowThumbXP(hDC, pXP->m_BottomArrowRect, CXPH_LARGEARROW|CXPH_DOWNWARDS|CXPS_PRESSED|lSmall);
- else
- ScrollDrowThumbXP(hDC, pXP->m_BottomArrowRect, CXPH_LARGEARROW|CXPH_DOWNWARDS|lSmall);
- }
- pXP->m_AreaRect = Rect;
- pXP->m_AreaRect.top = pXP->m_TopArrowRect.bottom;
- pXP->m_AreaRect.bottom = pXP->m_BottomArrowRect.top;
- if (nType == SCROLLALL)
- ScrollDrowThumbXP(hDC, pXP->m_AreaRect, CXPH_HASFRAME|CXPH_AREA);
- else
- ScrollDrowThumbXP(hDC, pXP->m_ThumbRect, CXPH_AREA);
-
- ScrollCalVertical(pCxp,sif, Rect);
- lState = CXPH_LARGEARROW|CXPH_DROPHANDLE|CXPS_HOTLIGHT;
- if (pXP->m_bMouseDown)
- lState |= CXPS_PRESSED;
- if(!lSmall)
- ScrollDrowThumbXP(hDC, pXP->m_ThumbRect, lState);
- ReleaseMemDCXP(&Mdcxp);
- }
- void ScrollCalHorizontal(PCLASSXP pCxp, SCROLLINFO sif, RECT Rect)
- {
- PSCROLLXP pXP;
- pXP = (PSCROLLXP)pCxp->pData;
- if(pXP->m_bDragging)sif.nPos = pXP->m_nThumbTrackPos;
- int ThumbWidth = 30;
- if(ThumbWidth > (pXP->m_AreaRect.right-pXP->m_AreaRect.left))
- ThumbWidth = (pXP->m_AreaRect.right-pXP->m_AreaRect.left)/ 2;
- double width = (pXP->m_AreaRect.right-pXP->m_AreaRect.left) - ThumbWidth;
- double range = sif.nMax - sif.nMin;
- double per = width / range;
- int pos = (int)(per * (sif.nPos - sif.nMin));
- if(range <= 0)return;
- pXP->m_ThumbRect.left = pXP->m_AreaRect.left + pos;
- pXP->m_ThumbRect.top = Rect.top;
- pXP->m_ThumbRect.right = pXP->m_ThumbRect.left + ThumbWidth;
- pXP->m_ThumbRect.bottom = Rect.bottom;
- if(pXP->m_ThumbRect.right == pXP->m_ThumbRect.left)
- pXP->m_ThumbRect.right = pXP->m_ThumbRect.left + 3;
- InflateRect(&pXP->m_ThumbRect, -1, -3);
- }
- void ScrollDrawHorizontal(PCLASSXP pCxp, long nType)
- {
- BOOL IsWindowEnable;
- RECT Rect;
- HWND hWnd;
- PSCROLLXP pXP;
- HDC hDC;
- long lState;
- pXP = (PSCROLLXP)pCxp->pData;
- hWnd = pCxp->hWnd;
- GetWindowRect(hWnd, &Rect);
- Rect.right -= Rect.left;
- Rect.bottom -= Rect.top;
- Rect.left = Rect.top = 0;
-
- IsWindowEnable = IsWindowEnabled(hWnd);
- SCROLLINFO sif;
- ZeroMemory(&sif, sizeof(SCROLLINFO));
- sif.cbSize = sizeof(SCROLLINFO);
- sif.fMask = SIF_ALL;
- if(!GetScrollInfo(hWnd, SB_CTL, &sif))
- return;
- if(sif.nMin == sif.nMax)
- return;
- MEMDCXP Mdcxp;
- Mdcxp.hWnd = hWnd;
- Mdcxp.bTransfer = FALSE;
- Mdcxp.hBitmap = NULL;
- GetMemDCXP(&Mdcxp);
- hDC = Mdcxp.hDC;
- pXP->m_LeftArrowRect = Rect;
- pXP->m_LeftArrowRect.right = Rect.left+Rect.bottom-Rect.top;
- if (nType == SCROLLLEFTARROW || nType == SCROLLALL)
- { if(pXP->m_bMouseDownArrowForback)
- ScrollDrowThumbXP(hDC, pXP->m_LeftArrowRect, CXPH_LARGEARROW|CXPH_LEFTWARDS|CXPS_PRESSED);
- else
- ScrollDrowThumbXP(hDC, pXP->m_LeftArrowRect, CXPH_LARGEARROW|CXPH_LEFTWARDS);
- }
- pXP->m_RightArrowRect = Rect;
- pXP->m_RightArrowRect.left = Rect.right-(Rect.bottom-Rect.top);
- if (nType == SCROLLRIGHTARROW || nType == SCROLLALL)
- { if(pXP->m_bMouseDownArrowForwad)
- ScrollDrowThumbXP(hDC, pXP->m_RightArrowRect, CXPH_LARGEARROW|CXPH_RIGHTWARDS|CXPS_PRESSED);
- else
- ScrollDrowThumbXP(hDC, pXP->m_RightArrowRect, CXPH_LARGEARROW|CXPH_RIGHTWARDS);
- }
- pXP->m_AreaRect = Rect;
- pXP->m_AreaRect.left = pXP->m_LeftArrowRect.right;
- pXP->m_AreaRect.right = pXP->m_RightArrowRect.left;
- if (nType == SCROLLALL)
- ScrollDrowThumbXP(hDC, pXP->m_AreaRect, CXPS_HORIZON|CXPH_HASFRAME|CXPH_AREA);
- else
- ScrollDrowThumbXP(hDC, pXP->m_ThumbRect,CXPS_HORIZON|CXPH_AREA);
- ScrollCalHorizontal(pCxp,sif, Rect);
- lState = CXPS_HOTLIGHT|CXPH_DROPHANDLE|CXPS_HORIZON;
- if (pXP->m_bMouseDown)
- lState |= CXPS_PRESSED;
- ScrollDrowThumbXP(hDC, pXP->m_ThumbRect, lState);
- ReleaseMemDCXP(&Mdcxp);
- }
- void ScrollOnLButtonDown(PCLASSXP pCxp,WPARAM wParam,LPARAM lParam)
- {
- SCROLLINFO sif;
- POINT point;
- PSCROLLXP pXP;
- HWND hWnd, hParent;
- HDC hDC;
- DWORD dwStyle;
- pXP = (PSCROLLXP)pCxp->pData;
- hWnd = pCxp->hWnd;
- point.x = LOWORD(lParam);
- point.y = HIWORD(lParam);
- SetCapture(hWnd);
- dwStyle = (DWORD)GetWindowLong(pCxp->hWnd, GWL_STYLE);
- hParent = GetParent(hWnd);
- if((dwStyle & SBS_VERT)==SBS_VERT)
- {
- if(PtInRect(&pXP->m_ThumbRect,point))
- {
- pXP->m_bMouseDown = true;
- pXP->m_MouseDownPoint.x = point.x - pXP->m_ThumbRect.left;
- pXP->m_MouseDownPoint.y = point.y - pXP->m_ThumbRect.top;
- hDC = GetDC(pCxp->hWnd);
-
-
- ScrollDrowThumbXP(hDC, pXP->m_ThumbRect,
- CXPH_LARGEARROW|CXPH_DROPHANDLE|CXPS_PRESSED);
-
-
- ReleaseDC(hWnd,hDC);
- }
- else if(PtInRect(&pXP->m_BottomArrowRect,point))
- {
- pXP->m_bMouseDownArrowForwad = true;
-
-
- SendMessage(hWnd,WM_SETREDRAW,FALSE,0);
- SendMessage(hParent,WM_VSCROLL,MAKEWPARAM(SB_LINEDOWN,0),(LPARAM)hWnd);
- SendMessage(hWnd,WM_SETREDRAW,TRUE,0);
- ScrollDrawVertical(pCxp, SCROLLBOTTOMARROW);
-
-
- }
- else if(PtInRect(&pXP->m_TopArrowRect,point))
- {
- pXP->m_bMouseDownArrowForback = true;
-
-
- SendMessage(hWnd,WM_SETREDRAW,FALSE,0);
- SendMessage(hParent,WM_VSCROLL,MAKEWPARAM(SB_LINEUP,0),(LPARAM)hWnd);
- SendMessage(hWnd,WM_SETREDRAW,TRUE,0);
- ScrollDrawVertical(pCxp, SCROLLTOPARROW);
-
-
-
- }
- else if(PtInRect(&pXP->m_AreaRect,point))
- {
- if(hParent != NULL)
- {
- ZeroMemory(&sif,sizeof(sif));
- sif.cbSize = sizeof(sif);
- sif.fMask = SIF_ALL;
- GetScrollInfo(hWnd, SB_CTL, &sif);
-
- if(point.y < pXP->m_ThumbRect.top)
- {
- pXP->m_bMouseDownArrowForback = TRUE;
- SendMessage(hWnd,WM_SETREDRAW,FALSE,0);
- SendMessage(hParent,WM_VSCROLL,MAKEWPARAM(SB_PAGEUP,0),(LPARAM)hWnd);
- SendMessage(hWnd,WM_SETREDRAW,TRUE,0);
- ScrollDrawVertical(pCxp, SCROLLAREANULL);
- }
- else
- {
- pXP->m_bMouseDownArrowForwad = TRUE;
- SendMessage(hWnd,WM_SETREDRAW,FALSE,0);
- SendMessage(hParent,WM_VSCROLL,MAKEWPARAM(SB_PAGEDOWN,0),(LPARAM)hWnd);
- SendMessage(hWnd,WM_SETREDRAW,TRUE,0);
- ScrollDrawVertical(pCxp, SCROLLAREANULL);
- }
- }
-
- }
- }
- else
- {
- if(PtInRect(&pXP->m_ThumbRect,point))
- {
- pXP->m_bMouseDown = true;
- pXP->m_MouseDownPoint.x = point.x - pXP->m_ThumbRect.left;
- pXP->m_MouseDownPoint.y = point.y - pXP->m_ThumbRect.top;
- pXP->m_bDragging = true;
-
- hDC = GetDC(pCxp->hWnd);
- ScrollDrowThumbXP(hDC, pXP->m_ThumbRect, CXPS_HORIZON|
- CXPH_LARGEARROW|CXPH_DROPHANDLE|CXPS_PRESSED);
- ReleaseDC(hWnd,hDC);
- }
- else if(PtInRect(&pXP->m_RightArrowRect,point))
- {
- pXP->m_bMouseDownArrowForwad = true;
- SendMessage(hWnd,WM_SETREDRAW,FALSE,0);
- SendMessage(hParent,WM_HSCROLL,MAKEWPARAM(SB_LINERIGHT,0),(LPARAM)hWnd);
- SendMessage(hWnd,WM_SETREDRAW,TRUE,0);
- ScrollDrawHorizontal(pCxp, SCROLLRIGHTARROW);
-
- }
- else if(PtInRect(&pXP->m_LeftArrowRect,point))
- {
- pXP->m_bMouseDownArrowForback = true;
- SendMessage(hWnd,WM_SETREDRAW,FALSE,0);
- SendMessage(hParent,WM_HSCROLL,MAKEWPARAM(SB_LINELEFT,0),(LPARAM)hWnd);
- SendMessage(hWnd,WM_SETREDRAW,TRUE,0);
- ScrollDrawHorizontal(pCxp, SCROLLLEFTARROW);
- }
- else if(PtInRect(&pXP->m_AreaRect,point))
- {
- if(hParent != NULL)
- {
- ZeroMemory(&sif,sizeof(sif));
- sif.cbSize = sizeof(sif);
- sif.fMask = SIF_ALL;
- GetScrollInfo(hWnd, SB_CTL, &sif);
- if(point.x < pXP->m_ThumbRect.left)
- {
- pXP->m_bMouseDownArrowForback = TRUE;
- SendMessage(hWnd,WM_SETREDRAW,FALSE,0);
- SendMessage(hParent,WM_HSCROLL,MAKEWPARAM(SB_PAGELEFT,0),(LPARAM)hWnd);
- SendMessage(hWnd,WM_SETREDRAW,TRUE,0);
- ScrollDrawHorizontal(pCxp, SCROLLAREANULL);
- }
- else
- {
- pXP->m_bMouseDownArrowForwad = TRUE;
- SendMessage(hWnd,WM_SETREDRAW,FALSE,0);
- SendMessage(hParent,WM_HSCROLL,MAKEWPARAM(SB_PAGERIGHT,0),(LPARAM)hWnd);
- SendMessage(hWnd,WM_SETREDRAW,TRUE,0);
- ScrollDrawHorizontal(pCxp, SCROLLAREANULL);
- }
- }
- }
- }
- }
- void ScrollOnLButtonUp(PCLASSXP pCxp,WPARAM wParam,LPARAM lParam)
- {
- POINT point, mousePoint;
- PSCROLLXP pXP;
- HWND hWnd, hParent;
- HDC hDC;
- DWORD dwStyle;
- SCROLLINFO sif;
- pXP = (PSCROLLXP)pCxp->pData;
- pXP->m_MouseDownTime = 0;
- hWnd = pCxp->hWnd;
- point.x = LOWORD(lParam);
- point.y = HIWORD(lParam);
- ReleaseCapture();
-
- dwStyle = (DWORD)GetWindowLong(pCxp->hWnd, GWL_STYLE);
- hParent = GetParent(hWnd);
- if(pXP->m_bDragging)
- {
- pXP->m_bDragging = FALSE;
- pXP->m_bMouseDown = FALSE;
- mousePoint.x = pXP->m_ThumbRect.left + pXP->m_MouseDownPoint.x;
- mousePoint.y= pXP->m_ThumbRect.top + pXP->m_MouseDownPoint.y;
- if( (dwStyle & SBS_VERT) == SBS_VERT)
- {
- if(mousePoint.y != point.y)
- {
- int move = point.y - mousePoint.y;
- double pos = pXP->m_ThumbRect.top + move - pXP->m_AreaRect.top;
- double height = (pXP->m_AreaRect.bottom-pXP->m_AreaRect.top) -
- (pXP->m_ThumbRect.bottom-pXP->m_ThumbRect.top);
- double per = pos / height;
-
- ZeroMemory(&sif,sizeof(sif));
- sif.cbSize = sizeof(SCROLLINFO);
- sif.fMask = SIF_ALL;
- GetScrollInfo(hWnd, SB_CTL, &sif);
- int newpos = (int)((sif.nMax - sif.nMin) * per);
- if(newpos < sif.nMin)newpos = sif.nMin;
- if(newpos > sif.nMax)newpos = sif.nMax;
- if(hParent != NULL)
- {
- SendMessage(hWnd,WM_SETREDRAW,FALSE,0);
- SendMessage(hParent,WM_VSCROLL,MAKEWPARAM(SB_THUMBPOSITION,newpos),(LPARAM)hWnd);
- SendMessage(hWnd,WM_SETREDRAW,TRUE,0);
- }
-
- }
- ScrollDrawVertical(pCxp, SCROLLALL);
- }
- else
- {
- if(mousePoint.x != point.x)
- {
- int move = point.x - mousePoint.x;
- double pos = pXP->m_ThumbRect.left + move - pXP->m_AreaRect.left;
- double width = (pXP->m_AreaRect.right-pXP->m_AreaRect.left) -
- (pXP->m_ThumbRect.right-pXP->m_ThumbRect.left);
- double per = pos / width;
- ZeroMemory(&sif,sizeof(sif));
- sif.cbSize = sizeof(SCROLLINFO);
- sif.fMask = SIF_ALL;
- GetScrollInfo(hWnd, SB_CTL, &sif);
- int newpos = (int)((sif.nMax - sif.nMin) * per);
- if(newpos < sif.nMin)newpos = sif.nMin;
- if(newpos > sif.nMax)newpos = sif.nMax;
- if(hParent != NULL)
- {
- SendMessage(hWnd,WM_SETREDRAW,FALSE,0);
- SendMessage(hParent,WM_HSCROLL,MAKEWPARAM(SB_THUMBPOSITION,newpos),(LPARAM)hWnd);
- SendMessage(hWnd,WM_SETREDRAW,TRUE,0);
- }
- }
- ScrollDrawHorizontal(pCxp, SCROLLALL);
- }
- }
- else if (pXP->m_bMouseDown)
- {
- hDC = GetDC(pCxp->hWnd);
- pXP->m_bMouseDown = false;
- if ((dwStyle & SBS_VERT) == SBS_VERT)
- ScrollDrowThumbXP(hDC, pXP->m_ThumbRect,CXPS_HOTLIGHT|CXPH_DROPHANDLE);
- else
- ScrollDrowThumbXP(hDC, pXP->m_ThumbRect,CXPS_HOTLIGHT|CXPH_DROPHANDLE|CXPS_HORIZON);
- ReleaseDC(hWnd,hDC);
- }
- else if (pXP->m_bMouseDownArrowForback&&
- (dwStyle & SBS_VERT) == SBS_VERT)
- {
- hDC = GetDC(pCxp->hWnd);
- pXP->m_bMouseDownArrowForback = false;
- ScrollDrowThumbXP(hDC, pXP->m_TopArrowRect, CXPH_LARGEARROW|CXPH_UPWARDS);
- ReleaseDC(hWnd,hDC);
- }
- else if (pXP->m_bMouseDownArrowForwad &&
- (dwStyle & SBS_VERT) == SBS_VERT)
- {
- hDC = GetDC(pCxp->hWnd);
- pXP->m_bMouseDownArrowForwad = false;
- ScrollDrowThumbXP(hDC, pXP->m_BottomArrowRect, CXPH_LARGEARROW|CXPH_DOWNWARDS);
- ReleaseDC(hWnd,hDC);
- }
- else if (pXP->m_bMouseDownArrowForback&&
- (dwStyle & SBS_HORZ) == SBS_HORZ)
- {
- hDC = GetDC(pCxp->hWnd);
- pXP->m_bMouseDownArrowForback = false;
- ScrollDrowThumbXP(hDC, pXP->m_LeftArrowRect, CXPH_LARGEARROW|CXPH_LEFTWARDS);
- ReleaseDC(hWnd,hDC);
- }
- else if (pXP->m_bMouseDownArrowForwad&&
- (dwStyle & SBS_HORZ) == SBS_HORZ)
- {
- hDC = GetDC(pCxp->hWnd);
- pXP->m_bMouseDownArrowForwad = false;
- ScrollDrowThumbXP(hDC, pXP->m_RightArrowRect, CXPH_LARGEARROW|CXPH_RIGHTWARDS);
- ReleaseDC(hWnd,hDC);
- }
- if(pXP->m_bMouseDown ||
- pXP->m_bMouseDownArrowForback ||
- pXP->m_bMouseDownArrowForwad)
- {
- pXP->m_bMouseDown = FALSE;
- pXP->m_bMouseDownArrowForback = FALSE;
- pXP->m_bMouseDownArrowForwad = FALSE;
-
-
-
-
-
-
- }
- }
- void ScrollOnMouseMove(PCLASSXP pCxp, WPARAM wParam, LPARAM lParam)
- {
- POINT point, mousePoint;
- PSCROLLXP pXP;
- HWND hWnd, hParent;
- RECT Rect;
- HDC hDC;
- DWORD dwStyle;
- SCROLLINFO sif;
- pXP = (PSCROLLXP)pCxp->pData;
- hWnd = pCxp->hWnd;
- point.x = LOWORD(lParam);
- point.y = HIWORD(lParam);
- dwStyle = (DWORD)GetWindowLong(pCxp->hWnd, GWL_STYLE);
- GetWindowRect(hWnd, &Rect);
- Rect.right -= Rect.left;
- Rect.bottom -= Rect.top;
- Rect.left = Rect.top = 0;
- hParent = GetParent(hWnd);
-
- if(hParent == NULL)return;
- if(pXP->m_bMouseDown)pXP->m_bDragging = TRUE;
- if(!pXP->m_bDragging)return;
- mousePoint.x = pXP->m_ThumbRect.left + pXP->m_MouseDownPoint.x;
- mousePoint.y = pXP->m_ThumbRect.top + pXP->m_MouseDownPoint.y;
- if( (dwStyle & SBS_VERT) == SBS_VERT)
- {
- if(mousePoint.y == point.y)return;
-
- int move = point.y - mousePoint.y;
- double pos = pXP->m_ThumbRect.top + move - pXP->m_AreaRect.top;
- double height = (pXP->m_AreaRect.bottom-pXP->m_AreaRect.top) -
- (pXP->m_ThumbRect.bottom-pXP->m_ThumbRect.top);
- double per = pos / height;
- ZeroMemory(&sif,sizeof(sif));
- sif.cbSize = sizeof(SCROLLINFO);
- sif.fMask = SIF_ALL;
- GetScrollInfo(hWnd, SB_CTL, &sif);
- int newpos = (int)((sif.nMax - sif.nMin) * per);
- if(newpos < sif.nMin) newpos = sif.nMin;
- if(newpos > sif.nMax) newpos = sif.nMax;
- sif.nTrackPos = newpos;
- if(pXP->m_nThumbTrackPos != newpos)
- {
- SendMessage(hWnd,WM_SETREDRAW,FALSE,0);
- SendMessage(hParent,WM_VSCROLL,MAKEWPARAM(SB_THUMBTRACK,sif.nTrackPos),(LPARAM)hWnd);
- SendMessage(hWnd,WM_SETREDRAW,TRUE,0);
- hDC = GetDC(hWnd);
- ScrollDrowThumbXP(hDC, pXP->m_ThumbRect, CXPH_AREA);
- pXP->m_nThumbTrackPos = newpos;
- ScrollCalVertical(pCxp,sif, Rect);
- ScrollDrowThumbXP(hDC, pXP->m_ThumbRect, CXPS_PRESSED|
- CXPH_LARGEARROW|CXPH_DROPHANDLE);
- ReleaseDC(hWnd,hDC);
- }
- }
- else
- {
- if(mousePoint.x == point.x)return;
-
- int move = point.x - mousePoint.x;
- double pos = pXP->m_ThumbRect.left + move - pXP->m_AreaRect.left;
- double width = (pXP->m_AreaRect.right-pXP->m_AreaRect.left) -
- (pXP->m_ThumbRect.right-pXP->m_ThumbRect.left);
- double per = pos / width;
- ZeroMemory(&sif,sizeof(sif));
- sif.cbSize = sizeof(SCROLLINFO);
- sif.fMask = SIF_ALL;
- GetScrollInfo(hWnd, SB_CTL, &sif);
- int newpos = (int)((sif.nMax - sif.nMin) * per);
- if(newpos < sif.nMin) newpos = sif.nMin;
- if(newpos > sif.nMax) newpos = sif.nMax;
- sif.nTrackPos = newpos;
- if(pXP->m_nThumbTrackPos != newpos)
- {
-
- SendMessage(hWnd,WM_SETREDRAW,FALSE,0);
- SendMessage(hParent,WM_HSCROLL,MAKEWPARAM(SB_THUMBTRACK,sif.nTrackPos),(LPARAM)hWnd);
- SendMessage(hWnd,WM_SETREDRAW,TRUE,0);
- hDC = GetDC(hWnd);
- ScrollDrowThumbXP(hDC, pXP->m_ThumbRect, CXPS_HORIZON|CXPH_AREA);
- pXP->m_nThumbTrackPos = newpos;
- ScrollCalHorizontal(pCxp,sif, Rect);
- ScrollDrowThumbXP(hDC, pXP->m_ThumbRect, CXPS_PRESSED|
- CXPH_LARGEARROW|CXPH_DROPHANDLE|CXPS_HORIZON);
- ReleaseDC(hWnd,hDC);
- }
- }
- }
- void CALLBACK ScrollOnTimer(PCLASSXP pCxp, UINT nIDEvent)
- {
- }
- void ScrollOnPaint(PCLASSXP pCxp)
- {
-
-
- DWORD dwStyle = (DWORD)GetWindowLong(pCxp->hWnd, GWL_STYLE);
- if( (dwStyle & SBS_VERT) == SBS_VERT)
- {
- ScrollDrawVertical(pCxp, SCROLLALL);
- }
- else
- {
- ScrollDrawHorizontal(pCxp, SCROLLALL);
- }
-
- }
- void ScrollOnLButtonDblClk(PCLASSXP pCxp,WPARAM wParam, LPARAM lParam)
- {
- ScrollOnLButtonDown(pCxp,wParam,lParam);
- ScrollOnLButtonUp(pCxp,wParam,lParam);
- }
- LRESULT ScrollWindowProc(PCLASSXP pCxp, UINT message,WPARAM wParam, LPARAM lParam)
- {
- LONG lReturn;
- HWND hWnd = pCxp->hWnd;
- switch (message)
- {
- case WM_LBUTTONDBLCLK :
- ScrollOnLButtonDblClk(pCxp, wParam,lParam);
- return 0;
- case WM_LBUTTONDOWN:
- ScrollOnLButtonDown(pCxp, wParam,lParam);
- return 0;
- case WM_LBUTTONUP:
- ScrollOnLButtonUp(pCxp, wParam,lParam);
- return 0;
- case WM_MOUSEMOVE:
- ScrollOnMouseMove(pCxp, wParam,lParam);
- return 0;
- case WM_ERASEBKGND:
- return TRUE;
- case WM_TIMER:
- ScrollOnTimer(pCxp, (UINT )wParam);
- lReturn = DefWindowProc(hWnd, message, wParam, lParam);
- return lReturn;
- break;
- case WM_NCPAINT:
- return 0;
- case WM_PAINT:
- lReturn = DefWindowProc(hWnd, message, wParam, lParam);
- ScrollOnPaint(pCxp);
- return lReturn;
- }
-
-
- lReturn = (LONG) CallWindowProc(pCxp->wpPrev, hWnd, message, wParam, lParam);
- if (message == WM_NCDESTROY)
- DeleteClassXP(hWnd);
- return lReturn;
- }
- #ifdef __cplusplus
- }
- #endif
|