I have a treeview in my program for which I am adding a bitmap of an open and closed folders. I have included messageboxes to show where the program fails. It fails at the loadbitmap function. I appreciate it if anybody can tell me what is wrong. Below is the code.
hTreeView = CreateWindowEx(0, WC_TREEVIEW, (LPCTSTR)NULL,
WS_CHILD | WS_VISIBLE | WS_THICKFRAME | TVS_HASBUTTONS | TVS_HASLINES
| TVS_LINESATROOT | TVS_DISABLEDRAGDROP | TVS_TRACKSELECT | TVS_SINGLEEXPAND
| TVS_FULLROWSELECT, 0, wndHeight(hToolBar), rcClient.right / 5,
rcClient.bottom - wndHeight (hToolBar) - wndHeight (hStatusBar),
hwnd, (HMENU)IDC_TREEVIEW, GetModuleHandle(NULL), NULL);
hImageList = ImageList_Create (16, 16, ILC_COLOR16, 2,4);
if (hImageList == FALSE)
MessageBox (NULL, TEXT ("Could not create image list"),
TEXT ("WARNING"), MB_ICONERROR) ;
hBitMap = LoadBitmap (((LPCREATESTRUCT) lParam)->hInstance, MAKEINTRESOURCE(IDB_TREE));
if (hBitMap == NULL)
MessageBox (NULL, TEXT ("Could not load bitmap into image list"),
TEXT ("WARNING"), MB_ICONERROR) ;
ImageList_Add (hImageList, hBitMap, NULL);
DeleteObject (hBitMap);
if (ImageList_GetImageCount(hImageList) < 2)
MessageBox (NULL, TEXT ("Could not add images to list"),
TEXT ("WARNING"), MB_ICONERROR) ;
SendMessage (GetDlgItem(hwnd, IDC_TREEVIEW), TVM_SETIMAGELIST,
0, (LPARAM)hImageList);
So basically I get the second error messagebox that says: "Could not load bitmap into image list"
Thank you in advance.