2010. december 20., hétfő
Remove the border of a TPageControl
Problem/Question/Abstract:
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.}
unit PageControlEx;
interface
uses
Windows, Messages, Classes, CommCtrl, ComCtrls, Controls;
type
TPageControlEx = class(TPageControl)
private
FThickFrame: Boolean;
procedure SetThickFrame(const Value: Boolean);
protected
procedure WndProc(var Msg: TMessage); override;
procedure CreateParams(var Params: TCreateParams); override;
public
constructor Create(AOwner: TComponent); override;
published
property ThickFrame: Boolean read FThickFrame write SetThickFrame default true;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Extra', [TPageControlEx]);
end;
constructor TPageControlEx.Create(AOwner: TComponent);
begin
inherited;
FThickFrame := True;
{DoubleBuffered := True;}
ParentBackground := False;
end;
procedure TPageControlEx.CreateParams(var Params: TCreateParams);
begin
inherited;
{BorderWidth := 0;}
{Params.Style := Params.Style or WS_POPUP;}
ParentBackground := False;
end;
procedure TPageControlEx.SetThickFrame(const Value: Boolean);
begin
if FThickFrame <> Value then
begin
FThickFrame := Value;
RecreateWnd;
end;
end;
procedure TPageControlEx.WndProc(var Msg: TMessage);
begin
inherited WndProc(Msg);
if not FThickFrame and (Msg.Msg = TCM_ADJUSTRECT) then
with PRect(Msg.LParam)^ do
begin
Left := 0;
Right := ClientWidth;
Top := Top - 8;
Bottom := ClientHeight;
end;
end;
end.
Feliratkozás:
Megjegyzések küldése (Atom)
Nincsenek megjegyzések:
Megjegyzés küldése