Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Custom drawing background of THeaderControl

Status
Not open for further replies.

djjd47130

Programmer
Nov 1, 2010
480
US
I'm using a THeaderControl to manually draw tabs for dynamically loading pages. The control works perfect for what I need to do, and don't want to change it, except one little problem: It doesn't let me draw over the background. The control stretches across the top of my form, and the sections are programatically managed. I do custom drawing to each section, which works fine, but when I try to draw over the background area where there are no sections, it doesn't do anything. I want this background color to match the parent color, which is following a blue theme, but this header control wants to stay the default gray color.

JD Solutions
 
As I notice with what I'm working on (Delphi 3), the unused section follows the form color. At least what I have here. The sections remain gray (per default in COMCTRLS.PAS it seems). As for filling in the remaining part of a section you ownerdraw, FillRect should do well.

As for other ideas you can try intercepting WM_PAINT (or another message, I'm not sure what triggers it to draw) in the WindowProc of your HeaderControl and try to draw it yourself and see what happens.

(and I happen to have this same problem with another TWinControl descendant, so hopefully we can both figure this out)

It is not possible for anyone to acknowledge truth when their salary depends on them not doing it.
 
I tried using FillRect but that's what's not working. I'm also using runtime themes.

JD Solutions
 
I tried using FillRect but that's what's not working. I'm also using runtime themes.

Earlier, I was able to OwnerDraw the whole cells of what I added to the THeaderControl (making them all blue) but I wasn't able to independently change the color of the remainder of the THeaderControl (it always followed the form color).

From looking at the API documentation, it doesn't look like you can set the Background color to anything other than common form elements. And I wasn't able to find the exact API code which draws this part of the THeaderControl (I think it's actually part of the Win32 API itself?).

I did figure out that I can ownerdraw the control I was interested in out of all of this, so hopefully that will work.

If anyone has any ideas, they are most certainly welcome.

It is not possible for anyone to acknowledge truth when their salary depends on them not doing it.
 
I only had two options: Automatically resize the entire header control based on the sections it contains, or fill in the empty space with an autosized section. Both ways are sloppy, but they will work.

JD Solutions
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top