Changing the Font of a ListView's Header Control 

Encapsulation of the ListView's Header control is something that is not included in even the latest versions of Builder or Delphi.  Indeed, when bound to a ListView control, the Header control is somewhat limited.  There are times however, when it is necessary to customize the Header control with unique fonts while preserving the font of the ListView itself. 
  
KEYWORDS: GetDlgItem, Header_SetItem, WM_SETFONT 

 

//in header file 
   TFont *TallHeaderFont; 

 


 
 

//---------------------------------------------------------------------------
//in source... 

__fastcall TForm1::TForm1(TComponent* Owner) 
 : TForm(Owner) 

    TallHeaderFont = new TFont(); 
    TallHeaderFont->Name = "Tahoma"; 
    TallHeaderFont->Size = 24; 

    //Get the Header control's handle 
    HWND HeaderHandle = GetDlgItem(ListView1->Handle, 0); 

    SendMessage(HeaderHandle, WM_SETFONT, 
                (WPARAM)(TallHeaderFont->Handle), (LPARAM)true); 
}