Give the need to do a work around for a tab control, I want to save then restore the CEditView
contents. What I do is shown below, and while the scrollbars and position go back to where they were properly, the actual contents of the edit control don't scroll (it is in the upper left like it has never been scrolled). I tried RedrawWindow()
, didn't work. I've been mainly dealing with the horizontal scrollbar, f I just simply click on the horizontal bar the contents jumps to where it should have been.
What am I missing or what is the trick to make it work?
TIA!!
// hack to work around ceditview getting its window contents changed
CView* pview=GetView(tabi);
if (pview->IsKindOf(RUNTIME_CLASS(CEditView))) {
CEditView* peditview=reinterpret_cast<CEditView*>(pview);
CEdit& editctrl=peditview->GetEditCtrl();
int startchar, endchar;
editctrl.GetSel(startchar, endchar);
int nhorzpos=peditview->GetScrollPos(SB_HORZ);
int nvertpos=peditview->GetScrollPos(SB_VERT);
CString strexistingtext;
pview->GetWindowText(strexistingtext);
// change label
tabctrl.SetTabLabel(tabi, strlabel);
// put back text
pview->SetWindowText(strexistingtext);
// put back where we were
peditview->SetScrollPos(SB_VERT, nvertpos);
peditview->SetScrollPos(SB_HORZ, nhorzpos);
editctrl.SetSel(startchar, endchar, TRUE);
}
else {
// change label
tabctrl.SetTabLabel(tabi, strlabel);
}