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
S

Shibu Krishnan

@Shibu Krishnan
About
Posts
6
Topics
1
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • I want to create a treeview with my structure/class variable as nodes and update the same with custom values
    S Shibu Krishnan

    Yes exactly. So this design will not work for this requirement. is it? any how thank you for the interest and help provided.

    C / C++ / MFC help question announcement

  • I want to create a treeview with my structure/class variable as nodes and update the same with custom values
    S Shibu Krishnan

    As my actual structure is pretty huge as I mentioned earlier, designing a form with label & textbox for each one is difficult. So I planned to use treeview to list the items and one text box to enter value. my form is simple with 1 treeview, label and textbox. in this case,my requirement is when i select the treeitem, associated value has to be displayed in a label and change the value through text box. Hope you are clear with my struct.

    C / C++ / MFC help question announcement

  • I want to create a treeview with my structure/class variable as nodes and update the same with custom values
    S Shibu Krishnan

    Sorry to post you incomplete question. I mean the address of the variable I am passing in the lParam. But again in my GetDataItem() method, i have to typecast to the corresponding variable. is it? for eg.

    typedef struct address
    {
    CString houseName;
    CString placeName;
    int cnrtyCode;
    char pinCode[6];
    };

    typedef struct node
    {
    CString Name;
    int Age;
    float Height;
    address adrs;
    };

    this is my structure. and

    HTREEITEM hItems, hRoot;
    TVINSERTSTRUCT tvInsert;

    pNode->Name = "Shibu";
    pNode->adrs.cnrtyCode = 91;
    pNode->adrs.houseName = "House No 23";
    pNode->adrs.placeName = "Bnglr";
    pNode->Height = 5.5;	
    pNode->Age = 28;
    
    hRoot	 = m\_tree.InsertItem(\_T("Personal Data"), 0, 1);
    tvInsert.hParent = hRoot;
    tvInsert.hInsertAfter = NULL;
    tvInsert.item.mask = TVIF\_TEXT | TVIF\_PARAM;	
    tvInsert.item.pszText = "Name";
    hItems = m\_tree.InsertItem(&tvInsert);	
    m\_tree.SetItemData(hItems, DWORD(&pNode->Name)); 
    

    .......
    .....
    tvInsert.item.pszText = "Age";
    hItems = m_tree.InsertItem(&tvInsert);
    m_tree.SetItemData(hItems, DWORD(&pNode->Age));

    Now my requirement is when i select the treeitem, associated value has to be displayed in a label. Also i have to change the value (through text box entry ; one text box only) of the selected item. Each value ( name,age etc.) are of different data types. first i tried by passing address of pNode. then how to check my selection (whether user selected name/age/..). Please help me with a code portion.

    C / C++ / MFC help question announcement

  • I want to create a treeview with my structure/class variable as nodes and update the same with custom values
    S Shibu Krishnan

    Yes, I used the SetItemData() and GetItemData() methods with lparam. I am passing the (DWORD). But the variables are of different data types. the value has to be changed for the selected variable. I have lots of fields in the struct and 8 structures are there in the tree. Compare and set values for each fields will be cumbersome. Can you give proper guidance. thank you

    C / C++ / MFC help question announcement

  • I want to create a treeview with my structure/class variable as nodes and update the same with custom values
    S Shibu Krishnan

    Thank you for the answer. I checked the methods to insertitem to treeview. (

    Quote:

    HTREEITEM InsertItem( LPTVINSERTSTRUCT lpInsertStruct ); HTREEITEM InsertItem(UINT nMask, LPCTSTR lpszItem, int nImage, int nSelectedImage, UINT nState, UINT nStateMask, LPARAM lParam, HTREEITEM hParent, HTREEITEM hInsertAfter ) etc..

    So how can I save address of a variable in the node? Can u please share the code segment for the same or any link to the same.

    C / C++ / MFC help question announcement

  • I want to create a treeview with my structure/class variable as nodes and update the same with custom values
    S Shibu Krishnan

    I have some structures in my application (which is pretty big). To test certain error conditions, I have to input wrong values to these variables and send across another system (using udp sockets). How can I use the treeview to populate all the structures and upon user selection of one of the node (the struct variable), i wants to input error values and update the same structure variable in my app. Here is the sample

    Quote:

    hRoot = m_TreeView.InsertItem(_T("Messages"), 0, 1); hMainMsg = m_TreeView.InsertItem("XXXXX", 0, 1, hRoot); hSubMsg = m_TreeView.InsertItem("MsgHdr", 2, 3, hMainMsg); m_TreeView.InsertItem(_T("msgId"), 4, 5, hSubMsg); m_TreeView.InsertItem(_T("InfId"), 4, 5, hSubMsg); m_TreeView.InsertItem(_T("Seq No"), 4, 5, hSubMsg); m_TreeView.InsertItem(_T("msgLen"), 4, 5, hSubMsg); m_TreeView.InsertItem(_T("timeStamp"), 4, 5, hSubMsg);

    in double click event,

    HTREEITEM nodSelected = m_TreeView.GetSelectedItem();
    CString strSelected = m_TreeView.GetItemText(nodSelected);

    HTREEITEM hParent = nodSelected;
    
    while (hParent = m\_TreeView.GetParentItem(hParent))
    {
    	
    	CString strParent    = m\_TreeView.GetItemText(hParent);
    	
    	if (strcmp(strParent,"Messages")==0)
    		break;
    
    	m\_TreeView.SetItemState(hParent, TVIS\_BOLD, TVIS\_BOLD);		
    
    	strSelected = strParent + "." + strSelected;
    }
    
    m\_txtMsg = strSelected + "=";
    

    for ex. m_txtMsg will be now "XXXXX.msgHdr.msgId=" Is there any way to use this text data to assign as my variable Please help.

    C / C++ / MFC help question announcement
  • Login

  • Don't have an account? Register

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