Sign in to follow this  

CTreeCtrl mouse wheel leaves trails

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
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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this