Using a CTreectrl as a menu 
Author Message
 Using a CTreectrl as a menu

Hi,

I am trying to use a CTreeCtrl as a menu.
Figuring out if there is a child or not works fine.
But the problem is as following

parent 1                 input
   child 1                    order
   child 2                    info request

parent 2                  consultation
   child 1                     order
   child 2                     info request
parent 3                  search
   child 1                     something
parent 4                  quit

And a function needs to be started after pressing (VK_RIGHT again) so
I have do
        if(pTVKeyDown->wVKey==VK_RIGHT){
                HTREEITEM hItem = pCtrl->GetSelectedItem();
                if ((hItem != NULL) && !pCtrl->ItemHasChildren(hItem))
                {      
                        AfxMessageBox(pCtrl->GetItemText(hItem));
                }
         }
That only returns the name of the item (ok, i can also retrieve the
parent).
The problem is that for the first 2 parents the names of the childers
is the same.
But is there way to place a unique number or something like that in
the tree so I know which branch is active. and have a switch-case
construction to start the program.
Or do I have to check the returned string against all the other
possible menu string and check its parent before knowing which
function to start.

Or does somebody has an better idea for a menu that has high contrast
and can be controlled with only the 4 cursor keys?

Regards

Laery



Fri, 19 Nov 2004 22:32:47 GMT  
 Using a CTreectrl as a menu
Set the ItemData to unique values, and test those instead of  the text


Quote:
> Hi,

> I am trying to use a CTreeCtrl as a menu.
> Figuring out if there is a child or not works fine.
> But the problem is as following

> parent 1                 input
>    child 1                    order
>    child 2                    info request

> parent 2                  consultation
>    child 1                     order
>    child 2                     info request
> parent 3                  search
>    child 1                     something
> parent 4                  quit

> And a function needs to be started after pressing (VK_RIGHT again) so
> I have do
> if(pTVKeyDown->wVKey==VK_RIGHT){
> HTREEITEM hItem = pCtrl->GetSelectedItem();
> if ((hItem != NULL) && !pCtrl->ItemHasChildren(hItem))
> {
> AfxMessageBox(pCtrl->GetItemText(hItem));
> }
>          }
> That only returns the name of the item (ok, i can also retrieve the
> parent).
> The problem is that for the first 2 parents the names of the childers
> is the same.
> But is there way to place a unique number or something like that in
> the tree so I know which branch is active. and have a switch-case
> construction to start the program.
> Or do I have to check the returned string against all the other
> possible menu string and check its parent before knowing which
> function to start.

> Or does somebody has an better idea for a menu that has high contrast
> and can be controlled with only the 4 cursor keys?

> Regards

> Laery



Sat, 20 Nov 2004 20:08:45 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Using resource edited menu for a dynamic menu

2. Using ON_UPDATE_COMMAND_UI in Context Menu(pop-up menu)

3. Reducing the Menu.Height when using bitmap menu buttons

4. Context menu for a CTreeCtrl

5. Popup menu for CTreeCtrl

6. Popup Menus in a Dialog CTreeCtrl

7. Need help with CTreeCtrl popup menu

8. Pop-up menu and CTreeCtrl

9. CTreeCtrls with Popup menus

10. Using CTreeCtrl::SetItemData

11. Using CTreeCtrl::EditLabel

12. Changing the font size of a CTreeCtrl's item using NM_CUSTOMDRAW

 

 
Powered by phpBB® Forum Software