• ### Announcements

#### Archived

This topic is now archived and is closed to further replies.

# Making a treectrl/listctrl split view without mfc

## Recommended Posts

Zeke    122
Im trying to make an app that has a tree of folders on the left side of the splitter and a list of items on the right of the splitter. In fact its pretty much windows explorer (or at the moment it is cos in the future it will become a thumbnail viewer/image repairer). I have already accomplished this with mfc which was a lot of hassle but rather easy. I now want to do this with straight up win32 (to learn win32 without mfc) but Im stuck. Ive got the splitter working(which in itself wasnt particularly easy) so now i need to "turn" the pane on the left into a tree control and the window on the right to a list control...i think. Im pretty new to win32 (other than mfc) so im not too hot on controls at all so any help would be much appreciated. Can anyone give me any hints on how i go about doing this? or point me in the direction of a tutorial or 2? Thanks very much.

##### Share on other sites
Oluseyi    2103
CreateWindowEx is your friend. You''ll probably need the common controls, too. Read the Platform SDK docs (which are available for free downlad, along with all the other enhancements). They''re pretty self-explanatory.

[ GDNet Start Here | GDNet Search Tool | GDNet FAQ | MS RTFM [MSDN] | SGI STL Docs | Google! ]
Thanks to Kylotan for the idea!

##### Share on other sites
Zeke    122
Thanks for the reply. Ive managed to get the list box up and working just in time for me to wonder whether its a list box im actually after. In mfc the CListView and CListCtrl can display the list as 1 of 4 states (just text,text with other info, text with small icons, and text with large icons. But after researching into Listboxes it seems they can only take text which leads me to the conclusion that mfc''s CListCtrl does not use ListBoxes to display items with an icon. But i dont know then what im supposed to be looking for for my thumbnail viewer.

So my question has changed. My new question is how can i put a collection of images inside a window in a row/column format and make it so the window acts as a listbox (i.e. when a user clicks on an image that image is highlighted etc), without having to manually draw to the window and work out the spacing/mouse hit tests etc? Or is there not a control for what im trying to do without mfc?

If anyone can understand what it is im trying to get at id be very grateful for some help as I dont know what to look for in the msdn or search engines.

Thanks very much.

##### Share on other sites
Oluseyi    2103
What you want is a ListView control, not a list box.

  // ListView, ReBar, Toolbar, ComboBoxEx and other controls are classified as// "Windows Common Controls" and must be initialized differently:#include <commctrl.h>#pragma comment( lib, "comctl32.lib" )HWND WINAPI CreateListView( HWND hParentWnd, DWORD dwStyles ){  // Initialization of Common Controls is cumulative  INITCOMMONCONTROLSEX ICCEx = {0};  ICCEx.dwICC  = ICC_LISTVIEW_CLASSES;  ICCEx.dwSize = sizeof(INITCOMMONCONTROLSEX);  if( !InitCommonControlsEx( &ICCEx ) )    return NULL;//  HINSTANCE hInstance = (HINSTANCE)GetModuleHandle(NULL);//  // Create the ListView control:  HWND hwndLV = CreateWindowEx( 0, WC_LISTVIEW, NULL, dwStyles,                  0, 0, 0, 0, hParentWnd, NULL, hInstance, NULL );  if( !hwndLV )    return NULL;//  return hwndLV;}

[ GDNet Start Here | GDNet Search Tool | GDNet FAQ | MS RTFM [MSDN] | SGI STL Docs | Google! ]
Thanks to Kylotan for the idea!