BOOL WINAPI CoolSB_EnableScrollBar(HWND hwnd, int wSBflags, UINT wArrows) { SCROLLBAR *sbar; UINT oldstate; BOOL bFailed = FALSE; if (!CoolSB_IsCoolScrollEnabled(hwnd)) return EnableScrollBar(hwnd, wSBflags, wArrows); if ((wSBflags == SB_HORZ || wSBflags == SB_BOTH) && (sbar = GetScrollBarFromHwnd(hwnd, SB_HORZ))) { oldstate = sbar->fScrollFlags; //clear any existing state, and OR in the disabled flags sbar->fScrollFlags = (sbar->fScrollFlags & ~ESB_DISABLE_BOTH) | wArrows; if (oldstate == sbar->fScrollFlags) bFailed = TRUE; } if ((wSBflags == SB_VERT || wSBflags == SB_BOTH) && (sbar = GetScrollBarFromHwnd(hwnd, SB_VERT))) { oldstate = sbar->fScrollFlags; //clear any existing state, and OR in the disabled flags sbar->fScrollFlags = (sbar->fScrollFlags & ~ESB_DISABLE_BOTH) | wArrows; if (oldstate == sbar->fScrollFlags) bFailed = TRUE; } return !bFailed; }
// // Show or hide the specified scrollbars // BOOL WINAPI CoolSB_ShowScrollBar (HWND hwnd, int wBar, BOOL fShow) { SCROLLBAR *sbar; BOOL bFailed = FALSE; DWORD dwStyle = GetWindowLong(hwnd, GWL_STYLE); if(!CoolSB_IsCoolScrollEnabled(hwnd)) return ShowScrollBar(hwnd, wBar, fShow); if((wBar == SB_HORZ || wBar == SB_BOTH) && (sbar = GetScrollBarFromHwnd(hwnd, SB_HORZ))) { sbar->fScrollFlags = sbar->fScrollFlags & ~CSBS_VISIBLE; sbar->fScrollFlags |= (fShow == TRUE ? CSBS_VISIBLE : 0); //bFailed = TRUE; if(fShow) SetWindowLong(hwnd, GWL_STYLE, dwStyle | WS_HSCROLL); else SetWindowLong(hwnd, GWL_STYLE, dwStyle & ~WS_HSCROLL); } if((wBar == SB_VERT || wBar == SB_BOTH) && (sbar = GetScrollBarFromHwnd(hwnd, SB_VERT))) { sbar->fScrollFlags = sbar->fScrollFlags & ~CSBS_VISIBLE; sbar->fScrollFlags |= (fShow == TRUE ? CSBS_VISIBLE : 0); //bFailed = TRUE; if(fShow) SetWindowLong(hwnd, GWL_STYLE, dwStyle | WS_VSCROLL); else SetWindowLong(hwnd, GWL_STYLE, dwStyle & ~WS_VSCROLL); } if(bFailed) { return FALSE; } else { //DWORD style = GetWindowLong(hwnd, GWL_STYLE); //style |= WS_VSCROLL; //if(s //SetWindowLong(hwnd, GWL_STYLE, style); SetWindowPos(hwnd, 0, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED); return TRUE; } }