📄 winnc.c
字号:
if(!(pWin->pVCurState->iClickPos)) return; wndGetVScrollBarRect(hWnd,&rc); iBarWidth =rc.right - rc.left + 1; iBarHeight =rc.bottom - rc.top + 1; iArrowHeight=GetSystemMetrics(SM_CYVSCROLL); pScrollInfo=pWin->pVScroll; pCurState = pWin->pVCurState; iTotalBarHeight = iBarHeight- 2 * iArrowHeight; iSliderBarHeight = pCurState->iSliderBarLen; iPos = pCurState->iSliderBarVal; //DownButton SetRect(&rcDownButton,rc.left,rc.bottom-iArrowHeight,rc.right,rc.bottom); //UpButton SetRect(&rcUpButton,rc.left,rc.bottom-2*iArrowHeight,rc.right,rc.bottom-iArrowHeight); //TotalBar SetRect(&rcTotalBar,rc.left,rc.top,rc.right,rc.bottom-2*iArrowHeight); //SliderBar SetRect(&rcSliderBar,rc.left,rc.top+iPos,rc.right,rc.top+iPos+iSliderBarHeight); if((y - rcSliderBar.top) > pCurState->iClickPos){//move down if(rcSliderBar.bottom == rcTotalBar.bottom - 1){//already reach bottom pScrollInfo->nPos = pScrollInfo->nMax - pScrollInfo->nPage + 1; pCurState->iSliderBarVal = iTotalBarHeight - iSliderBarHeight - 1; scrInvalidateRect(hWnd,&rcTotalBar,true); } else{ if((y + iSliderBarHeight - pCurState->iClickPos)>=rcTotalBar.bottom){ pScrollInfo->nPos=pScrollInfo->nMax - pScrollInfo->nPage + 1 ; pCurState->iSliderBarVal = iTotalBarHeight - iSliderBarHeight - 1; scrInvalidateRect(hWnd,&rcTotalBar,true); } else{ iPos = y - rcTotalBar.top - pCurState->iClickPos; pCurState->iSliderBarVal = iPos; pScrollInfo->nPos = iPos * (pScrollInfo->nMax - pScrollInfo->nMin + 1)/iTotalBarHeight; scrInvalidateRect(hWnd,&rcTotalBar,true); } } iRetMsg=SB_THUMBTRACK; if(IsControl(hWnd)){ SendMessage(hWnd,LMSG_VSCROLL,(WPARAM)iRetMsg,(LPARAM)NULL); } else{ SendNotifyMessage(hWnd,LMSG_VSCROLL,(WPARAM)iRetMsg,(LPARAM)NULL); } } else{//move up if(rcSliderBar.top == rcTotalBar.top) return; else{ if(y - rcTotalBar.top<= pCurState->iClickPos){ pScrollInfo->nPos=pScrollInfo->nMin; pCurState->iSliderBarVal = 0; scrInvalidateRect(hWnd,&rcTotalBar,true); } else{ iPos = y - rcTotalBar.top - pCurState->iClickPos; pCurState->iSliderBarVal = iPos; pScrollInfo->nPos = iPos * (pScrollInfo->nMax - pScrollInfo->nMin + 1)/iTotalBarHeight + pScrollInfo->nMin; scrInvalidateRect(hWnd,&rcTotalBar,true); } iRetMsg=SB_THUMBTRACK; if(IsControl(hWnd)){ SendMessage(hWnd,LMSG_VSCROLL,(WPARAM)iRetMsg,(LPARAM)NULL); } else{ SendNotifyMessage(hWnd,LMSG_VSCROLL,(WPARAM)iRetMsg,(LPARAM)NULL); } } }}//hscroll penmove procedurevoid HScrollBarPenMoveProc( HWND hWnd, int x, int y){ int iArrowWidth,iBarWidth,iBarHeight,iSliderBarWidth,iPos,iTotalBarWidth; RECT rc,rcRightButton,rcLeftButton,rcTotalBar,rcSliderBar; LPSCROLLCURSTATE pCurState; LPSCROLLINFO pScrollInfo; unsigned long iRetMsg; PWindowsTree pWin; pWin=(PWindowsTree)hWnd; if(!ScrollBarIsEnable(pWin->pHScroll)) return; if(!(pWin->pHCurState->iClickPos)) return; wndGetHScrollBarRect(hWnd,&rc); iBarWidth =rc.right - rc.left + 1; iBarHeight =rc.bottom - rc.top + 1; iArrowWidth=GetSystemMetrics(SM_CXHSCROLL); pScrollInfo=pWin->pHScroll; pCurState = pWin->pHCurState; iTotalBarWidth = iBarWidth- 2 * iArrowWidth; iSliderBarWidth = pCurState->iSliderBarLen; iPos = pCurState->iSliderBarVal; //RightButton SetRect(&rcRightButton,rc.right-iArrowWidth,rc.top,rc.right,rc.bottom); //LeftButton SetRect(&rcLeftButton,rc.right-2*iArrowWidth,rc.top,rc.right-iArrowWidth,rc.bottom); //TotalBar SetRect(&rcTotalBar,rc.left,rc.top,rc.right-2*iArrowWidth,rc.bottom); //SliderBar SetRect(&rcSliderBar,rc.left+iPos,rc.top,rc.left+iPos+iSliderBarWidth,rc.bottom); if((x - rcSliderBar.left) > pCurState->iClickPos){ if(rcSliderBar.right == rcTotalBar.right - 1){ pScrollInfo->nPos=pScrollInfo->nMax - pScrollInfo->nPage; pCurState->iSliderBarVal = iTotalBarWidth - iSliderBarWidth - 1; scrInvalidateRect(hWnd,&rcTotalBar,true); } else{ if((x + iSliderBarWidth - pCurState->iClickPos)>=rcTotalBar.right){ pScrollInfo->nPos=pScrollInfo->nMax - pScrollInfo->nPage; pCurState->iSliderBarVal = iTotalBarWidth - iSliderBarWidth - 1; scrInvalidateRect(hWnd,&rcTotalBar,true); } else{ iPos = x -rcTotalBar.left - pCurState->iClickPos; pCurState->iSliderBarVal = iPos; pScrollInfo->nPos = iPos * (pScrollInfo->nMax - pScrollInfo->nMin + 1)/iTotalBarWidth; scrInvalidateRect(hWnd,&rcTotalBar,true); } } iRetMsg=SB_THUMBTRACK; if(IsControl(hWnd)){ SendMessage(hWnd,LMSG_VSCROLL,(WPARAM)iRetMsg,(LPARAM)NULL); } else{ SendNotifyMessage(hWnd,LMSG_HSCROLL,(WPARAM)iRetMsg,(LPARAM)NULL); } } else{//move left if(rcSliderBar.left == rcTotalBar.left) return; else{ if(x - rcTotalBar.left<= pCurState->iClickPos){ pScrollInfo->nPos=pScrollInfo->nMin; pCurState->iSliderBarVal = 0; scrInvalidateRect(hWnd,&rcTotalBar,true); } else{ iPos = x -rcTotalBar.left - pCurState->iClickPos; pCurState->iSliderBarVal = iPos; pScrollInfo->nPos = iPos * (pScrollInfo->nMax - pScrollInfo->nMin + 1)/iTotalBarWidth + pScrollInfo->nMin; scrInvalidateRect(hWnd,&rcTotalBar,true); } iRetMsg=SB_THUMBTRACK; if(IsControl(hWnd)){ SendMessage(hWnd,LMSG_VSCROLL,(WPARAM)iRetMsg,(LPARAM)NULL); } else{ SendNotifyMessage(hWnd,LMSG_HSCROLL,(WPARAM)iRetMsg,(LPARAM)NULL); } } }}BOOL wndDrawNCFrame( HWND hWnd, HDC hDC){ PWindowsTree pWin; BOOL bHScroll,bVScroll; RECT rcVBar,rcHBar,rcCorner; LPSCROLLCURSTATE pCurState; pWin=(PWindowsTree)hWnd; if(!pWin) return false; if(pWin->dwStyle & WS_VSCROLL) bVScroll = true; else bVScroll = false; if(pWin->dwStyle & WS_HSCROLL) bHScroll = true; else bHScroll = false; //draw bound wndDrawNCArea(hWnd, hDC); //draw vert scroll if(bVScroll){ pCurState = pWin->pVCurState; wndGetVScrollBarRect(hWnd,&rcVBar); ScreenToWindowRect(hWnd,&rcVBar); wndDrawVScrollBar(&rcVBar,hDC,pWin->pVScroll->dwStatus,pCurState); } if(bHScroll){ pCurState = pWin->pHCurState; wndGetHScrollBarRect(hWnd,&rcHBar); ScreenToWindowRect(hWnd,&rcHBar); wndDrawHScrollBar(&rcHBar,hDC,pWin->pHScroll->dwStatus,pCurState); } if(bVScroll && bHScroll){ SetRect(&rcCorner,rcHBar.right,rcVBar.bottom,rcVBar.right,rcHBar.bottom); //draw right bottom corner box winFillRectangle(hDC, rcCorner.left+1,rcCorner.top,rcCorner.right,rcCorner.bottom, RGB_SYSTEMHIBRIGHT,RGB_SYSTEMHIBRIGHT); } return true;}//draw boundBOOL wndDrawNCArea( HWND hWnd, HDC hDC){ PWindowsTree pWin; RECT rcWin; POINT point; HPEN hPenGray; HPEN hPenBright; HPEN hPenDark; HPEN hPenBlack; PEN penBackup; pWin=(PWindowsTree)hWnd; if(!(pWin->dwStyle & WS_BORDER) && !(pWin->dwStyle & WS_THINBORDER) && !(pWin->dwStyle & WS_THICKBORDER)) return false; if(!GetWindowRect(hWnd,&rcWin)) return false; ScreenToWindowRect(hWnd,&rcWin); //backup current pen memcpy(&penBackup,hDC->hPen,sizeof(PEN)); 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); SelectObject(hDC,hPenGray); winMoveToEx(hDC,rcWin.left,rcWin.bottom,&point); winLineTo(hDC,rcWin.left,rcWin.top); winLineTo(hDC,rcWin.right,rcWin.top); SelectObject(hDC,hPenBlack); winMoveToEx(hDC,rcWin.left,rcWin.bottom,&point); winLineTo(hDC,rcWin.right,rcWin.bottom); winLineTo(hDC,rcWin.right,rcWin.top); if(pWin->dwStyle & WS_BORDER) goto okret; SelectObject(hDC,hPenBright); winMoveToEx(hDC,rcWin.left+1,rcWin.bottom-1,&point); winLineTo(hDC,rcWin.left+1,rcWin.top+1); winLineTo(hDC,rcWin.right-1,rcWin.top+1); SelectObject(hDC,hPenDark); winMoveToEx(hDC,rcWin.left+1,rcWin.bottom-1,&point); winLineTo(hDC,rcWin.right-1,rcWin.bottom-1); winLineTo(hDC,rcWin.right-1,rcWin.top+1); if(pWin->dwStyle & WS_THINBORDER) goto okret; SelectObject(hDC,hPenDark); winMoveToEx(hDC,rcWin.left+2,rcWin.bottom-4,&point); winLineTo(hDC,rcWin.left+2,rcWin.top+2); winLineTo(hDC,rcWin.right-4,rcWin.top+2); SelectObject(hDC,hPenBright); winMoveToEx(hDC,rcWin.right-2,rcWin.top+1,&point); winLineTo(hDC,rcWin.right-2,rcWin.bottom-2); SelectObject(hDC,hPenBlack); winMoveToEx(hDC,rcWin.left+3,rcWin.bottom-4,&point); winLineTo(hDC,rcWin.left+3,rcWin.top+3); winLineTo(hDC,rcWin.right-4,rcWin.top+3); SelectObject(hDC,hPenGray); winMoveToEx(hDC,rcWin.right-3,rcWin.top+2,&point); winLineTo(hDC,rcWin.right-3,rcWin.bottom-3); winLineTo(hDC,rcWin.left+2,rcWin.bottom-3);okret: //restore pen memcpy(hDC->hPen,&penBackup,sizeof(PEN)); if(IsCaption(hWnd)){ PaintCaption(hWnd,hDC); } //destroy the hdc object DeleteObject(hPenBlack); DeleteObject(hPenGray); DeleteObject(hPenBright); DeleteObject(hPenDark); return true;}BOOL PaintCaption( HWND hWnd, HDC hDC){ COLORREF crTextColor; char pString[256]; char *pEnvStr; int iLeft; BOOL bCloseBox; PWindowsTree pWin; int iBorder; RECT rcWin,rcCaption; HGDIOBJ hFont; pWin = (PWindowsTree)hWnd; iBorder = wndGetBorder(hWnd); if(!GetWindowRect(hWnd,&rcWin)) return; ScreenToWindowRect(hWnd,&rcWin); SetRect(&rcCaption,rcWin.left + iBorder, rcWin.top + iBorder, rcWin.right - iBorder, rcWin.top + iBorder + WIN_CAPTION_HEIGHT-1); //backup text color crTextColor = hDC->crTextColor; if(IsActive(hWnd)){ SetTextColor(hDC,RGB_WHITE); winFillRectangle(hDC,rcCaption.left,rcCaption.top, rcCaption.right, rcCaption.bottom, WIN_CAPTION_ACTIVE_COLOR, WIN_CAPTION_ACTIVE_COLOR); } else{ SetTextColor(hDC,RGB_BLACK); winFillRectangle(hDC,rcCaption.left,rcCaption.top, rcCaption.right, rcCaption.bottom, WIN_CAPTION_DISACTIVE_COLOR, WIN_CAPTION_DISACTIVE_COLOR); } hFont = GetStockObject(FONT_12_12); SelectObject(hDC,hFont); DeleteObject(hFont); //draw caption text winDrawText(hDC,pWin->lpszCaption,strlen(pWin->lpszCaption),&rcCaption,DT_LEFT|DT_VCENTER); //restore text color SetTextColor(hDC,crTextColor); //CLOSE BOX if(IsCloseBox(hWnd)) bCloseBox = true; else bCloseBox = false; if(bCloseBox){ pEnvStr=getenv("LGUI_HOME"); if(!pEnvStr){ printerror("Env variable LGUI_HOME is Null!"); return false; } strcpy(pString,pEnvStr); strcat(pString,"/pics/sys/"); if(IsCloseBoxPressed(hWnd)) strcat(pString,WIN_CLOSEBOX_FILESPEC_1); else strcat(pString,WIN_CLOSEBOX_FILESPEC_0); winShowBitmapWithTrColor(hDC,rcCaption.right - WIN_CLOSEBOX_WIDTH,iBorder, pString,RGB_BLACK); } //OK BOX if(IsOkButton(hWnd)){ pEnvStr=getenv("LGUI_HOME"); if(!pEnvStr){ printerror("Env variable LGUI_HOME is Null!"); return false; } strcpy(pString,pEnvStr); strcat(pString,"/pics/sys/"); if(IsOkButtonPressed(hWnd)) strcat(pString, WIN_OKBUTTON_FILESPEC_1); else strcat(pString, WIN_OKBUTTON_FILESPEC_0); iLeft = rcCaption.right - WIN_OKBUTTON_WIDTH; if(bCloseBox) iLeft -= WIN_CLOSEBOX_WIDTH; winShowBitmapWithTrColor(hDC,iLeft,iBorder,pString,RGB_BLACK); } return true;}void wndDrawVScrollBar( LPRECT lpRect, HDC hDC, DWORD dwStyle, LPSCROLLCURSTATE pCurState){ int iArrowHeight,iWinWidth,iWinHeight; int iPos,iSliderBarHeight,iTotalBarHeight; RECT rcDownButton,rcUpButton,rcTotalBar,rcSliderBar; HPEN hPenBlack,hPenGray,hPenBright,hPenDark; PEN penBackup; POINT point; int y; iWinWidth =lpRect->right - lpRect->left + 1; iWinHeight =lpRect->bottom - lpRect->top + 1; iArrowHeight=GetSystemMetrics(SM_CYVSCROLL); iTotalBarHeight = iWinHeight- 2 * iArrowHeight; //DownButton SetRect(&rcDownButton,lpRect->left,lpRect->bottom-iArrowHeight,lpRect->right,lpRect->bottom); //UpButton SetRect(&rcUpButton,lpRect->left,lpRect->bottom-2*iArrowHeight,lpRect->right,lpRect->bottom-iArrowHeight); //TotalBar SetRect(&rcTotalBar,lpRect->left,lpRect->top,lpRect->right,lpRect->bottom-iArrowHeight); 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)); winMoveToEx(hDC,rcTotalBar.left,rcTotalBar.top,&point); winLineTo(hDC,rcTotalBar.left,rcTotalBar.bottom); winFillRectangle(hDC, rcTotalBar.left+1,rcTotalBar.top,rcTotalBar.right,rcTotalBar.bottom, RGB_SYSTEMHIBRIGHT,RGB_SYSTEMHIBRIGHT); //1.down arrow if((dwStyle & SS_DOWNRIGHT_PRESSDOWN)!=0){//DOWN BUTTON PRESSED winFillRectangle(hDC,rcDownButton.left,rcDownButton.top,rcDownButton.right,rcDownButton.bottom, RGB_SYSTEMBRIGHT,RGB_SYSTEMDARK); //Draw the triangle SelectObject(hDC,hPenBlack); winMoveToEx(hDC,rcDownButton.left+4,rcDownButton.top+7,&point); winLineTo(hDC,rcDownButton.left+8,rcDownButton.top+7); winMoveToEx(hDC,rcDownButton.left+5,rcDownButton.top+8,&point); winLineTo(hDC,rcDownButton.left+7,rcDownButton.top+8); winSetPixel(hDC,rcDownButton.left+6,rcDownButton.top+9,RGB_SYSTEMBLACK);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -