| Autor |
Beitrag |
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: So 12.06.05 20:26
Hi,
hab heut ein wenig mit der OTA für einen Formular-Experten herumexperimentiert und dabei ein kleines Problem.
Mit folgendem Source erstelle ich ein neues Formular:
107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167:
| { ... } Const FormDfmSource = 'object %s: T%0:s'#13#10'end'; myClassName = 'TOVCLForm'; myClassParent = 'TOVCLForm'; myClassText = ''; myClassState = 'alpha'; myInterfaceUses = 'Windows, Messages, SysUtils, Classes, Controls, Forms, Graphics, OVCLForm'; myImplementationUses = 'ODbgInterface'; DFMInclude: Boolean = True;
Procedure TOVCLFormExpert.Execute; Var UnitIdent, FileName: String; FormName: String; CodeStream: TStreamAdapter; DFMStream: TStreamAdapter; DFMString: TStringStream; DFMVCLStream: TMemoryStream; Begin If ToolServices.GetProjectName = '' then Begin MessageDlg('Es muss ein Projekt geöffnet sein, um ein neues Omorphia-Formular erzeugen zu können.', mtError, [mbOk], 0); Exit; end;
If Not ToolServices.GetNewModuleName(UnitIdent, FileName) Then Exit;
FormName := Copy(myClassName, 2, Length(myClassName)) + Copy(UnitIdent, 5, 255); CodeStream := TStreamAdapter.Create(TStringStream.Create(MakeUnit(UnitIdent, FormName, myClassState, myClassParent, myInterfaceUses, myImplementationUses, myClassText, DFMInclude)));
DFMString := TStringStream.Create(Format(FormDfmSource, [FormName])); DFMString.Position := 0; DFMStream := TStreamAdapter.Create(DFMString); Try ToolServices.CreateModuleEx(FileName, FormName, myClassName, '', CodeStream, DFMStream, [cmAddToProject, cmShowSource, cmShowForm, cmUnnamed, cmMarkModified]); Except DFMStream.Free; End; End; |
Die Function MakeUnit erzeugt den Rohquelltext einer neuen Unit, der auch Syntaktisch korrekt ist.
Soweit funktioniert das auch, jedoch habe ich folgendes Problem:
Wenn ich auf dem erzeugten Formular den Punkt "Ansicht als Text" auswähle, bringt Delphi mir eine EConvertError-Exception 'Ungültiges Argument zum Codieren des Datums.' Allerdings kann ich nicht nachvollziehen, was Delphi damit meint.
Nehm ich jedoch ein Standard-Form von Delphi, funktioniert alles wie gewünscht.
Wer kann mir da helfen?
P.S.: So sieht der erzeugte Unit-Source aus:
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: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53:
| Unit Unit2; {$I Omorphia.config.inc}
Interface
Uses Windows, Messages, SysUtils, Classes, Controls, Forms, Graphics, OVCLForm;
Type TOVCLForm2 = class(TOVCLForm) Private Protected Public Published End;
Var OVCLForm2: TOVCLForm2;
Implementation
Uses ODbgInterface;
{$R *.dfm}
End. |
_________________ 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.
|
|
alzaimar
      
Beiträge: 2889
Erhaltene Danke: 13
W2000, XP
D6E, BDS2006A, DevExpress
|
Verfasst: So 12.06.05 20:32
Geht speichern? Dann einfach die DFM im Notepad öffnen.
Oder es liegt an der inc-Datei...
|
|
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: So 12.06.05 21:20
Speichern geht und er legt auch sowohl PAS als auch DFM korrekt an.
die INC-Datei ist im Suchpfad\Bibliothekspfad von Delphi verfügbar und steuert einige Bedingte Compilierungen für die einzelnen Delphi-Versionen. Die INC-File funktioniert zuverlässig in normalen Delphi-Units.
_________________ 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.
|
|
alzaimar
      
Beiträge: 2889
Erhaltene Danke: 13
W2000, XP
D6E, BDS2006A, DevExpress
|
Verfasst: So 12.06.05 21:25
Und? was steht so innner DFM-Datei? Kein Datum? Nix? Tät mich ja wundern....
|
|
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: So 12.06.05 21:31
Unit2.dfm 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17:
| object OVCLForm2: TOVCLForm2 Left = 190 Top = 106 Width = 320 Height = 240 Color = clBtnFace Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -11 Font.Name = 'MS Sans Serif' Font.Style = [] OldCreateOrder = False UseXPManifest = False ScreenIndex = 0 PixelsPerInch = 96 TextHeight = 13 end |
_________________ 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.
|
|
NeoInDerMATRIX
      
Beiträge: 245
Win95, Win98(+se), WinNT, Win2000, WinME, WinXP(+pro), VISTA, Linux(SuSe), DOS [MultiMon(3)], Vista
D6 PeE + (FP 2.0l) + D3 Pe + D2005+ D2006 Arch
|
Verfasst: So 12.06.05 21:55
Hi,
warum speicherst du extra TextFormat! Mit BIN ging es doch!
Cu
Neo
|
|
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: So 12.06.05 22:58
Mit BIN tritt genau das gleiche Problem auf.
_________________ 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.
|
|
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: Mo 13.06.05 17:53
Hab nochmal nachgeguckt und einen API-Fehler-Code 2 beim Laden der DFM-File von HDD bei Property ScreenIndex (neu in dieser Klasse). Ich werd also Neo mal anquatschen müssen. THX vorerst.
_________________ 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.
|
|
|