PageControl - sem bordas

Top  Previous  Next

Question/Problem/Abstract:

 

PageControl's is easy to use when designing different pages inside a form, but the anoying border around the control makes it hard to design Windows2000 like menus etc. 

 

Install the unit enclosed here, and the use the new PageControl instead of your old. As you can see we override the AdjustClientRect to prevent setting the internal border of the control. 

 

Btw. If you have a form with lot'of components you can view the form as text, then change all TPageControl's to TEasyPageControl for faster changes. 

Answer:

 

 

unit EasyPageControl; 

 

interface 

 

uses 

  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, 

  ComCtrls; 

 

type 

  TEasyPageControl = class(TPageControl) 

  private 

    { Private declarations } 

    fTabHeight : Integer; 

 

    Procedure SetTabHeight(NewTabHeight: Integer); 

  protected 

    { Protected declarations } 

  public 

    { Public declarations } 

    Constructor TEasyPageControl.Create(AOwner: TComponent); override; 

 

    Procedure AdjustClientRect(var Rect: TRect); override; 

  published 

    { Published declarations } 

    Property TabHeight: Integer read fTabHeight write SetTabHeight; 

  end; 

 

procedure Register; 

 

implementation 

 

procedure Register; 

begin 

  RegisterComponents('EasyWare', [TEasyPageControl]); 

end; 

 

Constructor TEasyPageControl.Create(AOwner: TComponent); 

Begin 

   Inherited; 

 

   fTabHeight := 0; 

End; 

 

Procedure TEasyPageControl.AdjustClientRect(var Rect: TRect); 

Begin 

   IF (csDesigning in ComponentState) Then 

   Begin 

      Inherited AdjustClientRect(Rect); 

   End 

    Else Rect.Top := Rect.Top + fTabHeight; 

End; 

 

Procedure TEasyPageControl.SetTabHeight(NewTabHeight: Integer); 

Begin 

   IF (NewTabHeight <> fTabHeight) Then 

   Begin 

      fTabHeight := NewTabHeight; 

      Invalidate; 

   End; 

End; 

 

End.