Konuyu Oyla:
  • Derecelendirme: 0/5 - 0 oy
  • 1
  • 2
  • 3
  • 4
  • 5
Tabsheet içinde Form Create, Close olayları
#1
Sad 
Merhaba Arkadaşlar,

aşağıdaki kod bloğu ile bir formu özelleştirilmiş (kapatma düğmesi olan) PageControlCloseButton objesi içinde create ediyorum.

procedure TsysfrmAna.YeniSayfa(ChildClass: TComponentClass; var sayfaadi; multi: integer = 0);
var
 tabSheet: TCloseTabSheet;
 AComponent: TComponent;
begin

 try
   Screen.Cursor := crHourGlass;
   if not assigned(TObject(sayfaadi) as TForm) then
   begin

     tabSheet := TCloseTabSheet.Create(PageControlCloseButton);
     tabSheet.PageControl := PageControlCloseButton;
     tabsheet.OnClose := CloseTabeProc;
     //IntToStr(PageControlCloseButton.PageCount);
     //if aIndex > -1 then
       //tabSheet.PageIndex := aIndex; //Set the index of the new TabSheet
     //(TObject(sayfaadi) as TForm).BringToFront;
     Application.CreateForm(ChildClass, sayfaadi);
     (TObject(sayfaadi) as TForm).Parent := tabsheet;
     (TObject(sayfaadi) as TForm).borderstyle := bsNone;
     (TObject(sayfaadi) as TForm).windowstate := wsMaximized;
     //tabSheet.Caption := (TObject(sayfaadi) as TForm).Caption;
     tabsheet.Name := 'sayfa_' + (TObject(sayfaadi) as TForm).name;
     (TObject(sayfaadi) as TForm).Show;
     PageControlCloseButton.ActivePageIndex := tabsheet.PageIndex;

   end
   else
   begin

     {AComponent := FindComponent('sayfa_' + (TObject(sayfaadi) as TForm).name);
showmessage('b');
showmessage('xxx' + FindComponent('sayfa_' + (TObject(sayfaadi) as TForm).name).name);
if Assigned(TCloseTabSheet(AComponent)) then
//showmessage('c');
//if TObject(AComponent) is TCloseTabSheet then
// showmessage('d'); }

     AComponent := FindComponent((TObject(sayfaadi) as TForm).name);
     //if Assigned(AComponent) then
      // showmessage('c');
     //if TObject(AComponent) is TForm then
       //showmessage('d');

     PageControlCloseButton.ActivePageIndex := TCloseTabSheet((TObject(sayfaadi) as TForm).Parent).PageIndex; //get the index of the 'TabSheet1'

   end;
   Screen.Cursor := crDefault;
 except
   on e: exception do
     showmessage('Exception -> CreateChildForm ' + e.message);
 end;

end;

aşağıdaki kod blogu ile de bu sayfayı ve içindeki formu kapatmaya çalışıyorum, 
procedure TCloseTabSheet.DoClose;
var
 i: integer;
begin
 if Assigned(FOnClose) then
   FOnClose(Self);

 for i := 0 to Application.ComponentCount - 1 do
   if (pos('frm', Lowercase(Application.Components[i].Name)) > 0) and
     (Application.Components[i] <> Application.MainForm) and
     (TForm(Application.Components[i]).Parent = self) then
   begin
     //(TObject(Application.Components[i]) as TForm).Close;
     //freeandnil(i);

   end;
 //freeandnil(self);
end;


ama ne yaparsam yapayım sanırım formu free ve nil yapamadığımdan kapatılan form tekrar açılmaya çalışınca access violation hatası veriyor. hatayı nerede yapıyorum, önerilerinizi alabilir miyim
There is no place like "127.0.0.1"

"Vatanını en çok seven, görevini en iyi yapandır."

Cevapla


Konu ile Alakalı Benzer Konular
Konular Yazar Yorumlar Okunma Son Yorum
  form close de form bosalmiyor sadikacar60 11 350 24-01-2025, Saat: 19:25
Son Yorum: sadikacar60
  Thread içinde Web Browser Çalışırmı adelphiforumz 0 97 09-01-2025, Saat: 13:22
Son Yorum: adelphiforumz
  Main form status barında mdichild isimlerini görüntüleme nevzatc 2 200 15-12-2024, Saat: 20:36
Son Yorum: nevzatc
  Listview içinde arada dilo 6 4.522 10-11-2024, Saat: 19:07
Son Yorum: mcuyan
  Delphi ile Web Form Alanlarını Doldurma bünyamin68 13 969 30-09-2024, Saat: 14:14
Son Yorum: yhackup



Konuyu Okuyanlar: 1 Ziyaretçi