Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2005.06.29;
Скачать: CL | DM;

Вниз

Проблема мигания   Найти похожие ветки 

 
Seldon ©   (2004-06-23 00:05) [0]

Я пишу аналог TNotebook но с возможностью создания страниц в runtime.
Создаю нескольких страниц и размещению на них TRichEdit с Align=alClient. При переключении страниц наблюдается мигание. Как от него избавиться? Установка DoubleBuffered:=true не помагает.
Вот код:


unit MyPanel;
interface

uses
 Classes, Controls, Contnrs;
 
type
 TMyPage=class(TCustomControl)
 public
   constructor Create(AOwner:TComponent); override;
 end;
 
 TMyPanel = class(TCustomControl)
 private
   fPages:TObjectList;
   fPageIndex: Integer;
   function GetPage(Index: Integer): TMyPage;
   procedure SetPageIndex(const Value: Integer);
   function CheckIndex(Index:Integer):Boolean;
 public
   constructor Create(AOwner:TComponent); override;
   destructor Destroy; override;
   function Add:TMyPage;
   procedure Delete(Index:Integer);
   property Pages[Index: Integer]: TMyPage read GetPage;
   property PageIndex:Integer read fPageIndex write SetPageIndex default -1;
 published
   property Align;
 end;
 
procedure Register;
implementation

procedure Register;
begin
 RegisterComponents("Standard", [TMyPanel]);
end;

function TMyPanel.Add: TMyPage;
var
 NewPage:TMyPage;
begin
 NewPage:=TMyPage.Create(Self);
 NewPage.Parent:=Self;
 NewPage.Align:=alClient;
 fPages.Add(NewPage);
 Result:=NewPage;
end;

function TMyPanel.CheckIndex(Index: Integer): Boolean;
begin
 Result:=(Index>=0)and(Index<fPages.Count)
end;

constructor TMyPanel.Create(AOwner: TComponent);
begin
 inherited;
 fPages:=TObjectList.Create;
 fPageIndex:=-1;
end;

procedure TMyPanel.Delete(Index: Integer);
begin
 fPages.Delete(Index);
end;

destructor TMyPanel.Destroy;
begin
 fPages.Free;
 inherited;
end;

function TMyPanel.GetPage(Index: Integer): TMyPage;
begin
 if CheckIndex(Index) then
   Result:=TMyPage(fPages[Index])
 else
   Result:=nil;
end;

procedure TMyPanel.SetPageIndex(const Value: Integer);
begin
 if CheckIndex(Value)or(Value=-1) then
 begin
   if CheckIndex(fPageIndex) then
     TMyPage(fPages[fPageIndex]).Visible:=false;
   fPageIndex := Value;
   if CheckIndex(fPageIndex) then
     TMyPage(fPages[fPageIndex]).Visible:=true;
 end;
end;

constructor TMyPage.Create(AOwner: TComponent);
begin
 inherited;
 ControlStyle:=ControlStyle+[csAcceptsControls];
 Visible:=false;
end;

end.


Вот код создания RichEdit"ов:


procedure TForm1.FormCreate(Sender: TObject);
var
 a:Integer;
begin
 MyPanel1.Add;
 MyPanel1.Add;
 MyPanel1.Add;
 MyPanel1.Add;
 for a:=0 to 3 do
   with TRichEdit.Create(MyPanel1.Pages[a]) do
   begin
     Parent:=MyPanel1.Pages[a];
     Align:=alClient;
   end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
 MyPanel1.PageIndex:=MyPanel1.PageIndex+1;
end;


 
GrayFace ©   (2004-06-27 09:15) [1]

Надо так:

procedure TMyPanel.SetPageIndex(const Value: Integer);
begin
if CheckIndex(Value)or(Value=-1) then
begin
  if CheckIndex(Value) then
    TMyPage(fPages[Value]).Visible:=true;
  if CheckIndex(fPageIndex) then
    TMyPage(fPages[fPageIndex]).Visible:=false;
  fPageIndex := Value;
end;
end;


 
Seldon ©   (2004-06-27 12:44) [2]


>  [1] GrayFace ©   (27.06.04 09:15)

Всё равно мигает



Страницы: 1 вся ветка

Текущий архив: 2005.06.29;
Скачать: CL | DM;

Наверх




Память: 0.47 MB
Время: 0.028 c
11-1099554883
DmiSb
2004-11-04 10:54
2005.06.29
MaskEdit в KOL


1-1118133587
LOP
2005-06-07 12:39
2005.06.29
Компоненет к доступу MS Accses


10-1094486888
vadim
2004-09-06 20:08
2005.06.29
Автоматизация MSOffice


3-1116401091
_e_u_
2005-05-18 11:24
2005.06.29
обнуление автоинкремента в МССУКЭЛЬ


1-1117821844
Tuzemec
2005-06-03 22:04
2005.06.29
избавиться от Sysutils подкиньте модуль