Jeg har lavet et lille program i D5 bestående af to forme (se nedenfor).
Når jeg automatisk laver begge forme, virker det perfekt.
Min label på form et får sat en værdi, alt efter min modalresult.
Hvis jeg manuelt laver form2, som nedenfor, virker det ikke.
Jeg får en fejl FFFFFFFFF i mit program.
Ved nogen hvorfor ?
____________________________________
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Label1: TLabel;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses Unit2;
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
var
temp : integer;
f : TForm2;
begin
f := NIL;
f := TForm2.Create(f);
if (f.ShowModal=mrOK) then
Label1.Caption := 'OK'
else
label1.caption := '????';
f.free;
end;
end.
__________________________________
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm2 = class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
var
knapok : Boolean;
{$R *.DFM}
procedure TForm2.Button1Click(Sender: TObject);
begin
KnapOK := TRUE;
close;
end;
procedure TForm2.Button2Click(Sender: TObject);
begin
KnapOK := FALSE;
Close;
end;
procedure TForm2.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
if (KnapOK) then
form2.ModalResult := mrOk
else
form2.ModalResult := mrCancel;
end;
end.
--
-----------------------------------------------------------------------
Med venlig hilsen / Best regards
OCC Data ApS - Michael Vilhelmsen
Systemudvikler
Telefon: 66 15 46 00 - Fax: 65 93 20 55
Website:
www.occdata.dk
Andre kontakter:
Bogholderi: bogholderi@occdata.dk Info: occdata@occdata.dk Salg:
salgocc@occdata.dk
-----------------------------------------------------------------------