Главная страница | назад

Article #17145: Changing the color of a TStatic label

 Question and Answer Database

FAQ2145C.txt   Changing the color of a TStatic label
Category   :OWL
Platform    :All
Product    :C++Builder  3.x

I want to change the background color of my TStatic control.  How
do I do this?

Place the following function in your client dialog class
(this overrides the parent's function):

HBRUSH TDlgClient::EvCtlColor(HDC dc, HWND hWndChild, uint ctlType)
  // call parent function
  HBRUSH result = TDialog::EvCtlColor(dc, hWndChild, ctlType);
  // This function gets called for every control periodically, 
  // so test for a particular control
  if (hWndChild == yourStaticControl->HWindow){

     // Sets color of background behind text
     ::SetBkColor(dc, TColor (r, g, b));

     // Sets color of non-text area
     result = CreateSolidBrush(RGB (r, g, b));                  

  return result;

7/2/98 10:32:32 AM

Last Modified: 01-SEP-99