//---------------------------------------------------------------------------
//The
goal is to change the style of the Header control to
//accomodate
a bitmap (HDF_BITMAP)...
__fastcall
TForm1::TForm1(TComponent* Owner)
:
TForm(Owner)
{
//Get a handle to the header control
HWND HeaderHandle = GetDlgItem(ListView1->Handle, 0);
//Header control item structure
HD_ITEM hdi;
for (int index = 0; index < ListView1->Columns->Count;
index++)
{
//Get the current format
Header_GetItem(HeaderHandle, index, &hdi);
hdi.mask = HDI_TEXT | HDI_FORMAT | HDI_BITMAP | HDI_WIDTH;
//Flag the bitmap format
hdi.fmt = hdi.fmt | HDF_LEFT | HDF_BITMAP | HDF_STRING;
hdi.pszText = ListView1->Columns->Items[index]->Caption.c_str();
hdi.cchTextMax = ListView1->Columns->Items[index]->Caption.Length();
hdi.cxy = ListView1->Columns->Items[index]->Width;
switch(index)
{
case 0: hdi.hbm = Image1->Picture->Bitmap->Handle;
break;
default: hdi.hbm = Image2->Picture->Bitmap->Handle;
break;
}
//Force the changes
Header_SetItem(HeaderHandle, index, &hdi);
}
}
|