Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Need to know how to make a custom control scroll nicely with a CView...

Need to know how to make a custom control scroll nicely with a CView...

Scheduled Pinned Locked Moved C / C++ / MFC
graphicsdata-structurestutorialquestion
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Ben Aldhouse
    wrote on last edited by
    #1

    Hi gang, I've got a custom control (m_HScrollBar1Ex) which I have made appear over a CTreeView derived interface (CLeftView) which moves up and down with the CTreeView object's scrollbar moderately well with a call to my control-positioning function PlaceScrollBar in the OnVScroll 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 default

    if (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
    
    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups