Link to home
Start Free TrialLog in
Avatar of nnbbb09
nnbbb09

asked on

Controlling the available client area of a control

I'm writing a new control that inherits from TCustomPanel and it will draw a Caption area similar to a Form at the top of the panel. However when components are dropped on the panel they can overwrite this Caption area.
Is there someway of controlling the available client area of a control

Thanks

Jo
Avatar of Cynna
Cynna

Didn't test it, but reducing your component client area should work. To do this, override GetClientRect method like this:



// .....

protected
 function GetClientRect: TRect; override;


// .....

function TmyPanel.GetClientRect: TRect;
begin
  with Result do begin
       Left     := Self.Left;
       Top      := CaptionAreaHeight; // <- this will reduce components client area
       Right    := Self.Width;
       Bottom   := Self.Height;
  end;
end

Avatar of nnbbb09

ASKER

Tried it for a descendent of TPanel but the painting of the control was very unpredictable.

Jo
An easier way would be to add another TPanel, align it to Top. :)
ASKER CERTIFIED SOLUTION
Avatar of Cynna
Cynna

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of nnbbb09

ASKER

Cynna,

I went for the second option. It's a great solution and exactly what I'm looking for.

Thanks

Jo