How can I assign / change an icon to a Tabcontrol at runtime?
Background: One of the Tabs contains a listview which is populated from a database. Whenever a change occurs the icon should change to alert the user.
Rolf
No idea anybody?
Hi Rolf, I am still travelling. Will get home tonight around midnight. I should be able to help tomorrow. Maybe try checking the generated source for how FF assigns icons to the tabs.
Thanks Paul.
I didnt saw this before, I would have suggested probably the same as paul. :)
This is what I did so far:
1. I assigned an image to the TabControl in the Designer.
2. At the end of the FormCreate event I get the hWnd of the associated imagelist and add two more imagages.
ihwnd = TabCtrl_GetImageList(HWND_FRMMAIN_TABCONTROL1)
indx = ImageList_AddIcon (hWndITabCtrl, LoadIcon (App.hInstance, "IMAGE_RED16"))
indx = ImageList_AddIcon (hWndITabCtrl, LoadIcon (App.hInstance, "IMAGE_BLUE16"))
3. Try to set the image index to another image. (From Josè's Wrappers)
r = TabCtrl_SetImageIndex(HWND_FRMMAIN_TABCONTROL1, 1)
At compile time I get this error:
"Parameter mismatches definition"
Rolf
Quote
Code: [Select]
r = TabCtrl_SetImageIndex(HWND_FRMMAIN_TABCONTROL1, 1)
At compile time I get this error:
"Parameter mismatches definition"
There is a third parameter that I have forgot to include in the documentation:
iImage - Zero-based index in the tab control's image list, or -1 if there is no image for the tab.
OK, my code so far is:
Local r As Long
Local ihwnd As Dword
Local TabTcItem As TC_ITEM
Local ztmp As Asciiz * %MAX_PATH
ihwnd = TabCtrl_GetImageList(HWND_FRMMAIN_TABCONTROL1)
r = TabCtrl_SetImageIndex(HWND_FRMMAIN_TABCONTROL1,0,ihwnd)
TabTcItem.iImage = 0
TabCtrl_SetItem(HWND_FRMMAIN_TABCONTROL1, 1, TabTcItem)
Unfortunately it just erases the icon from the TabControl.
???
The code is incorrect. You have to build an image list with images for each tab page and set the imagelist with TabCtrl_SetImageList.
If you have done it, the 3rd parameter in TabCtrl_SetImageIndex is not the handle of the image listm but the zero-based index of the image in the image list.
That is, you have to pass the handle of the tab control, the zero-based index of the tab and the zero based-index of the image in the image list.
OK, understood. But is it possible to change the image for Tab0 at runtime?
Rolf
With
TabCtrl_SetImageIndex(HWND_FRMMAIN_TABCONTROL1,0,iImage)
where iImage is the zero-based index of the image in the image list you have set for the tab control.
Yep - Works now.
Thanks a lot, Josè!
Rolf