📄 winnc.c
字号:
if(iSliderBarWidth<MIN_SLIDERBAR_LENGTH) iSliderBarWidth=MIN_SLIDERBAR_LENGTH; } pCurState->iSliderBarLen = iSliderBarWidth; iPos = (pScrollInfo->nPos - pScrollInfo->nMin) * iTotalBarWidth/(pScrollInfo->nMax - pScrollInfo->nMin + 1); if(iPos < 0) iPos = 0; if((rcTotalBar.right - iPos)< iSliderBarWidth) iPos=rcTotalBar.right - iSliderBarWidth; pCurState->iSliderBarVal = iPos;}//enable scrollbar of a windowBOOL GUIAPI EnableScrollBar ( HWND hWnd, int iSBar, BOOL bEnable){ LPSCROLLINFO pSBar; PWindowsTree pWin; RECT rcBar; pWin = (PWindowsTree)hWnd; if (iSBar == SB_HORZ) { if (pWin->dwStyle & WS_HSCROLL) pSBar=pWin->pHScroll; else return false; } else if (iSBar == SB_VERT) { if (pWin->dwStyle & WS_VSCROLL) pSBar=pWin->pVScroll; else return false; } if(bEnable){ if(pSBar->dwStatus & SS_DISABLED) pSBar->dwStatus &= ~SS_DISABLED; } else{ if(!(pSBar->dwStatus & SS_DISABLED)) pSBar->dwStatus |=SS_DISABLED; } if (iSBar == SB_VERT) wndGetVScrollBarRect (pWin, &rcBar); else wndGetHScrollBarRect (pWin, &rcBar); InvalidateRect(hWnd,&rcBar,true); return TRUE;}int GUIAPI SetScrollInfo( HWND hWnd, int fnBar, LPSCROLLINFO lpsi, BOOL fRedraw){ PWindowsTree pWin; LPSCROLLINFO pScrollInfo; RECT rc; pWin=(PWindowsTree)hWnd; if(!pWin) return false; if(fnBar == SB_CTL){ if(pWin->dwStyle & WS_VSCROLL) pScrollInfo = pWin->pVScroll; else pScrollInfo = pWin->pHScroll; } else{ if(fnBar == SB_VERT){ pScrollInfo = pWin->pVScroll; } else{ pScrollInfo = pWin->pHScroll; } } if(lpsi->fMask & SIF_RANGE){ pScrollInfo->nMin=lpsi->nMin; pScrollInfo->nMax=lpsi->nMax; } if(lpsi->fMask & SIF_PAGE){ pScrollInfo->nPage=lpsi->nPage; } if(lpsi->fMask & SIF_POS){ if(lpsi->nPos < pScrollInfo->nMin) pScrollInfo->nPos=pScrollInfo->nMin; else if(lpsi->nPos > (pScrollInfo->nMax - pScrollInfo->nPage)) pScrollInfo->nPos=pScrollInfo->nMax - pScrollInfo->nPage; else pScrollInfo->nPos=lpsi->nPos; pScrollInfo->nTrackPos=lpsi->nPos; } if(fnBar == SB_CTL){ if(pWin->dwStyle & WS_VSCROLL){ wndGetVScrollBarRect(hWnd,&rc); CalVScrollCurState(&rc,pScrollInfo,pWin->pVCurState); } else{ wndGetHScrollBarRect(hWnd,&rc); CalHScrollCurState(&rc,pScrollInfo,pWin->pHCurState); } pScrollInfo = pWin->pHScroll; } else{ if(fnBar == SB_VERT){ wndGetVScrollBarRect(hWnd,&rc); CalVScrollCurState(&rc,pScrollInfo,pWin->pVCurState); } else{ wndGetHScrollBarRect(hWnd,&rc); CalHScrollCurState(&rc,pScrollInfo,pWin->pHCurState); } } if(fRedraw) scrInvalidateRect(hWnd,NULL,true); return true;}int GUIAPI GetScrollInfo( HWND hWnd, LPSCROLLINFO lpsi){ PWindowsTree pWin; pWin = (PWindowsTree)hWnd; if(IsVScrollBar(hWnd)) lpsi = pWin->pVScroll; else lpsi = pWin->pHScroll;}int GUIAPI SetScrollPos( HWND hWnd, int nBar, int nPos, BOOL bRedraw){ PWindowsTree pWin; LPSCROLLINFO pScrollInfo; RECT rc; pWin=(PWindowsTree)hWnd; if(!pWin) return false; if(nBar == SB_CTL){ if(pWin->dwStyle & WS_VSCROLL) pScrollInfo = pWin->pVScroll; else pScrollInfo = pWin->pHScroll; } else{ if(nBar == SB_VERT){ if(!(pWin->dwStyle & WS_VSCROLL)) return false; else pScrollInfo = pWin->pVScroll; } else{ if(!(pWin->dwStyle & WS_HSCROLL)) return false; else pScrollInfo = pWin->pHScroll; } } if(nPos < pScrollInfo->nMin) pScrollInfo->nPos = pScrollInfo->nMin; else if(nPos > (pScrollInfo->nMax - pScrollInfo->nPage)) pScrollInfo->nPos =pScrollInfo->nMax - pScrollInfo->nPage; else pScrollInfo->nPos=nPos; if(nBar == SB_CTL){ if(pWin->dwStyle & WS_VSCROLL){ wndGetVScrollBarRect(hWnd,&rc); CalVScrollCurState(&rc,pScrollInfo,pWin->pVCurState); } else{ wndGetHScrollBarRect(hWnd,&rc); CalHScrollCurState(&rc,pScrollInfo,pWin->pHCurState); } } else{ if(nBar == SB_VERT){ wndGetVScrollBarRect(hWnd,&rc); CalVScrollCurState(&rc,pScrollInfo,pWin->pVCurState); } else{ wndGetHScrollBarRect(hWnd,&rc); CalHScrollCurState(&rc,pScrollInfo,pWin->pHCurState); } } if(bRedraw) scrInvalidateRect(hWnd,NULL,true); return true;}BOOL GUIAPI SetScrollRange( HWND hWnd, int nBar, int nMinPos, int nMaxPos, BOOL bRedraw){ PWindowsTree pWin; LPSCROLLINFO pScrollInfo; RECT rc; pWin=(PWindowsTree)hWnd; if(nBar == SB_CTL){ if(pWin->dwStyle & WS_VSCROLL) pScrollInfo = pWin->pVScroll; else pScrollInfo = pWin->pHScroll; } else{ if(nBar == SB_VERT){ if(!(pWin->dwStyle & WS_VSCROLL)) return false; else pScrollInfo = pWin->pVScroll; } else{ if(!(pWin->dwStyle & WS_HSCROLL)) return false; else pScrollInfo = pWin->pHScroll; } } pScrollInfo->nMin=nMinPos; pScrollInfo->nMax=nMaxPos; if(nBar == SB_CTL){ if(pWin->dwStyle & WS_VSCROLL){ wndGetVScrollBarRect(hWnd,&rc); CalVScrollCurState(&rc,pScrollInfo,pWin->pVCurState); } else{ wndGetHScrollBarRect(hWnd,&rc); CalHScrollCurState(&rc,pScrollInfo,pWin->pHCurState); } } else{ if(nBar == SB_VERT){ wndGetVScrollBarRect(hWnd,&rc); CalVScrollCurState(&rc,pScrollInfo,pWin->pVCurState); } else{ wndGetHScrollBarRect(hWnd,&rc); CalHScrollCurState(&rc,pScrollInfo,pWin->pHCurState); } } if(bRedraw) scrInvalidateRect(hWnd,NULL,true); return true;}BOOL IsVScrollBar( HWND hWnd){ PWindowsTree pWin; pWin=(PWindowsTree)hWnd; if(pWin->dwStyle & WS_VSCROLL) return true; else return false;}BOOL IsHScrollBar( HWND hWnd){ PWindowsTree pWin; pWin=(PWindowsTree)hWnd; if(pWin->dwStyle & WS_HSCROLL) return true; else return false;}static BOOL ScrollBarIsEnable( LPSCROLLINFO lpsi){ if(lpsi->dwStatus & SS_DISABLED) return false; else return true;}static LPSCROLLINFO wndGetScrollBar ( HWND hWnd, int iSBar){ PWindowsTree pWin; pWin = (PWindowsTree)hWnd; if (iSBar == SB_HORZ) { if (pWin->dwStyle & WS_HSCROLL) return pWin->pHScroll; } else if (iSBar == SB_VERT) { if (pWin->dwStyle & WS_VSCROLL) return pWin->pVScroll; } return NULL;}//get ok button rect screen coordsys void wndGetOkButtonRect( HWND hWnd, LPRECT lpRect){ int iOkButtonWidth,iCloseBoxWidth; RECT rcCaption; wndGetCaptionRect(hWnd,&rcCaption); if(!IsOkButton(hWnd)){ SetRect(lpRect,0,0,0,0); return; } iOkButtonWidth = WIN_OKBUTTON_WIDTH; if(IsCloseBox(hWnd)){ iCloseBoxWidth = WIN_CLOSEBOX_WIDTH; } else{ iCloseBoxWidth = 0; } SetRect(lpRect,rcCaption.right - iOkButtonWidth - iCloseBoxWidth, rcCaption.top, rcCaption.right - iCloseBoxWidth,rcCaption.bottom);}//get Close box rect screen coordsysvoid wndGetCloseBoxRect( HWND hWnd, LPRECT lpRect){ RECT rcCaption; wndGetCaptionRect(hWnd,&rcCaption); if(!IsCloseBox(hWnd)){ SetRect(lpRect,0,0,0,0); return; } SetRect(lpRect,rcCaption.right - WIN_CLOSEBOX_WIDTH,rcCaption.top, rcCaption.right,rcCaption.bottom);}void CloseBoxPenDownProc( HWND hWnd){ PWindowsTree pWin; RECT rc; pWin = (PWindowsTree)hWnd; pWin->dwStyle |= WS_CLOSEBOXPRESSED; //invalidte wndGetCloseBoxRect(hWnd,&rc); scrInvalidateRect(hWnd, &rc, true); }void OkButtonPenDownProc( HWND hWnd){ PWindowsTree pWin; RECT rc; pWin = (PWindowsTree)hWnd; pWin->dwStyle |= WS_OKBUTTONPRESSED; //invalidte wndGetOkButtonRect(hWnd,&rc); scrInvalidateRect(hWnd, &rc, true); }void CloseBoxPenUpProc( HWND hWnd){ PWindowsTree pWin; RECT rc; pWin = (PWindowsTree)hWnd; pWin->dwStyle = pWin->dwStyle & ~WS_CLOSEBOXPRESSED; //invalidte wndGetCloseBoxRect(hWnd,&rc); scrInvalidateRect(hWnd, &rc, true); //send message SendNotifyMessage(hWnd,LMSG_CLOSE,(WPARAM)NULL,(LPARAM)NULL); }void OkButtonPenUpProc( HWND hWnd){ PWindowsTree pWin; RECT rc; pWin = (PWindowsTree)hWnd; pWin->dwStyle = pWin->dwStyle & ~WS_OKBUTTONPRESSED; //invalidte wndGetOkButtonRect(hWnd,&rc); scrInvalidateRect(hWnd, &rc, true); //send message SendNotifyMessage(hWnd,LMSG_OK,(WPARAM)NULL,(LPARAM)NULL); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -