> Jeg har prøvet med tabsheet.enabled:= false, men det giver ikke ønsket
> effekt.
En løsning kunne være nedenstående. Der findes dog gratis alternativer
derude. Prøv at kigge
http://www.delphi-jedi.org/.
/Brian
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls;
type
TForm1 = class(TForm)
PageControl1: TPageControl;
TabSheet1: TTabSheet;
TabSheet2: TTabSheet;
TabSheet3: TTabSheet;
procedure PageControl1Changing(Sender: TObject;
var AllowChange: Boolean);
procedure PageControl1Change(Sender: TObject);
procedure PageControl1DrawTab(Control: TCustomTabControl;
TabIndex: Integer; const Rect: TRect; Active: Boolean);
private
FLastPageIndex: Integer;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
constructor TForm1.Create(AOwner: TComponent);
begin
inherited;
PageControl1.OwnerDraw := True;
end;
destructor TForm1.Destroy;
begin
inherited;
end;
procedure TForm1.PageControl1Changing(Sender: TObject;
var AllowChange: Boolean);
begin
FLastPageIndex := TPageControl(Sender).ActivePageIndex;
end;
procedure TForm1.PageControl1Change(Sender: TObject);
begin
if not TPageControl(Sender).ActivePage.Enabled then
TPageControl(Sender).ActivePageIndex := FLastPageIndex;
end;
procedure TForm1.PageControl1DrawTab(Control: TCustomTabControl;
TabIndex: Integer; const Rect: TRect; Active: Boolean);
begin
// Her må du selv lege, så du viser teksten enabled og disabled afhængig
af TTabSheet'ens status (o;
end;
end.