You can get the HWND of a dialog control using:
Code:
hwndTree = GetDlgItem(hDlg, ID_DIRTREE);
You can then use the normal functions for tree-view controls:
Code:
TreeView_InsertItem(hwndTree, &tvi);
Alternatively, you can use SendDlgItemMessage in place of SendMessage:
Code:
SendDlgItemMessage(hDlg, ID_DIRTREE, TVM_DELETEITEM, 0, (LPARAM) hItem);
With this knowledge, you should be able to convert the MSDN sample code to your needs.
This applies to all dialog controls, not just tree-views.
I don't know much about MFC but:
>> tried passing it one and the compiler tells me that it can't convert class "CDialog" to class "CWnd *",<<
No, but it can probably convert a pointer to a CDialog object to a pointer to a CWnd object.