CTreeCtrl ::EnsureVisible

hi all,

I've been using a tree ctrl in a modeless dialog to display some data.

When I call ensurevisible(treeitemhandle) from outside the dialog it
works really well except if the handle is for a child item...

If the handle is for a child item then the scroll only goes to the
root node leaving the child hidden below the node.
this behavior still happens with the node expanded or collapsed before
the call.

No difference if I use SelectSetFirstVisible(treeitemhandle) still
only scrolls to the node.

Any ideas what might be happening or someway to make it work right?
Thanks,
Johnny
0
gbl_user99 (30)
11/5/2004 10:51:39 PM
vc.mfc 33608 articles. 0 followers. Follow

2 Replies
1450 Views

Similar Articles

[PageSpeed] 32

"Johnny" <gbl_user99@hotmail.com> wrote in message
news:fb261790.0411051451.29652cf3@posting.google.com...
> hi all,
>
> I've been using a tree ctrl in a modeless dialog to display some data.
>
> When I call ensurevisible(treeitemhandle) from outside the dialog it
> works really well except if the handle is for a child item...
>
> If the handle is for a child item then the scroll only goes to the
> root node leaving the child hidden below the node.
> this behavior still happens with the node expanded or collapsed before
> the call.
>
> No difference if I use SelectSetFirstVisible(treeitemhandle) still
> only scrolls to the node.
>
> Any ideas what might be happening or someway to make it work right?
> Thanks,
> Johnny

I don't have any idea what went wrong; but a work-around might be to send a
message to your modeless dialog and have it perform the ensure visible.


0
billt61 (145)
11/5/2004 10:58:11 PM
"Bill Thompson" <billt61@rgv.rr.com> wrote in message news:<#QUkfq4wEHA.1984@TK2MSFTNGP14.phx.gbl>...
> "Johnny" <gbl_user99@hotmail.com> wrote in message
> news:fb261790.0411051451.29652cf3@posting.google.com...
> > hi all,
> >
> > I've been using a tree ctrl in a modeless dialog to display some data.
> >
> > When I call ensurevisible(treeitemhandle) from outside the dialog it
> > works really well except if the handle is for a child item...
> >
> > If the handle is for a child item then the scroll only goes to the
> > root node leaving the child hidden below the node.
> > this behavior still happens with the node expanded or collapsed before
> > the call.
> >
> > No difference if I use SelectSetFirstVisible(treeitemhandle) still
> > only scrolls to the node.
> >
> > Any ideas what might be happening or someway to make it work right?
> > Thanks,
> > Johnny
> 
> I don't have any idea what went wrong; but a work-around might be to send a
> message to your modeless dialog and have it perform the ensure visible.
Hi Bill.
I'm not sure what you mean.
 The message is being sent to the tree from a method within the dialog like this:

m_BrowseTree.EnsureVisible(hLastSelected); 

where hLastSelected is the handle of the last tree item selected.
So how would I have the dlg perform the ensure visible?
Thanks, Johnny
0
gbl_user99 (30)
11/9/2004 10:28:30 PM
Reply:

Similar Artilces:

selection in CTreeCtrl
Hello, I have a Tree Control in my application that displays two types of items: type A and type B. I want to implement the following: 1. When user clicks on any item of type A it should be shown as selected and the previously selected item will be deselected - it is actually the default behavior. 2. When user clicks on any item of type B - nothing should happen: the previously selected item remain selected and the clicked item remains deselected. So, actually, I want that the items of type B will never highlighted with a blue band. How can do it? Thanks, Mark. -- Please ...

Bolding or Hilighting node in a CTreeCtrl
I am looking for a way of of bolding, hilighting, or changing the text color for one specific node in a CTreeCtrl. Is this possible? If so, how? You have use an owner draw tree control. Look in here for one: http://www.codeproject.com/treectrl/#Custom+Tree+Controls This one looks useful http://www.codeproject.com/treectrl/colortreectrl.asp AliR. <mr.porteiro.head@gmail.com> wrote in message news:1141668031.681508.117640@u72g2000cwu.googlegroups.com... > I am looking for a way of of bolding, hilighting, or changing the text > color for one specific node in a CTreeCtrl. Is t...

CTreeCtrl EditLabel
Ok here is the problem. I have created an owner drawn tree (CCheckTree). Each node in the tree has a check box beside it. I have derived (CEditableCheckTree) from (CCheckTree). CEditableCheckTree has the edit labels style. When I call the EditLabel function the edit control shows up but when I left click in the edit control the caret isn't placed in the control, I can't select the text, or type into the control. I can right click and paste into the control, but that is just about all. Also if I call the edit control's SetFocus function it never receives focus. I know that I'm o...

CTreeCtrl
I have a CTreeCtrl with a couple of leafs and each leaf has a checkbox associated with it. If the user checks the checkbox of a leaf, how do I determine which leaf was checked? What callback can be used to get the check state of a leaf? NMCLICK msg works but I do not know how to get the current leaf that was clicked on. Does anybody know? Scott O' http://www.it-faq.pl/mskb/261/289.HTM Regards, Victor "ScottyO" <ofriels@abc.com> wrote in message news:ulAhetDREHA.3140@TK2MSFTNGP11.phx.gbl... > I have a CTreeCtrl with a couple of leafs and each leaf has a checkbo...

CTreeCtrl ::EnsureVisible
hi all, I've been using a tree ctrl in a modeless dialog to display some data. When I call ensurevisible(treeitemhandle) from outside the dialog it works really well except if the handle is for a child item... If the handle is for a child item then the scroll only goes to the root node leaving the child hidden below the node. this behavior still happens with the node expanded or collapsed before the call. No difference if I use SelectSetFirstVisible(treeitemhandle) still only scrolls to the node. Any ideas what might be happening or someway to make it work right? Thanks, Johnny "...

How to make out my CTreeCtrl?
Hey,All: I have created an extended class from CTreeCtrl,but I don't know how I can re-design the Scroll bar in the CTreeCtrl.Is there anybody who knows about how to re-design the scroll bar in my extended CTreeCtrl? thanks in advance! ^_^ Carl How are we to know what functionality your "extended" class adds? How are we to know what the scroll bar does that you do not want it to do? If you have a question as to how to perform a particular task, this is a great place to post it. I'm sorry, but I don't see how anyone could offer useful information given the informatio...

CTreeCtrls
Hi all, I was trying to copy one tree control into another, but soon found an error CTreeCtrl x; CTreeCtrl y; //.. load x with stuff y = x; // ERROR - this cannot be done (life is not so simple) Is there a way to do this easily? Thanks. M.P. wrote: > Hi all, > > I was trying to copy one tree control into another, but soon found an > error > > CTreeCtrl x; > CTreeCtrl y; > > //.. load x with stuff > > y = x; // ERROR - this cannot be done (life is not so simple) > > Is there a way to do this easily? No, but I thought it would be fun to try a...

CTreeCtrl ASSERT question?
1) Why do I get a "Debug Assertion Failed!" when I insert an item in the CTreeCtrl as shown below? BOOL CDeviceProp::OnInitDialog() { // TODO: Add extra initialization here mDeviceTreeCtrl.InsertItem( "TEST" ); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } void CDeviceProp::OnTvnSelchangedTree1(NMHDR *pNMHDR, LRESULT *pResult) { LPNMTREEVIEW pNMTreeView = reinterpret_cast<LPNMTREEVIEW>(pNMHDR); // TODO: Add your control notification handler code here *pResult = 0; } 2) Is it poss...

No refresh CTreeCtrl
How to update a CTreeCtrl, without repaint it? So, I refresh only one time and my program becomes more fast. Thanks Carlos ...

Updating CTreeCtrl from other view ?
I have a CTreeCtrl and a 3D render view. With the mouse, I create elements picking in the 3D render view. This elements must be showed in the CTreeCtrl. What is the process to do it? I think 3D render view must send a message to the CTreeCtrl. CTreeCtrl captures it and update itself. But what kind of message and how? On Jul 16, 8:35=A0am, Ravnock <Ravn...@discussions.microsoft.com> wrote: > I have a CTreeCtrl and a 3D render view. > > With the mouse, I create elements picking in the 3D render view. This > elements must be showed in the CTreeCtrl. > > What is the ...

CTreeCtrl SortChildren centers the selection, moves scrollbar
I've encountered a situation where calling SortChildren (or SortChildrenCB) centers the scrollbar of my CTreeView pane for the selected item (even if the scrollbar was all the way to the left) I can't find anything in the knowledge base on microsofts site about this at all. Anyone have any ideas? Thanks -Cindy If I was to guess at what you are trying to say, seems like that your Horizontal Scrollbar gets centered when you sort your treectrl. That's because the selected item at the time of SortChildren call is larger than the width of the window. I think there is only one way...

Vector CTreeCtrl
Hi, I am not able to add an item to a vector of type CTreeCtrl. vector<CTreeCtrl> v; CTreeCtrl obj; v.push_back(obj); throws an error : Error 1 error C2248: 'CObject::CObject' : cannot access private member declared in class 'CObject' C:\Program Files\Microsoft Visual Studio 8\VC\atlmfc\include\afxwin.h 1820 Vector of strings or other regular items works fine. Please let me know if you know the answer to the same. Thanks, Hemanth On May 28, 3:05 pm, Heman...@gmail.com wrote: > Hi, > > I am not able to add an item to a vector of type CTreeCtrl. > > ...

Treversing CTreeCTrl
I want to itereate and get each HTREEITEM of a CTreeCtrl which has many nested levels.How to do that?Ideas and Clues are appreciated. Regards, Vinodh Kumar P Try this: http://www.codeguru.com/treeview/TreeTraversal.shtml There are more in tree traversal section under Treeview control at the same site. -- Ajay Kalra [MVP - VC++] ajaykalra@yahoo.com "Vinodh Kumar" <thecomdeveloper@yahoo.com> wrote in message news:bdoi5f$5vv$1@news.mch.sbs.de... > I want to itereate and get each HTREEITEM of a CTreeCtrl which has many > nested levels.How to do that?Ideas and Clues ar...

Image List in CTreectrl
Hello, I created a simple dialog project to learn how to use images with a CTreectrl object. Below is the code that I am using to load the images and to create the tree control objects. The problem is that all items in the tree control, either selected or not, display the first image in the list instead of the one indexed. What am I missing? My image list is 15 pixels high and 90 pixels wide, containing 6 images. Thanks in Advance. pImg = NULL; CBitmap *pbmImage; pbmImage = new CBitmap; pbmImage->LoadBitmap(IDB_IMAGELIST); pImg = new CImageList; pImg->Create(15,15,IL...

CTreeCtrl DeleteAllItems() causes OnSelChange to fire
I have a very strange problem. I have a function that will fill a CTreeCtrl for me. In this function there is a call to DeleteAllItems() before I start to add new stuff. When DeleteAllItems() get's called, it causes the OnSelectionChange() event to fire. This is where stuff get's weird. In my OnSelectionChange() event, I get a void* to the selected Item's data, then I pass that ptr to the properties controls to display info about the selected item. No big deal. However, I have been getting trashed ptrs in the OnSelectionChange() event and I can't really see why. One thin...

Subclassing CTreeCtrl in CTreeView
I want to use a derived CTreeCtrl in a CTreeView and suppose I must subclass the usual CTreeCtrl to achieve that. How can I subclass the CTreeCtrl (and where should I put the subclassing code)? An example would help much of course "JackRnl" <Hccnet@Runit.Scarlet.nl> wrote in message news:bf9dcf$5jb$1@news.hccnet.nl... > I want to use a derived CTreeCtrl in a CTreeView and suppose I must subclass > the usual CTreeCtrl to achieve that. > How can I subclass the CTreeCtrl (and where should I put the subclassing > code)? > An example would help much of course Jack...

CTreeCtrl, SetItemImage
Hi, What I'm trying to do is that displaying different image when an tree item is selected. I declared a CImageList member variable and added images like this. class CAppContainerView : public CTreeView { protected: // create from serialization only CImageList m_imageList; ......... }; int CAppContainerView::OnCreate(LPCREATESTRUCT lpCreateStruct) { CTreeCtrl &ctrl = GetTreeCtrl(); ................. //Set image list for image drawnig for treeCtrl CBitmap bm1, bm2; m_imageList.Create(16, 14, ILC_COLOR32, 2, 1); bm1.LoadBitmap(IDB_REG_KEY_GENERAL); bm2.LoadBitmap(IDB_...

Question on CTreeCtrl
Hi All, I am having a tree control with checkboxes...i.e multiple select is allowed.I have a delete button which will delete the selected items in the treectrl. The code that i have written is as follows: HTREEITEM pItem = m_nameTree.GetRootItem(); UINT nTreeCount = m_nameTree.GetCount(); for( int i = 0; i < nTreeCount; i++ ) { if ( !pItem) return; if ( m_nameTree.GetCheck(pItem) ) { CString delName = m_nameTree.GetItemText(pItem); m_nameTree.DeleteItem(pItem); } pItem = m_nameTree.GetNextItem(pItem, TVGN_NEXTVISIBLE); } But i see that when...

About CTreeView and CTreeCtrl
Hi there, I would like to apply a derived CTreeCtrl in CMyTreeView which is derived from CTreeView. For that purpose, I refer to the following articles http://www.codeguru.com/doc_view/custom_view.shtml http://www.codeguru.com/doc_view/Control2View.shtml My code of my code are: class CMyTreeView : public CTreeView { protected: CMyTreeView (); DECLARE_DYNCREATE(CMyTreeView ) public: CMyDoc* GetDocument(); CMyTreeCtrl& GetTreeCtrl() const; virtual void OnDraw(CDC* pDC); // overridden to draw this view virtual BOOL PreCreateWindow(CREATESTRUCT& cs); virtual ~CMyTreeVi...

subclassing a CTreeCtrl
All, I'm trying to subclass a CTreeCtrl control with a CHeaderCtrl derived class to obtain the result as in (http://users.pandora.be/bart.de.lathouwer/Untitled-1.jpg) I would subclass the CTreeCtrl derived class to be able to draw 'over' both the header and CTreeCtrl surface. When I subclass my CTreeCtrl derived class it reports that it is already attached. My Ctrl's live in a CWnd derived class. Question: What is the correct way to subclass my CTreeCtrl with my HeaderClass to be able to draw "over" both classes? If not possible what is an alternative? (apart from ...

CtreeCtrl and Win98
Hi I am having problems with CtreeCtrl and Win98. I have a class that derives from CtreeCtrl and i add some functionality to enhance the tree. My code runs fine on Win2K and XP etc but on 98 I dont get the TVN_BEGINDRAG, TVN_SELCHANGED Messages at all. I am using VS .NET 2003 and my application is UNICODE Since .NET 2003 doesnt load in 98 i am just building for 98 on Win2K machine and hoping everything works I have put in messageboxes at various places and they seem to appear whenever i drag from the Tree Control or Change Selection but on 98 Nothing seems to happen Does anyone if the handlin...

EnsureVisible -- the selected node remains hidden under the horz. Scrollbar.
Hi, I tried below code to visible tree control item; I have derived my class from CTreeCtrl. if (stricmp(SelectStr.c_str(), CompareStr.c_str()) == 0) { SelectItem(hItem); EnsureVisible(hItem); } In spite of the code calling EnsureVisible on the tree ctrl, the selected node remains hidden under the horz. Scrollbar. You have to click the down arrow on the vert. scrollbar exactly once to see the (pre)selection. This problem is only when I have horz. Scrollbar on my tree control. Even I tried this one also, //HTREEITEM htreeItm = GetFirstV...

Scrolling in CTreeCtrl
Hi All, I have a unique problem. I am developing a self help kind of an application, for which i am using a CTreeCtrl. Initially the Tree Control will contain a node which has a question and the possible answers to that question as child nodes. Each of these answer nodes will in turn have a question element. Now when the user clicks on one of the answers, it will again add the possible answers as child nodes. Now my problem is when a user clicks on a node, i want to scroll the tree to the right and downwards so that the node that has been currently selected shows up in place of the ...

CTreeCtrl with Clickable Bitmap
Hi, I am new to using MFC, but it's going along alright. I have this CTreeCtrl and I want this bitmap or icon (left of text and right of + or - sign) to be clickable, and a small dialog (like a normal right-click dialog) to pop up. If anyone is familiar with the SelectionTree Control from the Windows Installer, it would look exactly like that. I just want to create a dialog like the SelectionTree, except with a lot more flexibility. Any help appreciated, Josh Add your Images list using the TVSIL_STATE flag instead of TVSIL_NORMAL. Catch the WM_LBUTTONDOWN message in the tree control cla...

how to expand a CTreeCtrl
I want to expand a CTreeCtrl ... ... m_treeRedef.Expand( m_hTreeItem, TVE_EXPAND ); but it doesn't work, why? This may fail if 1. you did not pass a valid not handle (m_hTreeItem 2. The given node does not have any children It may be worthwhile checking on these. ...