123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420 |
- #include "stdafx.h"
- #include <windows.h>
- #include <commctrl.h>
- #include "coolscroll.h"
- UINT CALLBACK CoolSB_DrawProc(HDC hdc, UINT uCmdId, UINT uButflags, RECT *rect);
- extern HWND hwndScroll;
- extern BOOL fCustomDraw ;
- extern BOOL fButtons ;
- extern BOOL fThumbAlways ;
- extern HDC hdcCoolSkin;
- HPEN hpen, oldpen;
- HPEN whitepen;
- HFONT hfont;
- HENHMETAFILE hemf=0;
- typedef struct
- {
- int x, y;
- int width, height;
- } CustomDrawTable;
- CustomDrawTable cdt_horz_normal[] =
- {
- { 0, 0, 16, 16 },
- { 0, 17, 16, 16 },
- { 0, 75, 1, 16 },
- { 0, 75, 1, 16 },
-
- { -1, -1, -1, -1 },
- { 48, 0, 3, 16 },
- { 52, 0, 8, 16 },
- { 61, 0, 3, 16 },
- { 50, 0, 2, 16 },
- };
- CustomDrawTable cdt_horz_hot[] =
- {
- { 16, 0, 16, 16 },
- { 16, 18, 16, 16 },
- { 4, 75, 1, 16 },
- { 4, 75, 1, 16 },
- { -1, -1, -1, -1 },
- { 54, 17, 8, 16 },
- { 54+8, 17, 1, 16 },
- { 54+8, 17, 8, 16 },
- };
- CustomDrawTable cdt_horz_active[] =
- {
- { 32, 0, 16, 16 },
- { 32, 17, 16, 16 },
- { 4, 75, 1, 16 },
- { 4, 75, 1, 16 },
- { -1, -1, -1, -1 },
- { 54, 32, 8, 16 },
- { 54+8, 32, 1, 16 },
- { 54+8, 32, 8, 16 },
- };
- CustomDrawTable cdt_vert_normal[] =
- {
- { 64, 0, 16, 16 },
- { 64, 16, 16, 16 },
- { 0, 100, 16, 1 },
- { 0, 100, 16, 1 },
- { -1, -1, -1, -1 },
- { 112, 0, 16, 3 },
- { 112, 4, 16, 8 },
- { 112, 13, 16, 3 },
- { 112, 2, 16, 2 },
- };
- CustomDrawTable cdt_vert_hot[] =
- {
- { 80, 0, 16, 16 },
- { 80, 17, 16, 16 },
- { 4, 75, 16, 1 },
- { 4, 75, 16, 1 },
- { -1, -1, -1, -1 },
- { 112, 15, 16, 8 },
- { 112, 24, 16, 1 },
- { 112, 24, 16, 8 },
- };
- CustomDrawTable cdt_vert_active[] =
- {
- { 96, 0, 16, 16 },
- { 96, 17, 16, 16 },
- { 4, 75, 16, 1 },
- { 4, 75, 16, 1 },
- { -1, -1, -1, -1 },
- { 112, 32, 16, 8 },
- { 112, 41, 16, 1 },
- { 112, 41, 16, 8 },
- };
- LRESULT HandleCustomDraw(UINT ctrlid, NMCSBCUSTOMDRAW *nm)
- {
- RECT *rc;
- CustomDrawTable *cdt;
- UINT code = NM_CUSTOMDRAW;
- UNREFERENCED_PARAMETER(ctrlid);
- if(nm->dwDrawStage == CDDS_PREPAINT)
- {
- if(fCustomDraw)
- return CDRF_SKIPDEFAULT;
- else
- return CDRF_DODEFAULT;
- }
-
- if(nm->nBar == SB_BOTH)
- {
- RECT *rc = &nm->rect;
-
- StretchBlt(nm->hdc, rc->left, rc->top, rc->right-rc->left, rc->bottom-rc->top,
- hdcCoolSkin, 90, 90, 16, 16, SRCCOPY);
- return CDRF_SKIPDEFAULT;
- }
- if(nm->nBar == SB_HORZ)
- {
- rc = &nm->rect;
-
- cdt = &cdt_horz_normal[nm->uItem];
-
- if(nm->uItem == HTSCROLL_THUMB)
- {
- if(rc->bottom -rc->top >16)
- {
- rc->top =rc->bottom -16;
- rc->left -=1;
- rc->right +=1;
- }
- if(rc->right -rc->left <14)
- {
- if(rc->right -rc->left <3)
- {
- StretchBlt(nm->hdc, rc->left, rc->top, (rc->right-rc->left)/2, 16, hdcCoolSkin, cdt->x, cdt->y, cdt->width, cdt->height, SRCCOPY);
- cdt+=2;
- StretchBlt(nm->hdc, rc->left+(rc->right-rc->left)/2, rc->top,(rc->right-rc->left)/2,16,hdcCoolSkin, cdt->x, cdt->y, cdt->width, cdt->height, SRCCOPY);
- }
- else
- {
- StretchBlt(nm->hdc, rc->left, rc->top, 3, 16, hdcCoolSkin, cdt->x, cdt->y, cdt->width, cdt->height, SRCCOPY);
- cdt+=2;
- StretchBlt(nm->hdc, rc->right -3, rc->top , 3, 16, hdcCoolSkin, cdt->x, cdt->y, cdt->width, cdt->height, SRCCOPY);
- cdt++;
- StretchBlt(nm->hdc, rc->left+3, rc->top, rc->right -rc->left -6,16,hdcCoolSkin, cdt->x, cdt->y, cdt->width, cdt->height, SRCCOPY);
- }
- }
- else
- {
- StretchBlt(nm->hdc, rc->left, rc->top, 3, 16, hdcCoolSkin, cdt->x, cdt->y, cdt->width, cdt->height, SRCCOPY);
- cdt+=2;
- StretchBlt(nm->hdc, rc->right-3, rc->top , 3, 16, hdcCoolSkin, cdt->x, cdt->y, cdt->width, cdt->height, SRCCOPY);
- cdt++;
- StretchBlt(nm->hdc, rc->left+3, rc->top, rc->right-rc->left-6, 16, hdcCoolSkin, cdt->x, cdt->y, cdt->width, cdt->height, SRCCOPY);
- cdt-=2;
- StretchBlt(nm->hdc, rc->left+(rc->right -rc->left -8)/2, rc->top, 8, 16,hdcCoolSkin, cdt->x, cdt->y, cdt->width, cdt->height, SRCCOPY);
- }
- return CDRF_SKIPDEFAULT;
- }
- if(rc->bottom -rc->top >16)
- {
- rc->top =rc->bottom -16;
- if(nm->uItem==0)
- {
- rc->right -=1;
- }
- else if(nm->uItem==1)
- {
- rc->left +=1;
- }
- else if(nm->uItem==2)
- {
- rc->left -=1;
- }
- else if(nm->uItem==3)
- {
- rc->right +=1;
- }
- }
- }
- else if(nm->nBar == SB_VERT)
- {
- rc = &nm->rect;
-
- cdt = &cdt_vert_normal[nm->uItem];
- if(nm->uItem == HTSCROLL_THUMB)
- {
- if(rc->right -rc->left >16)
- {
- rc->left =rc->right -16;
- rc->top-=1;
- rc->bottom +=1;
- }
- if(rc->bottom -rc->top <14)
- {
- if(rc->bottom -rc->top <3)
- {
- StretchBlt(nm->hdc, rc->left, rc->top, 16, (rc->bottom -rc->top)/2, hdcCoolSkin, cdt->x, cdt->y, cdt->width, cdt->height, SRCCOPY);
- cdt+=2;
- StretchBlt(nm->hdc, rc->left, rc->top+(rc->bottom -rc->top)/2, 16, (rc->bottom -rc->top)/2,hdcCoolSkin, cdt->x, cdt->y, cdt->width, cdt->height, SRCCOPY);
- }
- else
- {
- StretchBlt(nm->hdc, rc->left, rc->top, 16, 3, hdcCoolSkin, cdt->x, cdt->y, cdt->width, cdt->height, SRCCOPY);
- cdt+=2;
- StretchBlt(nm->hdc, rc->left, rc->bottom-3, 16, 3, hdcCoolSkin, cdt->x, cdt->y, cdt->width, cdt->height, SRCCOPY);
- cdt++;
- StretchBlt(nm->hdc, rc->left, rc->top+3, 16, rc->bottom -rc->top -6,hdcCoolSkin, cdt->x, cdt->y, cdt->width, cdt->height, SRCCOPY);
- }
- }
- else
- {
- StretchBlt(nm->hdc, rc->left, rc->top, 16, 3, hdcCoolSkin, cdt->x, cdt->y, cdt->width, cdt->height, SRCCOPY);
- cdt+=2;
- StretchBlt(nm->hdc, rc->left, rc->bottom-3, 16, 3, hdcCoolSkin, cdt->x, cdt->y, cdt->width, cdt->height, SRCCOPY);
- cdt++;
- StretchBlt(nm->hdc, rc->left, rc->top+3, 16, rc->bottom-rc->top-6,hdcCoolSkin, cdt->x, cdt->y, cdt->width, cdt->height, SRCCOPY);
- cdt-=2;
- StretchBlt(nm->hdc, rc->left, rc->top+(rc->bottom-rc->top-8)/2, 16, 8,hdcCoolSkin, cdt->x, cdt->y, cdt->width, cdt->height, SRCCOPY);
- }
- return CDRF_SKIPDEFAULT;
- }
- if(rc->right -rc->left >16)
- {
- rc->left =rc->right -16;
- if(nm->uItem==0)
- {
- rc->bottom -=1;
- }
- else if(nm->uItem==1)
- {
- rc->top +=1;
- }
- else if(nm->uItem==2)
- {
- rc->top -=1;
- }
- else if(nm->uItem==3)
- {
- rc->bottom +=1;
- }
- }
- }
- else
- {
- return CDRF_DODEFAULT;
- }
-
- StretchBlt(nm->hdc, rc->left, rc->top, rc->right-rc->left, rc->bottom-rc->top,
- hdcCoolSkin, cdt->x, cdt->y, cdt->width, cdt->height, SRCCOPY);
- return CDRF_SKIPDEFAULT;
- }
- void DrawTab(HDC hdcEMF, int x, int tabwidth, int tabheight, int xslope, BOOL active)
- {
- POINT pts[4];
- pts[0].x = x + 0;
- pts[0].y = 0;
- pts[1].x = x + xslope;
- pts[1].y = tabheight;
- pts[2].x = x + tabwidth - xslope;
- pts[2].y = tabheight;
- pts[3].x = x + tabwidth;
- pts[3].y = 0;
- if(active)
- SelectObject(hdcEMF, GetStockObject(WHITE_BRUSH));
- else
- SelectObject(hdcEMF, GetSysColorBrush(COLOR_3DFACE));
- Polygon(hdcEMF, pts, 4);
- oldpen = (HPEN)SelectObject(hdcEMF, hpen);
-
- MoveToEx(hdcEMF, pts[1].x+1, pts[1].y, 0);
- LineTo(hdcEMF, pts[2].x, pts[2].y);
-
- if(active)
- SelectObject(hdcEMF, whitepen);
- MoveToEx(hdcEMF, pts[3].x - 1, pts[3].y, 0);
- LineTo(hdcEMF, pts[0].x, pts[0].y);
-
- SelectObject(hdcEMF, oldpen);
- }
- void InitMetaFile(void)
- {
- HDC hdcEMF;
- RECT rect;
- int totalwidth = 120;
- int width = 110, height = GetSystemMetrics(SM_CYHSCROLL);
- LOGFONT lf;
- POINT pts[4];
- int tabwidth = 40, tabxslope = 5;
- pts[0].x = 0;
- pts[0].y = 0;
- pts[1].x = tabxslope;
- pts[1].y = height - 1;
- pts[2].x = tabwidth - tabxslope;
- pts[2].y = height - 1;
- pts[3].x = tabwidth;
- pts[3].y = 0;
- hpen = CreatePen(PS_SOLID,0,GetSysColor(COLOR_3DSHADOW));
- whitepen = CreatePen(PS_INSIDEFRAME,0,RGB(0xff,0xff,0xff));
- SetRect(&rect, 0, 0, totalwidth, height+1);
-
- hdcEMF = CreateEnhMetaFile(NULL, NULL, NULL, NULL);
-
- ZeroMemory(&lf, sizeof(lf));
- lf.lfHeight = -MulDiv(7, GetDeviceCaps(hdcEMF, LOGPIXELSY), 72);
- lf.lfPitchAndFamily = DEFAULT_PITCH;
- lf.lfCharSet = ANSI_CHARSET;
- lstrcpy(lf.lfFaceName, "Arial");
- hfont = CreateFontIndirect(&lf);
- pts[0].x = 0;
- pts[0].y = 0;
- pts[1].x = tabxslope;
- pts[1].y = height - 1;
- pts[2].x = tabwidth - tabxslope;
- pts[2].y = height - 1;
- pts[3].x = tabwidth;
- pts[3].y = 0;
-
- FillRect (hdcEMF, &rect, GetSysColorBrush(COLOR_3DFACE));
-
- SelectObject(hdcEMF, GetSysColorBrush(COLOR_3DFACE));
- DrawTab(hdcEMF, width-tabwidth, tabwidth, height - 1, tabxslope, FALSE);
- DrawTab(hdcEMF, width-tabwidth-tabwidth+tabxslope, tabwidth, height - 1, tabxslope, FALSE);
- DrawTab(hdcEMF, 0, tabwidth, height - 1, tabxslope, TRUE);
-
- SelectObject(hdcEMF, hpen);
- MoveToEx(hdcEMF, 110, 0, 0);
- LineTo(hdcEMF, totalwidth, 0);
- SelectObject(hdcEMF, hfont);
- SetBkMode(hdcEMF, TRANSPARENT);
- TextOut(hdcEMF, 10,1, "Build", 5);
- TextOut(hdcEMF, 42,1, "Debug", 5);
- TextOut(hdcEMF, 78,1, "Result", 6);
- SelectObject(hdcEMF, oldpen);
- DeleteObject(hpen);
- DeleteObject(whitepen);
- hemf = CloseEnhMetaFile(hdcEMF);
- }
|