How to create a TreeView and a ListView

Hello.. Does anyone knows how to create a treeview or a listwiew ?

I read on MSDN but they doesn't provide enough information, I took the example they show but doesn't work..I google them allover the places and no one shows exactly how it works. Does anyone know how to handle them ??
https://www.codeproject.com/articles/3448/using-treecontrol-treeview-under-win32-api

https://www.codeproject.com/articles/2890/using-listview-control-under-win32-api

I can't guarantee the demos listed above will work correctly, MS changed more than a few things in the Win32 API with 64-bit Windows, etc.
I see them all.. the problem is that any of these examples is bring in the code how to add images of the parent and child and that makes the code more complex, and I don't need a treeview with images ..I just want it simple to add few Items that user can select and see what's in the description and that's all.

Like this one shown in the MSDN:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
HWND CreateATreeView(HWND hwnd)
{
    RECT rcClient;

    InitCommonControls();

    GetClientRect(hwnd, &rcClient);
    hwnd = CreateWindowW(WC_TREEVIEWW, L"Tree View", WS_VISIBLE | WS_CHILD | WS_BORDER | TVS_HASLINES,
                        0, 0, rcClient.right, rcClient.bottom, hwnd, (HMENU)ID_TREEVIEW, NULL, NULL);

    if (!InitTreeViewImageLists(hwnd) ||
                !InitTreeViewItems(hwnd))
    {
        DestroyWindow(hwnd);
        return FALSE;
    }
    return hwnd;
}


Who needs a treeview like this. ? That cover the hole area of the entire window, when they could simply:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
HWND CreateATreeView(HWND hwnd)
{
    InitCommonControls();

    hwnd = CreateWindowW(WC_TREEVIEWW, L"Tree View", WS_VISIBLE | WS_CHILD | WS_BORDER | TVS_HASLINES,
                        0, 0, 150, 450, hwnd, (HMENU)ID_TREEVIEW, NULL, NULL);

    if (!InitTreeViewImageLists(hwnd) ||
                !InitTreeViewItems(hwnd))
    {
        DestroyWindow(hwnd);
        return FALSE;
    }
    return hwnd;
}


.. without sizing it. Why they always have to complicate the code when they could simply say .. you have to specify this WC_TREEVIEWW. this is just an example to show you what I meant.

Same thing in other examples ... why they don't show first the code that creates the treeview and then if user wants can add this and that (images, icons.. etc.)
Well however thank you guys for the help.. I'll keep searching.. cheers.
Topic archived. No new replies allowed.