Need to know how to make a custom control scroll nicely with a CView...
-
Hi gang, I've got a custom control (
m_HScrollBar1Ex
) which I have made appear over aCTreeView
derived interface (CLeftView
) which moves up and down with theCTreeView
object's scrollbar moderately well with a call to my control-positioning functionPlaceScrollBar
in theOnVScroll
function. However, the custom control only 'snaps' in to its final position when the left mouse button is released. Ideally I'd like the control to move in absolute synch with the graphics underneath it (ie. the tree control). Is there another message I could respond to which will allow the custom control to draw itself in the right place before the mouse button is released? I'm guessing that the answer is a bit more involved than this - in which case any clues that you can give me will be very much appreciated. Very much looking forward to your replies, Ben.void CLeftView::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
// TODO: Add your message handler code here and/or call defaultif (m\_HScrollBar1Ex.m\_hWnd != NULL){ m\_HScrollBar1Ex.ShowWindow(SW\_HIDE); } PlaceScrollBar(); CTreeView::OnVScroll(nSBCode, nPos, pScrollBar);
}
and
void CLeftView::PlaceScrollBar(void)
{if (m\_bBlockScrollDraw==FALSE){ CRect parentRect; CTreeCtrl &ctlFolders = this->GetTreeCtrl(); ctlFolders.GetWindowRect(&parentRect); ScreenToClient(&parentRect); CRect contRect; //20100902 HTREEITEM hRoot; HTREEITEM hFolder; hRoot = ctlFolders.GetSelectedItem(); CRect heightRect; //20100902 int count=0; int yPos=0; CRect itemRect; if (ctlFolders.ItemHasChildren(hRoot)) { HTREEITEM hNextItem; HTREEITEM hChildItem = ctlFolders.GetChildItem(hRoot); CWnd \* pChild = (CWnd \*) &hChildItem; count = 1; if (ctlFolders.IsTopParentActive()){ DWORD dwData = ctlFolders.GetItemData(hRoot); m\_dw08bCurNodeVisItems = (dwData & 0x000000FF); m\_dw24bCurNodeScrollPos = (dwData & 0xFFFFFF00) >> 8; } else m\_dw24bCurNodeScrollPos = 99; //20100917 temporary allocation //m\_dw08bCurNodeVisItems=12000; ctlFolders.GetItemRect(hChildItem, itemRect, FALSE); while (hChildItem != NULL) { hNextItem = ctlFolders.GetNextItem(hChildItem, TVGN\_NEXT); if (hNextItem != NULL){ count++; } hChildItem = hNextItem; } } if (m\_HScrollBa