📄 winnc.c
字号:
} else{//DOWN BUTTON NOT PRESSED //left & top bound SelectObject(hDC,hPenBright); winMoveToEx(hDC,rcDownButton.right-1,rcDownButton.top,&point); winLineTo(hDC,rcDownButton.left,rcDownButton.top); winLineTo(hDC,rcDownButton.left,rcDownButton.bottom-1); //Center for(y=rcDownButton.top+2;y<=rcDownButton.bottom-2;y++){ winMoveToEx(hDC,rcDownButton.left+2,y,&point); winLineTo(hDC,rcDownButton.right-2,y); } //left & top bright bound SelectObject(hDC,hPenGray); winMoveToEx(hDC,rcDownButton.right-2,rcDownButton.top+1,&point); winLineTo(hDC,rcDownButton.left+1,rcDownButton.top+1); winLineTo(hDC,rcDownButton.left+1,rcDownButton.bottom-2); //right & bottom dark bound SelectObject(hDC,hPenDark); winMoveToEx(hDC,rcDownButton.left+1,rcDownButton.bottom-1,&point); winLineTo(hDC,rcDownButton.right-1,rcDownButton.bottom-1); winLineTo(hDC,rcDownButton.right-1,rcDownButton.top+1); //bottom & right black bound SelectObject(hDC,hPenBlack); winMoveToEx(hDC,rcDownButton.left,rcDownButton.bottom,&point); winLineTo(hDC,rcDownButton.right,rcDownButton.bottom); winLineTo(hDC,rcDownButton.right,rcDownButton.top); //the triangle winMoveToEx(hDC,rcDownButton.left+4,rcDownButton.top+6,&point); winLineTo(hDC,rcDownButton.left+8,rcDownButton.top+6); winMoveToEx(hDC,rcDownButton.left+5,rcDownButton.top+7,&point); winLineTo(hDC,rcDownButton.left+7,rcDownButton.top+7); winSetPixel(hDC,rcDownButton.left+6,rcDownButton.top+8,RGB_SYSTEMBLACK); // } //2.up arrow if((dwStyle & SS_UPLEFT_PRESSDOWN)!=0){//UP BUTTON PRESSED winFillRectangle(hDC,rcUpButton.left,rcUpButton.top,rcUpButton.right,rcUpButton.bottom, RGB_SYSTEMBRIGHT,RGB_SYSTEMDARK); //Draw the triangle SelectObject(hDC,hPenBlack); winMoveToEx(hDC,rcUpButton.left+5,rcUpButton.top+9,&point); winLineTo(hDC,rcUpButton.left+9,rcUpButton.top+9); winMoveToEx(hDC,rcUpButton.left+6,rcUpButton.top+8,&point); winLineTo(hDC,rcUpButton.left+8,rcUpButton.top+8); winSetPixel(hDC,rcUpButton.left+7,rcUpButton.top+7,RGB_SYSTEMBLACK); } else{//UP BUTTON NOT PRESSED //left & top bound SelectObject(hDC,hPenBright); winMoveToEx(hDC,rcUpButton.right-1,rcUpButton.top,&point); winLineTo(hDC,rcUpButton.left,rcUpButton.top); winLineTo(hDC,rcUpButton.left,rcUpButton.bottom-1); //Center for(y=rcUpButton.top+2;y<=rcUpButton.bottom-2;y++){ winMoveToEx(hDC,rcUpButton.left+2,y,&point); winLineTo(hDC,rcUpButton.right-2,y); } //left & top bright bound SelectObject(hDC,hPenGray); winMoveToEx(hDC,rcUpButton.right-2,rcUpButton.top+1,&point); winLineTo(hDC,rcUpButton.left+1,rcUpButton.top+1); winLineTo(hDC,rcUpButton.left+1,rcUpButton.bottom-2); //right & bottom dark bound SelectObject(hDC,hPenDark); winMoveToEx(hDC,rcUpButton.left+1,rcUpButton.bottom-1,&point); winLineTo(hDC,rcUpButton.right-1,rcUpButton.bottom-1); winLineTo(hDC,rcUpButton.right-1,rcUpButton.top+1); //bottom & right bound SelectObject(hDC,hPenBlack); winMoveToEx(hDC,rcUpButton.left,rcUpButton.bottom,&point); winLineTo(hDC,rcUpButton.right,rcUpButton.bottom); winLineTo(hDC,rcUpButton.right,rcUpButton.top); //the triangle winMoveToEx(hDC,rcUpButton.left+4,rcUpButton.top+8,&point); winLineTo(hDC,rcUpButton.left+8,rcUpButton.top+8); winMoveToEx(hDC,rcUpButton.left+5,rcUpButton.top+7,&point); winLineTo(hDC,rcUpButton.left+7,rcUpButton.top+7); winSetPixel(hDC,rcUpButton.left+6,rcUpButton.top+6,RGB_SYSTEMBLACK); } //3.bar if(ScrollBarIsEnable(((PWindowsTree)(hDC->hWnd))->pVScroll)){ //SliderBar iPos = pCurState->iSliderBarVal; iSliderBarHeight = pCurState->iSliderBarLen; SetRect(&rcSliderBar,lpRect->left,lpRect->top+iPos,lpRect->right,lpRect->top+iPos+iSliderBarHeight); //left top SelectObject(hDC,hPenBright); winMoveToEx(hDC,rcSliderBar.right-1,rcSliderBar.top,&point); winLineTo(hDC,rcSliderBar.left,rcSliderBar.top); winLineTo(hDC,rcSliderBar.left,rcSliderBar.bottom-1); //center winFillRectangle(hDC,rcSliderBar.left+2,rcSliderBar.top+2, rcSliderBar.right-2,rcSliderBar.bottom-2, RGB_SYSTEMBRIGHT,RGB_SYSTEMBRIGHT); //right bottom SelectObject(hDC,hPenBlack); winMoveToEx(hDC,rcSliderBar.left,rcSliderBar.bottom,&point); winLineTo(hDC,rcSliderBar.right,rcSliderBar.bottom); winLineTo(hDC,rcSliderBar.right,rcSliderBar.top); //left top gray bound SelectObject(hDC,hPenGray); winMoveToEx(hDC,rcSliderBar.right-2,rcSliderBar.top+1,&point); winLineTo(hDC,rcSliderBar.left+1,rcSliderBar.top+1); winLineTo(hDC,rcSliderBar.left+1,rcSliderBar.bottom-2); //right bottom dark bound SelectObject(hDC,hPenDark); winMoveToEx(hDC,rcSliderBar.right-1,rcSliderBar.top+1,&point); winLineTo(hDC,rcSliderBar.right-1,rcSliderBar.bottom-1); winLineTo(hDC,rcSliderBar.left+1,rcSliderBar.bottom-1); } //restore pen memcpy(hDC->hPen,&penBackup,sizeof(PEN)); //destroy the hdc object DeleteObject(hPenBlack); DeleteObject(hPenGray); DeleteObject(hPenBright); DeleteObject(hPenDark);}void wndDrawHScrollBar( LPRECT lpRect, HDC hDC, DWORD dwStyle, LPSCROLLCURSTATE pCurState){ int iArrowWidth,iWinWidth,iWinHeight; int iPos,iSliderBarWidth,iTotalBarWidth; RECT rcRightButton,rcLeftButton,rcTotalBar,rcSliderBar; HPEN hPenBlack,hPenGray,hPenBright,hPenDark; POINT point; int y; PEN penBackup; iWinWidth =lpRect->right - lpRect->left + 1; iWinHeight =lpRect->bottom - lpRect->top + 1; iArrowWidth=GetSystemMetrics(SM_CXHSCROLL); iTotalBarWidth = iWinWidth- 2 * iArrowWidth; //RightButton SetRect(&rcRightButton,lpRect->right-iArrowWidth,lpRect->top,lpRect->right,lpRect->bottom); //LeftButton SetRect(&rcLeftButton,lpRect->right-2*iArrowWidth,lpRect->top,lpRect->right-iArrowWidth,lpRect->bottom); //TotalBar SetRect(&rcTotalBar,lpRect->left,lpRect->top,lpRect->right-iArrowWidth,lpRect->bottom); hPenBlack =CreatePen(PS_SOLID,1,RGB_SYSTEMBLACK); hPenGray =CreatePen(PS_SOLID,1,RGB_SYSTEMLTGRAY); hPenBright =CreatePen(PS_SOLID,1,RGB_SYSTEMBRIGHT); hPenDark =CreatePen(PS_SOLID,1,RGB_SYSTEMDARK); memcpy(&penBackup,hDC->hPen,sizeof(PEN)); SelectObject(hDC,hPenBlack); winMoveToEx(hDC,rcTotalBar.left,rcTotalBar.top,&point); winLineTo(hDC,rcTotalBar.right,rcTotalBar.top); winFillRectangle(hDC, rcTotalBar.left,rcTotalBar.top + 1,rcTotalBar.right,rcTotalBar.bottom, RGB_SYSTEMHIBRIGHT,RGB_SYSTEMHIBRIGHT); //1.right arrow if((dwStyle & SS_DOWNRIGHT_PRESSDOWN)!=0){//DOWN BUTTON PRESSED winFillRectangle(hDC,rcRightButton.left,rcRightButton.top,rcRightButton.right,rcRightButton.bottom, RGB_SYSTEMBRIGHT,RGB_SYSTEMDARK); //Draw the triangle SelectObject(hDC,hPenBlack); winMoveToEx(hDC,rcRightButton.left+7,rcRightButton.top+5,&point); winLineTo(hDC,rcRightButton.left+7,rcRightButton.top+9); winMoveToEx(hDC,rcRightButton.left+8,rcRightButton.top+6,&point); winLineTo(hDC,rcRightButton.left+8,rcRightButton.top+8); winSetPixel(hDC,rcRightButton.left+9,rcRightButton.top+7,RGB_SYSTEMBLACK); } else{//DOWN BUTTON NOT PRESSED //left & top bound //printf("down right not pressed\n"); SelectObject(hDC,hPenBright); winMoveToEx(hDC,rcRightButton.left,rcRightButton.bottom-1,&point); winLineTo(hDC,rcRightButton.left,rcRightButton.top); winLineTo(hDC,rcRightButton.right-1,rcRightButton.top); //Center for(y=rcRightButton.top+2;y<=rcRightButton.bottom-2;y++){ winMoveToEx(hDC,rcRightButton.left+2,y,&point); winLineTo(hDC,rcRightButton.right-2,y); } //left & top bright bound SelectObject(hDC,hPenGray); winMoveToEx(hDC,rcRightButton.left+1,rcRightButton.bottom-2,&point); winLineTo(hDC,rcRightButton.left+1,rcRightButton.top+1); winLineTo(hDC,rcRightButton.right-2,rcRightButton.top+1); //right & bottom dark bound SelectObject(hDC,hPenDark); winMoveToEx(hDC,rcRightButton.left+1,rcRightButton.bottom-1,&point); winLineTo(hDC,rcRightButton.right-1,rcRightButton.bottom-1); winLineTo(hDC,rcRightButton.right-1,rcRightButton.top+1); //bottom & right black bound SelectObject(hDC,hPenBlack); winMoveToEx(hDC,rcRightButton.left,rcRightButton.bottom,&point); winLineTo(hDC,rcRightButton.right,rcRightButton.bottom); winLineTo(hDC,rcRightButton.right,rcRightButton.top); //Draw the triangle SelectObject(hDC,hPenBlack); winMoveToEx(hDC,rcRightButton.left+6,rcRightButton.top+4,&point); winLineTo(hDC,rcRightButton.left+6,rcRightButton.top+8); winMoveToEx(hDC,rcRightButton.left+7,rcRightButton.top+5,&point); winLineTo(hDC,rcRightButton.left+7,rcRightButton.top+7); winSetPixel(hDC,rcRightButton.left+8,rcRightButton.top+6,RGB_SYSTEMBLACK); } //2.left arrow if((dwStyle & SS_UPLEFT_PRESSDOWN)!=0){//UP BUTTON PRESSED winFillRectangle(hDC,rcLeftButton.left,rcLeftButton.top,rcLeftButton.right,rcLeftButton.bottom, RGB_SYSTEMBRIGHT,RGB_SYSTEMDARK); //Draw the triangle SelectObject(hDC,hPenBlack); winMoveToEx(hDC,rcLeftButton.left+8,rcLeftButton.top+5,&point); winLineTo(hDC,rcLeftButton.left+8,rcLeftButton.top+9); winMoveToEx(hDC,rcLeftButton.left+7,rcLeftButton.top+6,&point); winLineTo(hDC,rcLeftButton.left+7,rcLeftButton.top+8); winSetPixel(hDC,rcLeftButton.left+6,rcLeftButton.top+7,RGB_SYSTEMBLACK); } else{//Left BUTTON NOT PRESSED //left & top bound SelectObject(hDC,hPenBright); winMoveToEx(hDC,rcLeftButton.left,rcLeftButton.bottom-1,&point); winLineTo(hDC,rcLeftButton.left,rcLeftButton.top); winLineTo(hDC,rcLeftButton.right-1,rcLeftButton.top); //Center for(y=rcLeftButton.top+2;y<=rcLeftButton.bottom-2;y++){ winMoveToEx(hDC,rcLeftButton.left+2,y,&point); winLineTo(hDC,rcLeftButton.right-2,y); } //left & top bright bound SelectObject(hDC,hPenGray); winMoveToEx(hDC,rcLeftButton.left+1,rcLeftButton.bottom-1,&point); winLineTo(hDC,rcLeftButton.left+1,rcLeftButton.top+1); winLineTo(hDC,rcLeftButton.right-1,rcLeftButton.top+1); //right & bottom dark bound SelectObject(hDC,hPenDark); winMoveToEx(hDC,rcLeftButton.left+1,rcLeftButton.bottom-1,&point); winLineTo(hDC,rcLeftButton.right-1,rcLeftButton.bottom-1); winLineTo(hDC,rcLeftButton.right-1,rcLeftButton.top+1); //bottom & right bound SelectObject(hDC,hPenBlack); winMoveToEx(hDC,rcLeftButton.left,rcLeftButton.bottom,&point); winLineTo(hDC,rcLeftButton.right,rcLeftButton.bottom); winLineTo(hDC,rcLeftButton.right,rcLeftButton.top); //the triangle winMoveToEx(hDC,rcLeftButton.left+7,rcLeftButton.top+4,&point); winLineTo(hDC,rcLeftButton.left+7,rcLeftButton.top+8); winMoveToEx(hDC,rcLeftButton.left+6,rcLeftButton.top+5,&point); winLineTo(hDC,rcLeftButton.left+6,rcLeftButton.top+7); winSetPixel(hDC,rcLeftButton.left+5,rcLeftButton.top+6,RGB_SYSTEMBLACK); } if(ScrollBarIsEnable(((PWindowsTree)(hDC->hWnd))->pHScroll)){ //SliderBar iPos = pCurState->iSliderBarVal; iSliderBarWidth = pCurState->iSliderBarLen; SetRect(&rcSliderBar,lpRect->left+iPos,lpRect->top,lpRect->left+iPos+iSliderBarWidth,lpRect->bottom); //3.bar //left top SelectObject(hDC,hPenBright); winMoveToEx(hDC,rcSliderBar.left,rcSliderBar.bottom-1,&point); winLineTo(hDC,rcSliderBar.left,rcSliderBar.top); winLineTo(hDC,rcSliderBar.right-1,rcSliderBar.top); //center winFillRectangle(hDC,rcSliderBar.left+2,rcSliderBar.top+2, rcSliderBar.right-2,rcSliderBar.bottom-2, RGB_SYSTEMBRIGHT,RGB_SYSTEMBRIGHT); //right bottom SelectObject(hDC,hPenBlack); winMoveToEx(hDC,rcSliderBar.left,rcSliderBar.bottom,&point); winLineTo(hDC,rcSliderBar.right,rcSliderBar.bottom); winLineTo(hDC,rcSliderBar.right,rcSliderBar.top); //left top gray bound SelectObject(hDC,hPenGray); winMoveToEx(hDC,rcSliderBar.left+1,rcSliderBar.bottom-2,&point); winLineTo(hDC,rcSliderBar.left+1,rcSliderBar.top+1); winLineTo(hDC,rcSliderBar.right-1,rcSliderBar.top+1); //right bottom dark bound SelectObject(hDC,hPenDark); winMoveToEx(hDC,rcSliderBar.left+1,rcSliderBar.bottom-1,&point); winLineTo(hDC,rcSliderBar.right-1,rcSliderBar.bottom-1); winLineTo(hDC,rcSliderBar.right-1,rcSliderBar.top+1); } //restore pen memcpy(hDC->hPen,&penBackup,sizeof(PEN)); //destroy the hdc object DeleteObject(hPenBlack); DeleteObject(hPenGray); DeleteObject(hPenBright); DeleteObject(hPenDark);}//=======================================ScrollBar===========================================BOOL wndGetVScrollBarRect( HWND hWnd, LPRECT lpRect){ PWindowsTree pWin; RECT rcWin; int iWidth,iHeight; int iBorder; int iCaption; pWin=(PWindowsTree)hWnd; if(!pWin) return false; if(!(pWin->dwStyle & WS_VSCROLL)){ SetRect(lpRect,0,0,0,0); return false; } iBorder=wndGetBorder(hWnd); GetWindowRect(hWnd,&rcWin); if(IsCaption(hWnd)) iCaption = WIN_CAPTION_HEIGHT; else iCaption = 0; iWidth=GetSystemMetrics(SM_CXVSCROLL); iHeight=GetSystemMetrics(SM_CYHSCROLL); if(pWin->dwStyle & WS_HSCROLL){ SetRect(lpRect,rcWin.right+1-iWidth-iBorder,rcWin.top+iBorder+iCaption+1, rcWin.right-iBorder,rcWin.bottom-iBorder-iHeight); } else{ SetRect(lpRect,rcWin.right+1-iWidth-iBorder,rcWin.top+iBorder+iCaption+1, rcWin.right-iBorder,rcWin.bottom-iBorder); } return true;}BOOL wndGetHScrollBarRect( HWND hWnd, LPRECT lpRect){ PWindowsTree pWin; RECT rcWin; int iWidth,iHeight; int iBorder; int iCaption; pWin=(PWindowsTree)hWnd; if(!pWin) return false; if(!(pWin->dwStyle & WS_HSCROLL)){ SetRect(lpRect,0,0,0,0); return false; } GetWindowRect(hWnd,&rcWin); iBorder=wndGetBorder(hWnd); if(IsCaption(hWnd)) iCaption = WIN_CAPTION_HEIGHT; else iCaption = 0; iWidth=GetSystemMetrics(SM_CXVSCROLL); iHeight=GetSystemMetrics(SM_CYHSCROLL); if(pWin->dwStyle & WS_VSCROLL){ SetRect(lpRect,rcWin.left+iBorder,rcWin.bottom+1-iHeight, rcWin.right-iBorder-iWidth,rcWin.bottom-iBorder); } else{ SetRect(lpRect,rcWin.left+iBorder,rcWin.bottom+1-iHeight, rcWin.right-iBorder,rcWin.bottom-iBorder); } return true;}static void CalVScrollCurState( LPRECT lpRect, LPSCROLLINFO pScrollInfo, LPSCROLLCURSTATE pCurState){ RECT rcTotalBar; int iWinHeight, iArrowHeight,iTotalBarHeight,iSliderBarHeight, iPos; iWinHeight =lpRect->bottom - lpRect->top + 1; iArrowHeight=GetSystemMetrics(SM_CYVSCROLL); //TotalBar SetRect(&rcTotalBar,lpRect->left,lpRect->top,lpRect->right,lpRect->bottom-2*iArrowHeight); //height of total bar iTotalBarHeight = iWinHeight- 2 * iArrowHeight; if(pScrollInfo->nMax - pScrollInfo->nMin + 1 <= pScrollInfo->nPage) iSliderBarHeight = iTotalBarHeight - 1; else{ iSliderBarHeight = iTotalBarHeight * pScrollInfo->nPage / (pScrollInfo->nMax - pScrollInfo->nMin + 1); if(iSliderBarHeight<MIN_SLIDERBAR_LENGTH) iSliderBarHeight=MIN_SLIDERBAR_LENGTH; } pCurState->iSliderBarLen = iSliderBarHeight; iPos = (pScrollInfo->nPos - pScrollInfo->nMin) * iTotalBarHeight/(pScrollInfo->nMax - pScrollInfo->nMin + 1); if(iPos < 0) iPos = 0; if((rcTotalBar.bottom - iPos)< iSliderBarHeight) iPos=rcTotalBar.bottom - iSliderBarHeight; pCurState->iSliderBarVal = iPos;}static void CalHScrollCurState( LPRECT lpRect, LPSCROLLINFO pScrollInfo, LPSCROLLCURSTATE pCurState){ RECT rcTotalBar; int iWinWidth,iArrowWidth,iTotalBarWidth,iSliderBarWidth, iPos; iWinWidth = lpRect->right - lpRect->left + 1; iArrowWidth = GetSystemMetrics(SM_CXHSCROLL); SetRect(&rcTotalBar,lpRect->left,lpRect->top,lpRect->right-2*iArrowWidth,lpRect->bottom); iTotalBarWidth = iWinWidth - 2* iArrowWidth; if(pScrollInfo->nMax - pScrollInfo->nMin + 1 <= pScrollInfo->nPage) iSliderBarWidth = iTotalBarWidth - 1; else{ iSliderBarWidth = iTotalBarWidth * pScrollInfo->nPage / (pScrollInfo->nMax - pScrollInfo->nMin + 1);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -