| Autor |
Beitrag |
nabbl
      
Beiträge: 51
Win XP Home
Delphi 7 PE
|
Verfasst: Mi 27.05.09 07:48
Moijn.
Zur Zeit erstelle ich ein neues Form und weise es einem TabSheet zu. Funktioniert auch soweit:
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 tabSheet := TAdvTabSheet.Create(TabControl) ; tabSheet.AdvPageControl := TabControl; tabSheet.ShowClose := True; tabSheet.OnCanClose := TabClose; aForm := TFrame.Create(tabSheet) ; aForm.Parent := tabSheet; aForm.Align := alClient; aForm.BorderStyle := bsNone; aForm.Visible := true; tabSheet.Caption := ExtractFileName(Caption);
TabControl.ActivePage := tabSheet;
if (Caption <> 'Unnamed') then aForm.SourceCode.Lines.LoadFromFile(Caption); 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
      
Beiträge: 8721
Erhaltene Danke: 191
Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
|
Verfasst: 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 
      
Beiträge: 51
Win XP Home
Delphi 7 PE
|
Verfasst: Mi 27.05.09 09:05
|
|
BenBE
      
Beiträge: 8721
Erhaltene Danke: 191
Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
|
Verfasst: 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 
      
Beiträge: 51
Win XP Home
Delphi 7 PE
|
Verfasst: Mi 27.05.09 09:37
Jo, fettes THX
Habs hinbekommen. Für alle, die irgendwann mal suchen:
Delphi-Quelltext 1:
| ShowMessage((TabControl.Pages[0].Controls[0] as TFrame).SourceCode.Lines[0]); |
|
|
BenBE
      
Beiträge: 8721
Erhaltene Danke: 191
Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
|
Verfasst: 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.
|
|
|