Einzelnen Beitrag anzeigen

Benutzerbild von Neutral General
Neutral General

Registriert seit: 16. Jan 2004
Ort: Bendorf
5.219 Beiträge
 
Delphi 10.2 Tokyo Professional
 
#3

Re: Objektinstanz an Hauptprogramm übergeben

  Alt 17. Feb 2008, 15:01
Hauptprogramm:

Delphi-Quellcode:
procedure TForm1.tbtnOpenClick(Sender: TObject);
var newf: IFileFormat;
    pData: PRawData;
begin
  if dlgOpenFile.Execute then
  begin
    newf := ExtList.GetFormat(ExtractFileExt(dlgOpenFile.Filename)); // Interface bekommen
    if not Assigned(newf) then
      exit;
    newf.LoadFromFile(PChar(dlgOpenFile.Filename)); // Datei laden
    pData := newf.GetData; // Datei-Daten erhalten
    case pData^.DataType of
      dtImage: begin
                 with TForm2.Create(Application) do
                 begin
                   Image1.Picture.Bitmap := PBitmap(pData.Data)^; // Ich weiß, ist zu umständlich aber jetzt egal
                   Caption := dlgOpenFile.Filename;
                 end;
               end;
      dt3D: with TForm3.Create(Application) do
            begin
              A3DFile := P3DDataFile(pData.Data)^;
            end;
    end;
  end;
end;
Michael
"Programmers talk about software development on weekends, vacations, and over meals not because they lack imagination,
but because their imagination reveals worlds that others cannot see."
  Mit Zitat antworten Zitat