From: <kr_...@us...> - 2003-08-30 22:57:50
|
Update of /cvsroot/htoolkit/port/src/cbits/Win32 In directory sc8-pr-cvs1:/tmp/cvs-serv28624/port/src/cbits/Win32 Modified Files: Notebook.c Log Message: Add support for icons in Notebook Index: Notebook.c =================================================================== RCS file: /cvsroot/htoolkit/port/src/cbits/Win32/Notebook.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Notebook.c 24 Aug 2003 14:39:00 -0000 1.2 --- Notebook.c 30 Aug 2003 22:57:46 -0000 1.3 *************** *** 30,33 **** --- 30,35 ---- LRESULT CALLBACK HNotebookFunction(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { + LRESULT lResult; + switch (uMsg) { *************** *** 65,69 **** } ! return CallWindowProc(DefTabCtrlProc, hWnd, uMsg, wParam, lParam); } --- 67,84 ---- } ! lResult = CallWindowProc(DefTabCtrlProc, hWnd, uMsg, wParam, lParam); ! ! switch (uMsg) ! { ! case WM_CREATE: ! if (lResult >= 0) ! { ! HIMAGELIST hImageList = ImageList_Create(15, 15, ILC_COLOR, 0, 1); ! SendMessage(hWnd, TCM_SETIMAGELIST, 0, (LPARAM) hImageList); ! } ! break; ! } ! ! return lResult; } *************** *** 251,253 **** res[0] = rect.right-rect.left; res[1] = rect.bottom-rect.top; ! } \ No newline at end of file --- 266,333 ---- res[0] = rect.right-rect.left; res[1] = rect.bottom-rect.top; ! } ! ! void osSetNotebookPageBitmap(WindowHandle window, BitmapHandle bitmap) ! { ! TCITEM item; ! int i, nPos, nImage, nCount; ! HWND hNotebook = GetParent(window); ! ! // find the page position and an index of the old bitmap ! nPos = -1; ! nImage = -1; ! nCount = SendMessage(hNotebook, TCM_GETITEMCOUNT, 0, 0); ! for (i = 0; i < nCount; i++) ! { ! item.mask = TCIF_PARAM | TCIF_IMAGE; ! SendMessage(hNotebook, TCM_GETITEM, i, (LPARAM) &item); ! ! if (((HWND) item.lParam) == window) ! { ! nPos = i; ! nImage = item.iImage; ! break; ! } ! } ! ! // return if the page is not found ! if (nPos < 0) ! return; ! ! if (nImage > 0) ! { ! // remove old bitmap ! ! BOOL bUsed = FALSE; ! for (i = 0; i < nCount; i++) ! { ! item.mask = TCIF_PARAM | TCIF_IMAGE; ! SendMessage(hNotebook, TCM_GETITEM, i, (LPARAM) &item); ! ! if (((HWND) item.lParam) != window && item.iImage == nImage) ! { ! bUsed = TRUE; ! break; ! } ! } ! ! if (!bUsed) ! SendMessage(hNotebook, TCM_REMOVEIMAGE, nImage, 0); ! } ! ! // set new bitmap ! if (bitmap) ! { ! HIMAGELIST hImageList = (HIMAGELIST) SendMessage(hNotebook, TCM_GETIMAGELIST, 0, 0); ! printf("1 %p\n", hImageList); ! item.iImage = ImageList_Add(hImageList, bitmap->hBitmap, bitmap->hBitmap); ! } ! else ! { ! printf("2\n"); ! item.iImage = -1; ! } ! ! printf("iImage=%d %d\n", item.iImage, GetLastError()); ! SendMessage(hNotebook, TCM_SETITEM, nPos, (LPARAM) &item); ! } |