Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Delphi Exception EAccessViolation Form Free (https://www.delphipraxis.net/39340-exception-eaccessviolation-form-free.html)

shidap 1. Feb 2005 10:37


Exception EAccessViolation Form Free
 
** Exception EAccessViolation **

[dp][df]


Hi,

Bekomme o.a. Fehlermeldung (Delphi 6) weiß aber nicht warum.


procedure Tfrmsaselogin.FormCreate(Sender: TObject);
...
...
StartMainRptScreen(Application, SaseAdoConn, strUserId, strAccessLevel);

:?:
Fehlermeldung hier:

If Assigned(frmsaselogin) then
frmsaselogin.Free;


Ich bin für jeden Vorschlag sehr Dankbar.

jim_raynor 1. Feb 2005 11:47

Re: Exception EAccessViolation Form Free
 
In frmsaselogin steht ein ungültiger Wert drin. Ist dieser auch richtig initsialisiert mit nil?

Auf jeden Fall wäre bissle mehr Quellcode nicht schlecht. Für micht sieht es sehr durcheinander aus, da man nicht erkannt, was zu was gehört.

Chegga 1. Feb 2005 12:04

Re: Exception EAccessViolation Form Free
 
Hi,

Zitat:

Zitat von jim_raynor
Auf jeden Fall wäre bissle mehr Quellcode nicht schlecht.

Und benutze bitte die Delphi-Tags.

Also nicht so:

procedure TForm1.Button1Click(Sender: TObject);
begin
ShowMessage('So nicht!!');
end;

sondern:

Delphi-Quellcode:
procedure TForm1.Button1Click(Sender: TObject);
begin
  ShowMessage('So ist es schöner und vor allem lesbarer!');
end;
MfG Marc

Tip: Benutze den Delphi-Code Button

shidap 1. Feb 2005 12:24

Re: Exception EAccessViolation Form Free
 
If the user does not have the report INI, it will prompted with a login, otherwise it will run the report automatically and (should) end the application upon completion.

Delphi-Quellcode:
procedure Tfrmsaselogin.FormCreate(Sender: TObject);
var Connstr : String;
strFTPReportDIR : String;
strUserId : ShortString;
begin
     Scaleform(self);
     DateSeparator := '-';
     ShortDateFormat := 'yyyy' + DateSeparator + 'mm' + DateSeparator + 'dd';
     ThousandSeparator := '.';
     DecimalSeparator := ',';

     try
         SaseAdoConn.Open
     except on E:Exception do
        begin
             Screen.Cursor := crDefault;
             SaseAdoConn := Nil;
             ShowMessage(E.Message);
        end;
     end;

     MyIniFile := TIniFile.Create('./SASE_Report.ini');
     logintry:=0;
     logon_q.DatabaseName:= SASEDB.DatabaseName;

     //Check if the .ini file exists or not
     If FileExists('./SASE_Report.ini') then
     begin
          strFTPReportDIR := MyInifile.ReadString('FTPReportDirectory', 'FTPReportDIR', '');
          If Trim(strFTPReportDIR) <> '' then
          begin
              MyInifile.Free;
              strUserId := 'Automatik';
              strUserId:=LowerCase(strUserId);
              strAccessLevel := '0';
              // Go straight to the Report Generator
              StartGenerateReports(Application,SaseAdoConn,-1, Now, Now, '');

              // when the user exits the Form "StartGenerateReports" the Application should end.
              If Assigned(frmsaselogin) then
                 frmsaselogin.Free;

              // I tried closed and Exit but the application remainded in the background

          end;
     end;

     // If there is no INI show the User the Login screen and let them enter their password

     USID_EB.Text := GetSystemUserName;
end;

shmia 1. Feb 2005 12:27

Re: Exception EAccessViolation Form Free
 
Zitat:

Zitat von shidap
Delphi-Quellcode:
procedure Tfrmsaselogin.FormCreate(Sender: TObject);
StartMainRptScreen(Application, SaseAdoConn, strUserId, strAccessLevel);

   If Assigned(frmsaselogin) then
      frmsaselogin.Free;

Du darfst in FormCreate nicht das eigene Formular freigeben!!
(wenn es doch nötig ist, kann man die Methode Release verwenden)
Du darfst ausserdem nicht in einer Methode auf eine Objektvariable der eigenen Klasse zugreifen.
Du kannst aber ein Klassenfunktion schreiben, um ein Formular modal anzuzeigen:

Delphi-Quellcode:
Tfrmsaselogin = class(TForm)

public
   class function ShowLoginDialog:integer;
end;

class function Tfrmsaselogin.ShowLoginDialog:integer;
var
   f : Tfrmsaselogin;
begin
   f := Tfrmsaselogin.Create(nil);
   try
      result := f.ShowModal;
     
      StartMainRptScreen(Application, SaseAdoConn, strUserId, strAccessLevel);

   finally
      f.Free;
   end;
end;
Zum Beenden einer Anwendung benutzt man:
Delphi-Quellcode:
   Application.Terminate;

shidap 1. Feb 2005 12:30

Re: Exception EAccessViolation Form Free
 
Danke!

Shidap :-D


Alle Zeitangaben in WEZ +1. Es ist jetzt 17:58 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