使用c的对象树?

时间:2012-07-03 09:08:54

标签: c windows

我使用此代码列出进程:

       //Creating ListBox
        hPNList=CreateWindow(TEXT("ListBox"),TEXT(""),WS_CHILD|WS_VISIBLE|LBS_SORT|LBS_NOTIFY,30,132,185,380,hWnd,(HMENU)PNLIST_ID,
        GetModuleHandle(NULL),NULL);

        //changing Font
        SendMessage( hPNList ,WM_SETFONT ,(WPARAM) GetStockObject(DEFAULT_GUI_FONT ),TRUE);

        //making list
        ProcessCount =getprocesslist(pro);

        //adding to list  
        for ( i = 0; i < ProcessCount; i++) 
        { 
            int pos = (int)SendMessage(hPNList, LB_ADDSTRING, 0, 
                (LPARAM) pro[i].szExeFile); 
            // Set the array index of the player as item data.
            // This enables us to retrieve the item from the array
            // even after the items are sorted by the list box.
            SendMessage(hPNList, LB_SETITEMDATA, pos, (LPARAM) pro[i].th32ProcessID ); 
        } 

现在我想以树形式展示它。任何人都可以帮我怎么做?

1 个答案:

答案 0 :(得分:1)

有关如何在Windows中使用本机树视图控件的一般概述,请参阅Using Tree-View Controls。特别是,请参阅How to Add Tree-View Items以获取有关如何将项目层次结构添加到树视图的代码示例。

归结为:

  1. 在指定CreateWindow作为窗口类
  2. 时使用WC_TREEVIEW功能
  3. TVM_INSERTITEM消息发送到树窗口,用树项填充它。