//---------------------------------------------------------------------------
//The
goal is to change the style of each TabSheet to
//accomodate
a bitmap (TCIF_IMAGE)...
__fastcall TForm1::TForm1(TComponent*
Owner)
: TForm(Owner)
{
//Get
the current Style
DWORD
dwStyle = GetWindowLong(PageControl1->Handle, GWL_STYLE);
//Add
the "put icon on left" style or TCS_FORCELABELLEFT
//depending on where you want the image
SetWindowLong(PageControl1->Handle,
GWL_STYLE,
dwStyle | TCS_FIXEDWIDTH | TCS_FORCEICONLEFT);
//Change
the attributes of each tab
TC_ITEM
tci;
for
(int index = 0; index < PageControl1->PageCount; index++)
{
//flag the image state
tci.mask = TCIF_TEXT | TCIF_IMAGE;
//add the previously assigned captions
tci.pszText = PageControl1->Pages[index]->Caption.c_str();
int max = PageControl1->Pages[index]->Caption.Length() * sizeof(char);
tci.cchTextMax = max;
tci.iImage = index;
//force the changes
TabCtrl_SetItem(PageControl1->Handle, index, &tci);
}
//associate
an ImageList with the TabControl
PageControl1->Perform(TCM_SETIMAGELIST,
0, (LPARAM)ImageList1->Handle);
}
|