Author: Lou Adler How to remove the border of a TPageControl Answer: {TPageControlEx component Copyright (c) 1998 Sigbjoern Revheim, Sigbjoern@mad.scientist.com This component removes the border of the pagecontrol only if there are one ore more tabs.} 1 unit PageControlEx; 2 3 interface 4 5 uses 6 Windows, Messages, Classes, CommCtrl, ComCtrls, Controls; 7 8 type 9 TPageControlEx = class(TPageControl) 10 private 11 FThickFrame: Boolean; 12 procedure SetThickFrame(const Value: Boolean); 13 protected 14 procedure WndProc(var Msg: TMessage); override; 15 procedure CreateParams(var Params: TCreateParams); override; 16 public 17 constructor Create(AOwner: TComponent); override; 18 published 19 property ThickFrame: Boolean read FThickFrame write SetThickFrame default true; 20 end; 21 22 procedure register; 23 24 implementation 25 26 procedure register; 27 begin 28 RegisterComponents('Extra', [TPageControlEx]); 29 end; 30 31 constructor TPageControlEx.Create(AOwner: TComponent); 32 begin 33 inherited; 34 FThickFrame := True; 35 {DoubleBuffered := True;} 36 ParentBackground := False; 37 end; 38 39 procedure TPageControlEx.CreateParams(var Params: TCreateParams); 40 begin 41 inherited; 42 {BorderWidth := 0;} 43 {Params.Style := Params.Style or WS_POPUP;} 44 ParentBackground := False; 45 end; 46 47 procedure TPageControlEx.SetThickFrame(const Value: Boolean); 48 begin 49 if FThickFrame <> Value then 50 begin 51 FThickFrame := Value; 52 RecreateWnd; 53 end; 54 end; 55 56 procedure TPageControlEx.WndProc(var Msg: TMessage); 57 begin 58 inherited WndProc(Msg); 59 if not FThickFrame and (Msg.Msg = TCM_ADJUSTRECT) then 60 with PRect(Msg.LParam)^ do 61 begin 62 Left := 0; 63 Right := ClientWidth; 64 Top := Top - 8; 65 Bottom := ClientHeight; 66 end; 67 end; 68 69 end.