Board index » delphi » D3: Text background color in a TTreeView component ????

D3: Text background color in a TTreeView component ????

Hi,

The text background color in my D3 - TTreeView component stays white
regardless of:
  TTreeView.Color
  TTreeView.Brush.Color
  TTreeView.Font.Color
  ParentFont and
  ParentColor.

Does anybody recognize this problem? - help is appreciated :-)

Carl-H. / 91341...@mobilpost.com

 

Re:D3: Text background color in a TTreeView component ????


Have you tried to use the API call "SetBkGround(TreeView.Canvas.Handle,
Color)"
Quote
"Carl-H. Pedersen" wrote:
> Hi,

> The text background color in my D3 - TTreeView component stays white
> regardless of:
>   TTreeView.Color
>   TTreeView.Brush.Color
>   TTreeView.Font.Color
>   ParentFont and
>   ParentColor.

> Does anybody recognize this problem? - help is appreciated :-)

> Carl-H. / 91341...@mobilpost.com

Re:D3: Text background color in a TTreeView component ????


I had same problem.  "Stealing" the following VCL code from my CBuilder 4 and
putting it into COMCTRLS.PAS fixed the problem for me on Win 95.  Still didn't
work on NT4 until I downloaded latest COMCTRL dlls from microsoft.com

const
  TVM_SETBKCOLOR     = TV_FIRST + 29;
  TVM_SETTEXTCOLOR   = TV_FIRST + 30;

function TreeView_SetBkColor(hwnd: HWND; clr: COLORREF): COLORREF;
begin
  Result := COLORREF(SendMessage(hwnd, TVM_SETBKCOLOR, 0, LPARAM(clr)));
end;

function TreeView_SetTextColor(hwnd: HWND; clr: COLORREF): COLORREF;
begin
  Result := COLORREF(SendMessage(hwnd, TVM_SETTEXTCOLOR, 0, LPARAM(clr)));
end;

procedure TCustomTreeView.CreateWnd;
begin
  FStateChanging := False;
  inherited CreateWnd;
  TreeView_SetBkColor(Handle, ColorToRGB(Color));         /////  added
  TreeView_SetTextColor(Handle, ColorToRGB(Font.Color));  /////  added
  if FMemStream <> nil then
  begin
    Items.ReadData(FMemStream);
    FMemStream.Destroy;
    FMemStream := nil;
    SetTopItem(Items.GetNodeFromIndex(FSaveTopIndex));
    FSaveTopIndex := 0;
    SetSelection(Items.GetNodeFromIndex(FSaveIndex));
    FSaveIndex := 0;
  end;
  if FSaveIndent <> -1 then Indent := FSaveIndent;
  if (Images <> nil) and Images.HandleAllocated then
    SetImageList(Images.Handle, TVSIL_NORMAL);
  if (StateImages <> nil) and StateImages.HandleAllocated then
    SetImageList(StateImages.Handle, TVSIL_STATE);
end;

Good luck,

Jim

Other Threads