LRESULT CMultiLineEditCanvasWnd::OnEditChanged(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) { if( m_pOwner == NULL ) return 0; // Rearrange the scrollbar int nLineCount = Edit_GetLineCount(m_pOwner->m_pWindow->GetHWND()); if ((nLineCount > 0) && (m_pOwner->m_pWindow->GetVerticalScrollbar() != NULL)) { SCROLLINFO si = {0}; si.cbSize = sizeof(SCROLLINFO); si.fMask = SIF_ALL; if (GetScrollInfo(m_pOwner->m_pWindow->GetHWND(), SB_VERT, &si)) { m_pOwner->m_pWindow->GetVerticalScrollbar()->SetEnabled((si.nMax >= static_cast<int>(si.nPage))); m_pOwner->m_pWindow->GetVerticalScrollbar()->SetScrollRange(si.nMax - si.nMin); m_pOwner->m_pWindow->GetVerticalScrollbar()->SetScrollPos(si.nPos); } } // Copy text back int cchLen = ::GetWindowTextLength(m_pOwner->m_pWindow->GetHWND()) + 1; LPTSTR pstr = static_cast<LPTSTR>(_alloca(cchLen * sizeof(TCHAR))); ASSERT(pstr); ::GetWindowText(m_pOwner->m_pWindow->GetHWND(), pstr, cchLen); m_pOwner->m_sText = pstr; m_pOwner->GetManager()->SendNotify(m_pOwner, _T("textchanged")); return 0; }
LRESULT CMultiLineEditWnd::OnEditChanged(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) { if( m_pOwner == NULL ) return 0; // Copy text back int cchLen = ::GetWindowTextLength(m_hWnd) + 1; LPTSTR pstr = static_cast<LPTSTR>(_alloca(cchLen * sizeof(TCHAR))); ASSERT(pstr); ::GetWindowText(m_hWnd, pstr, cchLen); m_pOwner->m_sText = pstr; m_pOwner->GetManager()->SendNotify(m_pOwner, _T("changed")); return 0; }
LRESULT CMultiLineEditWnd::OnSize(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled) { SCROLLINFO vsi = {0}; vsi.cbSize = sizeof(SCROLLINFO); vsi.fMask = SIF_ALL; SCROLLINFO hsi = {0}; hsi.cbSize = sizeof(SCROLLINFO); hsi.fMask = SIF_ALL; if ((m_pOwner != NULL) && (m_pOwner->GetManager() != NULL) && GetScrollInfo(m_pOwner->m_pWindow->GetHWND(), SB_VERT, &vsi)) { m_pVScrollBar = static_cast<CScrollbarUI*>(m_pOwner->GetManager()->FindControl(_T("vEditScrollbar"))); m_pHScrollBar = static_cast<CScrollbarUI*>(m_pOwner->GetManager()->FindControl(_T("hEditScrollbar"))); if (m_pVScrollBar != NULL) { m_pVScrollBar->SetNotifier(m_pOwner); m_pVScrollBar->SetEnabled(vsi.nMax >= static_cast<int>(vsi.nPage)); m_pVScrollBar->SetScrollRange(vsi.nMax - vsi.nMin); m_pVScrollBar->SetScrollPos(vsi.nPos); } if ((m_pHScrollBar != NULL) && GetScrollInfo(m_pOwner->m_pWindow->GetHWND(), SB_VERT, &hsi)) { m_pHScrollBar->SetNotifier(m_pOwner); m_pVScrollBar->SetEnabled(hsi.nMax >= static_cast<int>(hsi.nPage)); m_pHScrollBar->SetScrollRange(hsi.nMax - hsi.nMin); m_pHScrollBar->SetScrollPos(hsi.nPos); } m_pOwner->SetScrollRange(CSize(hsi.nMax - hsi.nMin, vsi.nMax - vsi.nMin)); } bHandled = FALSE; return 0; }