Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   GUI-Design mit VCL / FireMonkey / Common Controls (https://www.delphipraxis.net/18-gui-design-mit-vcl-firemonkey-common-controls/)
-   -   Delphi OpenDialog AccessViolation (https://www.delphipraxis.net/52006-opendialog-accessviolation.html)

bundy 22. Aug 2005 15:27


OpenDialog AccessViolation
 
Hallo Leute, ich bin irgednwie am verzweifeln !


Ich zeig euch mal den Quelltext:

Delphi-Quellcode:
Imortfilestring:=TStringList.Create;

if OpenDialog1.Execute then
begin
Imortfilestring.LoadFromFile(OpenDialog1.FileName);
end;
Wenn ich die stringlist so laden will kommt es zu einer AccessViolation.
Wenn ich das so mache funzt es:

Delphi-Quellcode:
Imortfilestring.LoadFromFile('c:\stringlist.txt');
Die AccessViolation spielt sich allso im Opendialog.Execute ab.

Ich weiss nicht mehr weiter

PLS PLS PLS HELP

mfg
Bundy

bigg 22. Aug 2005 15:36

Re: OpenDialog AccessViolation
 
moin,

Execute gibt True oder False zurück und wenn du nun auf Öffnen drückst, liefert er dir True zurück.
Der Fehler liegt also bei dir und nicht beim OpenDialog.

bundy 22. Aug 2005 15:38

Re: OpenDialog AccessViolation
 
Kann ich ir nich vorstellen, weil wenn ich es nach dem Unteren Beispiel direkt Lade geht es

Delphi-Quellcode:
Imortfilestring.LoadFromFile('c:\stringlist.txt');
Mach ich bei dem OpenDialog Teil was falsch ?

bigg 22. Aug 2005 15:42

Re: OpenDialog AccessViolation
 
Zitat:

Imortfilestring:=TStringList.Create;
Wie oft willst du denn ImportFileString erstellen?
Genauso oft wie du auf öffnen drückst?

Erstelle die Liste nur einmal dann geht es auch.

bundy 22. Aug 2005 15:44

Re: OpenDialog AccessViolation
 
Ich hab das nur oben dazugeschrieben, um zu zeigen was für eine Variable das ist.
Ich erstelle den String im OnFormCreate Event

bigg 22. Aug 2005 15:50

Re: OpenDialog AccessViolation
 
Bei mir funktioniert das:

Delphi-Quellcode:
var List: TStringList;

procedure TForm1.Button1Click(Sender: TObject);
begin if OpenDialog1.Execute then
begin
List.LoadFromFile(OpenDialog1.FileName);
Memo1.Lines := List;
end;
end;


procedure TForm1.FormCreate(Sender: TObject);
begin
List := TStringList.Create;
end;

bundy 22. Aug 2005 15:56

Re: OpenDialog AccessViolation
 
Ja ich hab das jetzt auch mal in einem neuen Programm getestet und da geht das auch.....hmmmmmmm

Muss wohl in meinen Anderen Programm liegen.

muss wohl mal schaun, aber ich weiss nicht wo :(

aber ich danke dir auf jedenfall.

bundy 22. Aug 2005 16:02

Re: OpenDialog AccessViolation
 
JETZT HAB ICHS !!!!!!! :)


Ich hab eine VCLSKIN Componete imlimentiert gehabt. Die hab ich jetzt enfernt und siehe da jetzt gehts.
Da dürfte was mit der Componente nicht stimmen.

DANKE DANKE


Alle Zeitangaben in WEZ +1. Es ist jetzt 03:48 Uhr.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz