Autor Beitrag
nabbl
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 51

Win XP Home
Delphi 7 PE
BeitragVerfasst: Mi 27.05.09 07:48 
Moijn.
Zur Zeit erstelle ich ein neues Form und weise es einem TabSheet zu. Funktioniert auch soweit:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
procedure TForm1.AddForm(Caption: String = 'Unnamed');
var
   aForm : TFrame;
   tabSheet : TAdvTabSheet;
begin
   //Create a new tab sheet
   tabSheet := TAdvTabSheet.Create(TabControl) ;
   tabSheet.AdvPageControl := TabControl;
   tabSheet.ShowClose := True;
   tabSheet.OnCanClose := TabClose;
   //create a form
   aForm := TFrame.Create(tabSheet) ;
   aForm.Parent := tabSheet;
   aForm.Align := alClient;
   aForm.BorderStyle := bsNone;
   aForm.Visible := true;
   tabSheet.Caption := ExtractFileName(Caption);

   //activate the sheet
   TabControl.ActivePage := tabSheet;

   //Load data
   if (Caption <> 'Unnamed'then
      aForm.SourceCode.Lines.LoadFromFile(Caption);
   //Set Focus
   aForm.SourceCode.SetFocus;
end;


Mein Frage ist nun: Wie kann ich später auf aForm.SourceCode zugreifen?
Wäre super, wenn ihr mir dabei etwas unter die Arme greifen könntet.

Gruß
Nabbl
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Mi 27.05.09 08:58 
Forms und Frames sind was Unterschiedliches. Bitte nicht in einen Topf werfen ...

Zur Frage:
Tabsheet.Controls ... und dort entsprechend gucken. ODER du merkst Dir irgendwo eine Referenz auf dein Frame.

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
nabbl Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 51

Win XP Home
Delphi 7 PE
BeitragVerfasst: Mi 27.05.09 09:05 
user profile iconBenBE hat folgendes geschrieben Zum zitierten Posting springen:
Forms und Frames sind was Unterschiedliches. Bitte nicht in einen Topf werfen ...

Zur Frage:
Tabsheet.Controls ... und dort entsprechend gucken. ODER du merkst Dir irgendwo eine Referenz auf dein Frame.


Ah, sry - ist irreführend:

ausblenden Delphi-Quelltext
1:
2:
type
  TFrame = class(TForm)


Ich weiß - ist dreckig.. werde ich aber noch ändern ;) versprochen :D

€dit:

Habe gerade das hier ausprobiert:
ausblenden Delphi-Quelltext
1:
ShowMessage((TabControl.Controls[0as TFrame).SourceCode.Lines[0]);					


Bekomme aber leider eine Fehlermeldung beim klicken des Buttons:
ausblenden Quelltext
1:
Ungültige Typumwandlung					
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Mi 27.05.09 09:32 
Beachte, wem Du dein Form zuordnest. Wenn du dem Tabsheet das Form zuordnest, musst Du es auch dort suchen.

Ferner: Es kann durchaus sein, dass da mehrere Controls sind; schau also mal mit dem Index durch.
Die Fehlermeldung heißt nur, dass das Control[0] von einem falschen Typ ist; bei einem direkten Typecast ohne Typprüfung hätte es hier mit einer AV gekracht ;-)

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
nabbl Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 51

Win XP Home
Delphi 7 PE
BeitragVerfasst: Mi 27.05.09 09:37 
Jo, fettes THX :D
Habs hinbekommen. Für alle, die irgendwann mal suchen:

ausblenden Delphi-Quelltext
1:
ShowMessage((TabControl.Pages[0].Controls[0as TFrame).SourceCode.Lines[0]);					
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Mi 27.05.09 09:41 
Wobei die Indizes an die eigenen Bedürfnisse anzupassen sind ;-)

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.