Jump to content
  • Advertisement
Sign in to follow this  
Pelgar

CTreeCtrl mouse wheel leaves trails

This topic is 3429 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Can anyone tell me how to prevent a CTreeCtrl, with tooltips enabled, from leaving trails in the tree if scrolled with the mouse wheel? I've searched Google and Yahoo as well as these forums for an answer but found nothing about this.

Share this post


Link to post
Share on other sites
Advertisement
I've used treeviews in the past and never had this problem. This is my first attempt at a treeview using MFC. I assumed the trails left when using the wheel was a common problem with CTreeView and/or CTreeCtrl. A lack of any response indicates this may not be the case. I've included a couple of images to show what I'm dealing with.
The top images shows my tree after using the slider to scroll the tree.
The bottom images shows my tree after using the mouse wheel to scroll.





It seems that CTreeView/CTreeCrl is losing track of where a tooltip popped up if it was scrolled across with the mouse wheel. And restores the captured image in the wrong place.

I would really appreciate any help with what to do about this.

Share this post


Link to post
Share on other sites
No idea what actually causes the problem, but you should be able to trap the mouse wheel scroll messages that come to the control, and simply InvalidateRect() the entire control to force a proper redraw.

Share this post


Link to post
Share on other sites
Thanks for the reply ApochPiQ,

Using OnMouseWheel with CTreeCtrl proved erratic to the point of being strange!
Sometimes CTabTreeCtrl::OnMouseWheel was called, sometimes not! I even put a
Beep(800,100); in the code to make sure it was actually not being called. After fooling with it all afternoon I finally moved on and captured V Scroll instead.
InvalidateRect(NULL, TRUE); did the job but was not pretty. Had to much flicker/flash in the view. I ended up disabling tooltips while processing VScroll. This works nicely.

Here is the code for my OnVScroll handler in case someone else runs across this.
CTabTreeCtrl is just a subclass of CTreeCtrl.

void CTabTreeCtrl::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
//get ptr to treeviews tooltips control
CToolTipCtrl* ptoolCtrl = GetToolTips();

ptoolCtrl->Activate(FALSE); //deactivate tooltips
//let CTreeCtrl scroll the view
CTreeCtrl::OnVScroll(nSBCode, nPos, pScrollBar);
ptoolCtrl->Activate(TRUE); //reactivate tooltips

}

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!