///////////////////////////////////////////////////////////////////////////// // CInputView message handlers void CInputView::OnInitialUpdate() { CEditView::OnInitialUpdate(); // Disable scroll bars and set a text limit of 255 characters EnableScrollBarCtrl( SB_VERT, FALSE ); EnableScrollBarCtrl( SB_HORZ, FALSE ); GetEditCtrl().SetLimitText( 255 ); // Set the focus to this window at startup SetFocus(); }
void CScrollView::UpdateBars() /****************************/ { CRect rectClient; GetClientRect( &rectClient ); int cxVScroll = ::GetSystemMetrics( SM_CXVSCROLL ); int cyHScroll = ::GetSystemMetrics( SM_CYVSCROLL ); BOOL bHadX = GetStyle() & WS_HSCROLL; BOOL bHadY = GetStyle() & WS_VSCROLL; if( !bHadY ) { rectClient.right -= cxVScroll; } if( !bHadX ) { rectClient.bottom -= cyHScroll; } BOOL bHasX = m_totalDev.cx > rectClient.Width(); BOOL bHasY = m_totalDev.cy > rectClient.Height(); int xOld = GetScrollPos( SB_HORZ ); int yOld = GetScrollPos( SB_VERT ); SCROLLINFO si; si.cbSize = sizeof( SCROLLINFO ); si.fMask = SIF_RANGE | SIF_PAGE; si.nMin = 0; si.nMax = m_totalDev.cx; si.nPage = rectClient.Width(); if( !bHasY ) { si.nPage += cxVScroll; } SetScrollInfo( SB_HORZ, &si ); EnableScrollBarCtrl( SB_HORZ, bHasX ); si.nMax = m_totalDev.cy; si.nPage = rectClient.Height(); if( !bHasX ) { si.nPage += cyHScroll; } SetScrollInfo( SB_VERT, &si ); EnableScrollBarCtrl( SB_VERT, bHasY ); int xNew = bHasX ? GetScrollPos( SB_HORZ ) : 0; int yNew = bHasY ? GetScrollPos( SB_VERT ) : 0; if( xOld != xNew ) { ::ScrollWindow( m_hWnd, xOld - xNew, 0, NULL, NULL ); } if( yOld != yNew ) { ::ScrollWindow( m_hWnd, 0, yOld - yNew, NULL, NULL ); } }
void CScrollWnd::SetScaleToFitSize(SIZE sizeTotal) { // Note: It is possible to set sizeTotal members to negative values to // effectively invert either the X or Y axis. ASSERT(m_hWnd != NULL); m_nMapMode = MM_SCALETOFIT; // special internal value m_totalLog = sizeTotal; // reset and turn any scroll bars off if (m_hWnd != NULL && (GetStyle() & (WS_HSCROLL|WS_VSCROLL))) { SetScrollPos(SB_HORZ, 0); SetScrollPos(SB_VERT, 0); EnableScrollBarCtrl(SB_BOTH, FALSE); ASSERT((GetStyle() & (WS_HSCROLL|WS_VSCROLL)) == 0); } CRect rectT; GetClientRect(rectT); m_totalDev = rectT.Size(); if (m_hWnd != NULL) { // window has been created, invalidate UpdateBars(); Invalidate(TRUE); } }
void CBirchCtrl::ResetScrollBar() { // Flag to avoid a call from OnSize while resetting the scrollbar m_bScrollBarMessage = TRUE; CRect rFrame; GetClientRect( rFrame ); // Need for scrollbars? if( rFrame.Height() > m_iDocHeight + 8 ) { ShowScrollBar( SB_VERT, FALSE ); // Hide it SetScrollPos( SB_VERT, 0 ); } else { SCROLLINFO si; si.cbSize = sizeof(SCROLLINFO); si.fMask = SIF_PAGE | SIF_RANGE; si.nPage = rFrame.Height()/*/m_iLineHeight*/; si.nMax = (m_iDocHeight + 8)/*/m_iLineHeight*/; si.nMin = 0 ; SetScrollInfo( SB_VERT, &si ); EnableScrollBarCtrl( SB_VERT, TRUE ); } m_bScrollBarMessage = FALSE; }
bool CLogGraph::attach(UINT id, CWnd* pParent) { CStatic wndStatic; CRect r; if (pParent == NULL || !wndStatic.SubclassDlgItem(id, pParent)) return false; wndStatic.GetWindowRect(&r); pParent->ScreenToClient(&r); if ( !CreateEx( wndStatic.GetExStyle(), NULL, NULL, WS_CHILD | WS_VISIBLE | wndStatic.GetStyle(), r, pParent, id, NULL)) { wndStatic.DestroyWindow(); return false; } wndStatic.DestroyWindow(); EnableScrollBarCtrl(SB_HORZ, TRUE); GetClientRect(&m_rectWnd); calcRect(); SetTimer(11839, 1000, NULL); m_bCreated = true; return true; }
void CScrollView::SetScaleToFitSize( SIZE sizeTotal ) /***************************************************/ { m_nMapMode = -1; m_totalLog.cx = sizeTotal.cx; m_totalLog.cy = sizeTotal.cy; EnableScrollBarCtrl( SB_BOTH, FALSE ); }
int MFCSequenceEditor::OnCreate(LPCREATESTRUCT lpCreateStruct ) { EnableScrollBarCtrl(SB_VERT); EnableScrollBarCtrl(SB_HORZ); bounds.left = 0; bounds.top = 0; bounds.right = lpCreateStruct->cx; bounds.bottom = lpCreateStruct->cy; frame.left = lpCreateStruct->x; frame.top = lpCreateStruct->y; frame.right = frame.left+bounds.right; frame.bottom = frame.top+bounds.bottom; SetHVScroll(); target.Register(this); return CScrollView::OnCreate(lpCreateStruct); }
// Automatically enable or disable a scroll bar void StaticEdit::AutoScrollBar(int bar) { // Try the vertical scroll bar first if using both if (bar == SB_BOTH) { EnableScrollBarCtrl(SB_HORZ, false); EnableScrollBarCtrl(SB_VERT, true); if (GetScrollLimit(SB_VERT) == 0) { EnableScrollBarCtrl(SB_VERT, false); } } // Try the horizontal scroll bar if ((bar == SB_HORZ) || (bar == SB_BOTH)) { EnableScrollBarCtrl(SB_HORZ, true); if (GetScrollLimit(SB_HORZ) == 0) { EnableScrollBarCtrl(SB_HORZ, false); } } // Try the vertical scroll bar if ((bar == SB_VERT) || (bar == SB_BOTH)) { EnableScrollBarCtrl(SB_VERT, true); if (GetScrollLimit(SB_VERT) == 0) { EnableScrollBarCtrl(SB_VERT, false); } } }
void CXTPCoreTreeControl::UpdateScrollBar() { if (m_bInUpdateScrollBar) return; m_bInUpdateScrollBar = TRUE; CXTPClientRect rc(this); m_bScrollVisible = rc.Height() < m_nClientHeight; if (m_bScrollVisible) { ShowScrollBar(SB_VERT, TRUE); SCROLLINFO si ; si.cbSize = sizeof(SCROLLINFO) ; si.fMask = SIF_PAGE | SIF_RANGE ; GetScrollInfo(SB_VERT, &si, si.fMask); UINT nControlHeight = (UINT)rc.Height(); if (si.nPage != nControlHeight || si.nMax != m_nClientHeight - 1 || si.nMin != 0) { si.nPage = nControlHeight ; si.nMax = m_nClientHeight - 1; si.nMin = 0 ; si.fMask = SIF_PAGE | SIF_RANGE ; SetScrollInfo(SB_VERT, &si) ; } EnableScrollBarCtrl(SB_VERT, TRUE); } else { SetScrollPos(SB_VERT, 0); ShowScrollBar(SB_VERT, FALSE); } m_bInUpdateScrollBar = FALSE; }
bool CLogGraph::create(UINT id, CWnd* pParent) { Create("LogGraph", "LogGraph", WS_CHILD | WS_VISIBLE , CRect(0,0,0,0) , pParent, 0); // if ( !CreateEx(0, NULL, NULL, WS_CHILD | WS_VISIBLE , // CRect(0,0,0,0) , pParent, id, NULL)) // { // // return false; // } m_nID = id; EnableScrollBarCtrl(SB_HORZ, TRUE); GetClientRect(&m_rectWnd); calcRect(); SetTimer(11839, 1000, NULL); m_ctrTooltip.Create(this, TTS_ALWAYSTIP|TTS_NOPREFIX); m_ctrTooltip.SetDelayTime(50); m_ctrTooltip.Activate(TRUE); m_bCreated = true; return true; }
void CScrollWnd::UpdateBars() { // UpdateBars may cause window to be resized - ignore those resizings if (m_bInsideUpdate) return; // Do not allow recursive calls // Lock out recursion m_bInsideUpdate = TRUE; // update the horizontal to reflect reality // NOTE: turning on/off the scrollbars will cause 'OnSize' callbacks ASSERT(m_totalDev.cx >= 0 && m_totalDev.cy >= 0); CRect rectClient; BOOL bCalcClient = TRUE; // allow parent to do inside-out layout first CWnd* pParentWnd = GetParent(); if (pParentWnd != NULL) { // if parent window responds to this message, use just // client area for scroll bar calc -- not "true" client area if ((BOOL)pParentWnd->SendMessage(WM_RECALCPARENT, 0, (LPARAM)(LPCRECT)&rectClient) != 0) { // use rectClient instead of GetTrueClientSize for // client size calculation. bCalcClient = FALSE; } } CSize sizeClient; CSize sizeSb; if (bCalcClient) { // get client rect if (!GetTrueClientSize(sizeClient, sizeSb)) { // no room for scroll bars (common for zero sized elements) CRect rect; GetClientRect(&rect); if (rect.right > 0 && rect.bottom > 0) { // if entire client area is not invisible, assume we have // control over our scrollbars EnableScrollBarCtrl(SB_BOTH, FALSE); } m_bInsideUpdate = FALSE; return; } } else { // let parent window determine the "client" rect GetScrollBarSizes(sizeSb); sizeClient.cx = rectClient.right - rectClient.left; sizeClient.cy = rectClient.bottom - rectClient.top; } // enough room to add scrollbars CSize sizeRange; CPoint ptMove; CSize needSb; // get the current scroll bar state given the true client area GetScrollBarState(sizeClient, needSb, sizeRange, ptMove, bCalcClient); if (needSb.cx) sizeClient.cy -= sizeSb.cy; if (needSb.cy) sizeClient.cx -= sizeSb.cx; // first scroll the window as needed ScrollToDevicePosition(ptMove); // will set the scroll bar positions too // this structure needed to update the scrollbar page range SCROLLINFO info; info.fMask = SIF_PAGE|SIF_RANGE; info.nMin = 0; // now update the bars as appropriate EnableScrollBarCtrl(SB_HORZ, needSb.cx); if (needSb.cx) { info.nPage = sizeClient.cx; info.nMax = m_totalDev.cx-1; if (!SetScrollInfo(SB_HORZ, &info, TRUE)) SetScrollRange(SB_HORZ, 0, sizeRange.cx, TRUE); } EnableScrollBarCtrl(SB_VERT, needSb.cy); if (needSb.cy) { info.nPage = sizeClient.cy; info.nMax = m_totalDev.cy-1; if (!SetScrollInfo(SB_VERT, &info, TRUE)) SetScrollRange(SB_VERT, 0, sizeRange.cy, TRUE); } // remove recursion lockout m_bInsideUpdate = FALSE; }
void CXTPPropertyPage::UpdateBars() { if (m_totalDev == CSize(0, 0) || !m_bCreated) return; // UpdateBars may cause window to be resized - ignore those resizings if (m_bInsideUpdate) return; // Do not allow recursive calls // Lock out recursion m_bInsideUpdate = TRUE; // update the horizontal to reflect reality // NOTE: turning on/off the scrollbars will cause 'OnSize' callbacks ASSERT(m_totalDev.cx >= 0 && m_totalDev.cy >= 0); CRect rectClient; BOOL bCalcClient = TRUE; CSize sizeClient; CSize sizeSb; // get client rect if (!GetTrueClientSize(sizeClient, sizeSb)) { // no room for scroll bars (common for zero sized elements) CRect rect; GetClientRect(&rect); if (rect.right > 0 && rect.bottom > 0) { // if entire client area is not invisible, assume we have // control over our scrollbars EnableScrollBarCtrl(SB_BOTH, FALSE); } m_bInsideUpdate = FALSE; return; } // enough room to add scrollbars CSize sizeRange; CPoint ptMove; CSize needSb; // get the current scroll bar state given the true client area GetScrollBarState(sizeClient, needSb, sizeRange, ptMove, bCalcClient); if (needSb.cx) sizeClient.cy -= sizeSb.cy; if (needSb.cy) sizeClient.cx -= sizeSb.cx; // first scroll the window as needed ScrollToDevicePosition(ptMove); // will set the scroll bar positions too // this structure needed to update the scrollbar page range SCROLLINFO info; info.fMask = SIF_PAGE|SIF_RANGE; info.nMin = 0; // now update the bars as appropriate EnableScrollBarCtrl(SB_HORZ, needSb.cx); if (needSb.cx) { info.nPage = sizeClient.cx; info.nMax = m_totalDev.cx-1; if (!SetScrollInfo(SB_HORZ, &info, TRUE)) SetScrollRange(SB_HORZ, 0, sizeRange.cx, TRUE); } EnableScrollBarCtrl(SB_VERT, needSb.cy); if (needSb.cy) { info.nPage = sizeClient.cy; info.nMax = m_totalDev.cy-1; if (!SetScrollInfo(SB_VERT, &info, TRUE)) SetScrollRange(SB_VERT, 0, sizeRange.cy, TRUE); } // remove recursion lockout m_bInsideUpdate = FALSE; }