Главная страница
    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.45 MB
Время: 0.037 c
1-1117968479
lifo
2005-06-05 14:47
2005.06.29
МЕТОДЫ РАСПОЗНАВАНИЯ ОБРАЗОВ


9-1111518164
Bret
2005-03-22 22:02
2005.06.29
Вид от первого лица в GLscene


6-1112164956
dtm
2005-03-30 10:42
2005.06.29
Подключение IdHTTP через прокси и получение результата в строку


3-1116422713
Иг
2005-05-18 17:25
2005.06.29
Как достучаться к функциям Ацеса из адо?


8-1109731660
dr_ollo
2005-03-02 05:47
2005.06.29
DSPack регулировка яркости и контрастности в тюнере





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский