DjDMac
asked on
Form visible property causes wierd error..
I have coded my project several months now. And it works fine. Now it has started to give Access Violation error.
It creates Mainform and several other forms in startup. In mainform's on create event it should check and set other forms VISIBLE property. This worked fine, until now. I haven't changed the code, or done any other modifications. Now when i try to read or set forms visible property it gives an error: "Access Violation at address 004499DE in module "program name". Read of address FFFFFFFF."
When i click ok, the program will continue normally.
What causes this and how can i get rid of it ?
Help me !
It's wierd, because i havent changed those routines that affect or read the visible propertys, in several months..
It creates Mainform and several other forms in startup. In mainform's on create event it should check and set other forms VISIBLE property. This worked fine, until now. I haven't changed the code, or done any other modifications. Now when i try to read or set forms visible property it gives an error: "Access Violation at address 004499DE in module "program name". Read of address FFFFFFFF."
When i click ok, the program will continue normally.
What causes this and how can i get rid of it ?
Help me !
It's wierd, because i havent changed those routines that affect or read the visible propertys, in several months..
ASKER
No help! :(
Now i get even more Access violations..
And why the code worked earlier but now suddenly started to give these f***ing errors.. ?!?
Now i get even more Access violations..
And why the code worked earlier but now suddenly started to give these f***ing errors.. ?!?
Still no real help I think.....;-(
There's not really enough information to give a solution I think. Why not copy paste the exact code that gives the error, stripped from all other things. The error code you give doens't say much...
One thing, if your code worked Okee before, don't start changing things! The problem might be somewhere else (new Delphi version?, how are your directory settings? how do older versions work, you do have previous versions I hope?)
Or try to put the code in the OnShow / OnActivate event (please do add a global boolean to your project and use it so that your code will be called only once, if placed here).
I remember that using form.visible = true works different in newer versions...
Good Luck with the |o|o| errors.
F-)
There's not really enough information to give a solution I think. Why not copy paste the exact code that gives the error, stripped from all other things. The error code you give doens't say much...
One thing, if your code worked Okee before, don't start changing things! The problem might be somewhere else (new Delphi version?, how are your directory settings? how do older versions work, you do have previous versions I hope?)
Or try to put the code in the OnShow / OnActivate event (please do add a global boolean to your project and use it so that your code will be called only once, if placed here).
I remember that using form.visible = true works different in newer versions...
Good Luck with the |o|o| errors.
F-)
ASKER
I try couple of things first and if no help, then i post some source here.
I use Delphi 4 C/S.
Before i started to receive these errors, i changed the name of directory were projects is.. could this have anything to do with these errors ?
And what if those form files .DFM's are some way corrupted or something..
I use Delphi 4 C/S.
Before i started to receive these errors, i changed the name of directory were projects is.. could this have anything to do with these errors ?
And what if those form files .DFM's are some way corrupted or something..
hi djdmac,
didn't know why this happened, but maybe this workaroung helps
project source:
program app_;
uses
Forms,
app_u1 in 'app_u1.pas' {Form1},
app_u2 in 'app_u2.pas' {Form2},
app_u3 in 'app_u3.pas' {Form3};
{$R *.RES}
begin
Application.Initialize;
Application.CreateForm(TFo rm1, Form1);
Application.CreateForm(TFo rm2, Form2);
Application.CreateForm(TFo rm3, Form3);
Form1.StartUp(Application) ; //look here
Application.Run;
end.
mainform source :
unit app_u1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;
type
TForm1 = class(TForm)
private
{ Private declarations }
public
procedure StartUp(Sender: TObject);
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses app_u2, app_u3;
{$R *.DFM}
procedure TForm1.StartUp(Sender: TObject);
begin
Form2.Visible := Not(Form2.Visible); //or whatever
Form3.Visible := Not(Form3.Visible);
end;
end.
well the forms are a bit empty in this sample :-)
meikl
didn't know why this happened, but maybe this workaroung helps
project source:
program app_;
uses
Forms,
app_u1 in 'app_u1.pas' {Form1},
app_u2 in 'app_u2.pas' {Form2},
app_u3 in 'app_u3.pas' {Form3};
{$R *.RES}
begin
Application.Initialize;
Application.CreateForm(TFo
Application.CreateForm(TFo
Application.CreateForm(TFo
Form1.StartUp(Application)
Application.Run;
end.
mainform source :
unit app_u1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;
type
TForm1 = class(TForm)
private
{ Private declarations }
public
procedure StartUp(Sender: TObject);
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses app_u2, app_u3;
{$R *.DFM}
procedure TForm1.StartUp(Sender: TObject);
begin
Form2.Visible := Not(Form2.Visible); //or whatever
Form3.Visible := Not(Form3.Visible);
end;
end.
well the forms are a bit empty in this sample :-)
meikl
Check project|options and there the directory's. Changing a directory name might result in Delphi searching (and finding!) parts of your application in the old directory!
Did you try to change it back, just to test?
I really don;t know about corrupted dfm's. Start with using view form (button in Delphi toolbar) to check whether Delphi can view all forms.
F.
Did you try to change it back, just to test?
I really don;t know about corrupted dfm's. Start with using view form (button in Delphi toolbar) to check whether Delphi can view all forms.
F.
I think, nrico is right. Please post the project code here, and the MainForm.FromCreate code. Then we'll find the problem...
Regards, Madshi.
Regards, Madshi.
He! I posted an other comment, lost.
Please first check your directory settings, without changing anything the code did work before you changed the directory. The problem should be here...
F-)
Please first check your directory settings, without changing anything the code did work before you changed the directory. The problem should be here...
F-)
Delete or Rename all your *.dcu's I would bet one is pointing to the wrong directory...
Rick
Rick
Hi DjDMac,
You can easily have wierds problems like these if you, like me, have a directory where you copy almost all components you think are good enough to keep a copy.
If this is the case then rename this directory and create another with the old name and starting copying only those components your programs are asking for.
if this is not the case then think of something like this. I bet it's the right direction.
sinceramente,
Reginaldo
You can easily have wierds problems like these if you, like me, have a directory where you copy almost all components you think are good enough to keep a copy.
If this is the case then rename this directory and create another with the old name and starting copying only those components your programs are asking for.
if this is not the case then think of something like this. I bet it's the right direction.
sinceramente,
Reginaldo
Yo DJDMAC,
Maybe you can check in the menu 'Project - Options - Forms'
Perhaps your forms are in the 'auto-create' list.
If you create your forms at runtime, then you'd better put them in the 'available forms' list.
Best regards,
The Mayor
Maybe you can check in the menu 'Project - Options - Forms'
Perhaps your forms are in the 'auto-create' list.
If you create your forms at runtime, then you'd better put them in the 'available forms' list.
Best regards,
The Mayor
ASKER
[PROJECT SOURCE]
program WinDMP;
uses
Forms,
Main in 'Main.pas' {MainForm},
TimeDate in 'TimeDate.pas' {TimeDateForm},
About in 'About.pas' {AboutForm},
PitchCalc in 'PitchCalc.pas' {PitchCalcForm},
PlayList in 'PlayList.pas' {PlayListForm},
PlayListAddDlg in 'PlayListAddDlg.pas' {PlayListAddDlgForm},
NotePad in 'NotePad.pas' {NotePadForm},
Chrono in 'Chrono.pas' {ChronoForm},
ChroSet in 'ChroSet.pas' {ChronoSetF},
Bpm in 'Bpm.pas' {BPMForm},
BpmBrows in 'BpmBrows.pas' {BPMBrowserForm},
Calculator in 'Calculator.pas' {CalculatorForm},
DataBase in 'DataBase.pas' {DataBaseF},
DBUpdate in 'DBUpdate.pas' {DatabaseUpdateForm},
LookUpEdit in 'LookUpEdit.pas' {LookupEditForm},
Details in 'Details.pas' {DetailsForm},
Search in 'Search.pas' {SearchDialog};
{$R *.RES}
begin
Application.Initialize;
Application.Title := 'WinDMP [Special Edition]';
Application.CreateForm(TMa inForm, MainForm);
Application.CreateForm(TBP MForm, BPMForm);
Application.CreateForm(TTi meDateForm , TimeDateForm);
Application.CreateForm(TAb outForm, AboutForm);
Application.CreateForm(TPi tchCalcFor m, PitchCalcForm);
Application.CreateForm(TPl ayListForm , PlayListForm);
Application.CreateForm(TPl ayListAddD lgForm, PlayListAddDlgForm);
Application.CreateForm(TNo tePadForm, NotePadForm);
Application.CreateForm(TCh ronoForm, ChronoForm);
Application.CreateForm(TCh ronoSetF, ChronoSetF);
Application.CreateForm(TBP MBrowserFo rm, BPMBrowserForm);
Application.CreateForm(TCa lculatorFo rm, CalculatorForm);
Application.CreateForm(TDa taBaseF, DataBaseF);
Application.CreateForm(TDa tabaseUpda teForm, DatabaseUpdateForm);
Application.CreateForm(TLo okupEditFo rm, LookupEditForm);
Application.CreateForm(TDe tailsForm, DetailsForm);
Application.CreateForm(TSe archDialog , SearchDialog);
Application.Run;
end.
[MAINFORM]
procedure TMainForm.FormCreate(Sende r: TObject);
begin
Set1Background:=ExtractFil ePath(Appl ication.Ex eName)+'wi ndmp.bmp';
Set2Background:=ExtractFil ePath(Appl ication.Ex eName)+'wi ndmp.bmp';
Set3Background:=ExtractFil ePath(Appl ication.Ex eName)+'wi ndmp.bmp';
Set4Background:=ExtractFil ePath(Appl ication.Ex eName)+'wi ndmp.bmp';
ActiveSET:=1;
SaveAsDefault:=False;
DetailsVisible:=False;
end;
procedure TMainForm.FormShow(Sender: TObject);
Begin
DontSaveDefaultSet:=False;
LMDTipDlg1.CaptionTitle:= '- XXXX '+Versio+' -';
LMDTipDlg1.Execute;
MainosBanneri.Lines[0]:='- XXXX '+ Versio+' - By Seppo ''DJ Lazy Jeff'' Sormunen';
MainForm.Caption:='XXXX '+Versio;
MainosBanneri.Scroll:=True ;
<!1!> If FileExists(ExtractFilePath (Applicati on.Exename )+'default .set') Then
| Begin
| LoadDefault:=True;
| M_LoadSetClick(self);
| LoadDefault:=False;
<!1!> End;
end;
procedure TMainForm.M_LoadSetClick(S ender: TObject);
Var SF:TextFile;
S:String;
begin
SaveFormsToOldSet;
LoadSetDialog.InitialDir:= ExtractFil ePath(Appl ication.Ex ename);
If LoadDefault=True Then LoadSetDialog.Filename:='d efault.set ';
If LoadDefault=False Then
If MessageDlg('Do you want to save your current desktops before loading a new ??',mtConfirmation, [mbYes, mbNo], 0) = mrYes then
M_SaveSetClick(self);
If LoadDefault=False Then LoadSetDialog.Execute;
If LoadSetDialog.Filename<>'' Then
Begin
AssignFile(SF,LoadSetDialo g.Filename );
Reset(SF);
ReadLn(SF,S);
If S = '--- WINDMP SET FILE ---' Then // oikea file..
Begin
ReadLn(SF,S);
If UpperCase(S)='TRUE' Then BPM_SetInfo[1]:=True Else BPM_SetInfo[1]:=False;
ReadLn(SF,S);
If UpperCase(S)='TRUE' Then BPM_SetInfo[2]:=True Else BPM_SetInfo[2]:=False;
ReadLn(SF,S);
If UpperCase(S)='TRUE' Then BPM_SetInfo[3]:=True Else BPM_SetInfo[3]:=False;
ReadLn(SF,S);
If UpperCase(S)='TRUE' Then BPM_SetInfo[4]:=True Else BPM_SetInfo[4]:=False;
ReadLn(SF,S);
BPM_Xpos[1]:=StrToInt(S);
ReadLn(SF,S);
BPM_Xpos[2]:=StrToInt(S);
ReadLn(SF,S);
BPM_Xpos[3]:=StrToInt(S);
ReadLn(SF,S);
BPM_Xpos[4]:=StrToInt(S);
ReadLn(SF,S);
BPM_Ypos[1]:=StrToInt(S);
ReadLn(SF,S);
BPM_Ypos[2]:=StrToInt(S);
ReadLn(SF,S);
BPM_Ypos[3]:=StrToInt(S);
ReadLn(SF,S);
BPM_Ypos[4]:=StrToInt(S);
ReadLn(SF,S);
DatabaseF.Grid.Columns[0]. Width:=Str ToInt(S);
ReadLn(SF,S);
DatabaseF.Grid.Columns[1]. Width:=Str ToInt(S);
ReadLn(SF,S);
DatabaseF.Grid.Columns[2]. Width:=Str ToInt(S);
ReadLn(SF,S);
DatabaseF.Grid.Columns[3]. Width:=Str ToInt(S);
ReadLn(SF,S);
DatabaseF.Grid.Columns[4]. Width:=Str ToInt(S);
ReadLn(SF,S);
DatabaseF.Grid.Columns[5]. Width:=Str ToInt(S);
ReadLn(SF,S);
DatabaseF.Grid.Columns[6]. Width:=Str ToInt(S);
ReadLn(SF,S);
DatabaseF.Grid.Columns[7]. Width:=Str ToInt(S);
CloseFile(SF);
FriendlyStatusBar1.Panels[ 2].Text:=' Desktops loaded !';
End;
End;
LoadCurrentSet;
end;
Procedure LoadCurrentSet;
Begin
If BPM_SetInfo[ActiveSET]=Tru e Then BpmForm.Show Else BpmForm.Close;
If PITCH_SetInfo[ActiveSET]=T rue Then PitchCalcForm.Show Else PitchCalcForm.Close;
If TIMEDATE_SetInfo[ActiveSET ]=True Then TimeDateForm.Show Else TimeDateForm.Close;
If CHRONO_SetInfo[ActiveSET]= True Then ChronoForm.Show Else ChronoForm.Close;
If NOTEPAD_SetInfo[ActiveSET] =True Then NotePadForm.Show Else NotePadForm.Close;
If PLAYLIST_SetInfo[ActiveSET ]=True Then PlaylistForm.Show Else PlaylistForm.Close;
If CALCULATOR_SetInfo[ActiveS ET]=True Then CalculatorForm.Show Else CalculatorForm.Close;
If BPMBROWSER_SetInfo[ActiveS ET]=True Then BpmBrowserForm.Show Else BpmBrowserForm.Close;
If DATABASE_SetInfo[ActiveSET ]=True Then DataBaseF.Show Else DataBaseF.Close;
If UPDATEDB_SetInfo[ActiveSET ]=True Then DatabaseUpdateForm.Show Else DatabaseUpdateForm.Close;
If BpmForm.Visible Then
Begin
BpmForm.Left:=BPM_Xpos[Act iveSET];
BpmForm.Top:=BPM_Ypos[Acti veSET];
End;
If PitchCalcForm.Visible Then
Begin
PitchCalcForm.Left:=PITCH_ Xpos[Activ eSET];
PitchCalcForm.Top:=PITCH_Y pos[Active SET];
End;
If TimeDateForm.Visible Then
Begin
TimeDateForm.Left:=TIMEDAT E_Xpos[Act iveSET];
TimeDateForm.Top:=TIMEDATE _Ypos[Acti veSET];
TimeDateForm.Height:=TIMED ATE_H[Acti veSET];
TimeDateForm.Width:=TIMEDA TE_W[Activ eSET];
If TIMEDATE_Mode[ActiveSET]=1 Then
Begin
TimeDateForm.AnalogClock.V isible:=Tr ue;
TimeDateForm.LCD_Time.Visi ble:=False ;
TimeDateForm.LCD_Date.Visi ble:=False ;
End
Else
Begin
TimeDateForm.AnalogClock.V isible:=Fa lse;
TimeDateForm.LCD_Time.Visi ble:=True;
TimeDateForm.LCD_Date.Visi ble:=True;
End;
End;
If ChronoForm.Visible Then
Begin
ChronoForm.Left:=CHRONO_Xp os[ActiveS ET];
ChronoForm.Top:=CHRONO_Ypo s[ActiveSE T];
End;
If NotePadForm.Visible Then
Begin
NotePadForm.Left:=NOTEPAD_ Xpos[Activ eSET];
NotePadForm.Top:=NOTEPAD_Y pos[Active SET];
NotePadForm.Width:=NOTEPAD _W[ActiveS ET];
NotePadForm.Height:=NOTEPA D_H[Active SET];
End;
If PlayListForm.Visible Then
Begin
PlaylistForm.Left:=PLAYLIS T_Xpos[Act iveSET];
PlaylistForm.Top:=PLAYLIST _Ypos[Acti veSET];
End;
If CalculatorForm.Visible Then
Begin
CalculatorForm.Left:=CALCU LATOR_Xpos [ActiveSET ];
CalculatorForm.Top:=CALCUL ATOR_Ypos[ ActiveSET] ;
End;
If DataBaseF.Visible Then
Begin
DataBaseF.Left:=DATABASE_X pos[Active SET];
DataBaseF.Top:=DATABASE_Yp os[ActiveS ET];
End;
If BpmBrowserForm.Visible Then
Begin
BpmBrowserForm.Left:=BPMBR OWSER_Xpos [ActiveSET ];
BpmBrowserForm.Top:=BPMBRO WSER_Ypos[ ActiveSET] ;
BpmBrowserForm.Height:=BPM BROWSER_H[ ActiveSET] ;
End;
If DatabaseUpdateForm.Visible Then
Begin
DatabaseUpdateForm.Left:=U PDATEDB_Xp os[ActiveS ET];
DatabaseUpdateForm.Top:=UP DATEDB_Ypo s[ActiveSE T];
DatabaseUpdateForm.Height: =UPDATEDB_ H[ActiveSE T];
End;
End;
Procedure SaveFormsToOldSet;
Begin
<ERR> If BpmForm.Visible Then BPM_SetInfo[ActiveSET]:=Tr ue Else BPM_SetInfo[ActiveSET]:=Fa lse;
If PitchCalcForm.Visible Then PITCH_SetInfo[ActiveSET]:= True Else PITCH_SetInfo[ActiveSET]:= False;
If TimeDateForm.Visible Then TIMEDATE_SetInfo[ActiveSET ]:=True Else TIMEDATE_SetInfo[ActiveSET ]:=False;
If ChronoForm.Visible Then CHRONO_SetInfo[ActiveSET]: =True Else CHRONO_SetInfo[ActiveSET]: =False;
If NotePadForm.Visible Then NOTEPAD_SetInfo[ActiveSET] :=True Else NOTEPAD_SetInfo[ActiveSET] :=False;
If PlaylistForm.Visible Then PLAYLIST_SetInfo[ActiveSET ]:=True Else PLAYLIST_SetInfo[ActiveSET ]:=False;
If DatabaseF.Visible Then DATABASE_SetInfo[ActiveSET ]:=True Else DATABASE_SetInfo[ActiveSET ]:=False;
If BpmBrowserForm.Visible Then BPMBROWSER_SetInfo[ActiveS ET]:=True Else BPMBROWSER_SetInfo[ActiveS ET]:=False ;
If CalculatorForm.Visible Then CALCULATOR_SetInfo[ActiveS ET]:=True Else CALCULATOR_SetInfo[ActiveS ET]:=False ;
If DatabaseUpdateForm.Visible Then UPDATEDB_SetInfo[ActiveSET ]:=True Else UPDATEDB_SetInfo[ActiveSET ]:=False;
If BpmForm.Visible Then
Begin
BPM_Xpos[ActiveSET]:=BpmFo rm.Left;
BPM_Ypos[ActiveSET]:=BpmFo rm.Top;
End;
If PitchCalcForm.Visible Then
Begin
PITCH_Xpos[ActiveSET]:=Pit chCalcForm .Left;
PITCH_Ypos[ActiveSET]:=Pit chCalcForm .Top;
End;
If TimeDateForm.Visible Then
Begin
TIMEDATE_Xpos[ActiveSET]:= TimeDateFo rm.Left;
TIMEDATE_Ypos[ActiveSET]:= TimeDateFo rm.Top;
TIMEDATE_W[ActiveSET]:=Tim eDateForm. Width;
TIMEDATE_H[ActiveSET]:=Tim eDateForm. Height;
If TimeDateForm.AnalogClock.V isible Then TIMEDATE_Mode[ActiveSET]:= 1
End;
If ChronoForm.Visible Then
Begin
CHRONO_Xpos[ActiveSET]:=Ch ronoForm.L eft;
CHRONO_Ypos[ActiveSET]:=Ch ronoForm.T op;
End;
If NotePadForm.Visible Then
Begin
NOTEPAD_Xpos[ActiveSET]:=N otePadForm .Left;
NOTEPAD_Ypos[ActiveSET]:=N otePadForm .Top;
NOTEPAD_W[ActiveSET]:=Note PadForm.Wi dth;
NOTEPAD_H[ActiveSET]:=Note PadForm.He ight;
End;
If PlayListForm.Visible Then
Begin
PLAYLIST_Xpos[ActiveSET]:= PlayListFo rm.Left;
PLAYLIST_Ypos[ActiveSET]:= PlayListFo rm.Top;
End;
If CalculatorForm.Visible Then
Begin
CALCULATOR_Xpos[ActiveSET] :=Calculat orForm.Lef t;
CALCULATOR_Ypos[ActiveSET] :=Calculat orForm.Top ;
End;
If DataBaseF.Visible Then
Begin
DATABASE_Xpos[ActiveSET]:= DataBaseF. Left;
DATABASE_Ypos[ActiveSET]:= DataBaseF. Top;
End;
If BpmBrowserForm.Visible Then
Begin
BPMBROWSER_Xpos[ActiveSET] :=BpmBrows erForm.Lef t;
BPMBROWSER_Ypos[ActiveSET] :=BpmBrows erForm.Top ;
BPMBROWSER_H[ActiveSET]:=B pmBrowserF orm.Height ;
End;
If DatabaseUpdateForm.Visible Then
Begin
UPDATEDB_Xpos[ActiveSET]:= DatabaseUp dateForm.L eft;
UPDATEDB_Ypos[ActiveSET]:= DatabaseUp dateForm.T op;
UPDATEDB_H[ActiveSET]:=Dat abaseUpdat eForm.Heig ht;
End;
End;
-------------------------- ---------- ---------- ---------- -
When i remove the whole IF part marked with <!1!>, the program works.
But if i don't remove it the program will hang in line marked with <ERR>.
I tried to remove all .dcu's but it wont help.
I can get the program running now, by removing that default.set file's automatic
loading, but i really want to know whats wrong with the code..
I hope this code will show right..
Lazy Jeff
program WinDMP;
uses
Forms,
Main in 'Main.pas' {MainForm},
TimeDate in 'TimeDate.pas' {TimeDateForm},
About in 'About.pas' {AboutForm},
PitchCalc in 'PitchCalc.pas' {PitchCalcForm},
PlayList in 'PlayList.pas' {PlayListForm},
PlayListAddDlg in 'PlayListAddDlg.pas' {PlayListAddDlgForm},
NotePad in 'NotePad.pas' {NotePadForm},
Chrono in 'Chrono.pas' {ChronoForm},
ChroSet in 'ChroSet.pas' {ChronoSetF},
Bpm in 'Bpm.pas' {BPMForm},
BpmBrows in 'BpmBrows.pas' {BPMBrowserForm},
Calculator in 'Calculator.pas' {CalculatorForm},
DataBase in 'DataBase.pas' {DataBaseF},
DBUpdate in 'DBUpdate.pas' {DatabaseUpdateForm},
LookUpEdit in 'LookUpEdit.pas' {LookupEditForm},
Details in 'Details.pas' {DetailsForm},
Search in 'Search.pas' {SearchDialog};
{$R *.RES}
begin
Application.Initialize;
Application.Title := 'WinDMP [Special Edition]';
Application.CreateForm(TMa
Application.CreateForm(TBP
Application.CreateForm(TTi
Application.CreateForm(TAb
Application.CreateForm(TPi
Application.CreateForm(TPl
Application.CreateForm(TPl
Application.CreateForm(TNo
Application.CreateForm(TCh
Application.CreateForm(TCh
Application.CreateForm(TBP
Application.CreateForm(TCa
Application.CreateForm(TDa
Application.CreateForm(TDa
Application.CreateForm(TLo
Application.CreateForm(TDe
Application.CreateForm(TSe
Application.Run;
end.
[MAINFORM]
procedure TMainForm.FormCreate(Sende
begin
Set1Background:=ExtractFil
Set2Background:=ExtractFil
Set3Background:=ExtractFil
Set4Background:=ExtractFil
ActiveSET:=1;
SaveAsDefault:=False;
DetailsVisible:=False;
end;
procedure TMainForm.FormShow(Sender:
Begin
DontSaveDefaultSet:=False;
LMDTipDlg1.CaptionTitle:= '- XXXX '+Versio+' -';
LMDTipDlg1.Execute;
MainosBanneri.Lines[0]:='-
MainForm.Caption:='XXXX '+Versio;
MainosBanneri.Scroll:=True
<!1!> If FileExists(ExtractFilePath
| Begin
| LoadDefault:=True;
| M_LoadSetClick(self);
| LoadDefault:=False;
<!1!> End;
end;
procedure TMainForm.M_LoadSetClick(S
Var SF:TextFile;
S:String;
begin
SaveFormsToOldSet;
LoadSetDialog.InitialDir:=
If LoadDefault=True Then LoadSetDialog.Filename:='d
If LoadDefault=False Then
If MessageDlg('Do you want to save your current desktops before loading a new ??',mtConfirmation, [mbYes, mbNo], 0) = mrYes then
M_SaveSetClick(self);
If LoadDefault=False Then LoadSetDialog.Execute;
If LoadSetDialog.Filename<>''
Begin
AssignFile(SF,LoadSetDialo
Reset(SF);
ReadLn(SF,S);
If S = '--- WINDMP SET FILE ---' Then // oikea file..
Begin
ReadLn(SF,S);
If UpperCase(S)='TRUE' Then BPM_SetInfo[1]:=True Else BPM_SetInfo[1]:=False;
ReadLn(SF,S);
If UpperCase(S)='TRUE' Then BPM_SetInfo[2]:=True Else BPM_SetInfo[2]:=False;
ReadLn(SF,S);
If UpperCase(S)='TRUE' Then BPM_SetInfo[3]:=True Else BPM_SetInfo[3]:=False;
ReadLn(SF,S);
If UpperCase(S)='TRUE' Then BPM_SetInfo[4]:=True Else BPM_SetInfo[4]:=False;
ReadLn(SF,S);
BPM_Xpos[1]:=StrToInt(S);
ReadLn(SF,S);
BPM_Xpos[2]:=StrToInt(S);
ReadLn(SF,S);
BPM_Xpos[3]:=StrToInt(S);
ReadLn(SF,S);
BPM_Xpos[4]:=StrToInt(S);
ReadLn(SF,S);
BPM_Ypos[1]:=StrToInt(S);
ReadLn(SF,S);
BPM_Ypos[2]:=StrToInt(S);
ReadLn(SF,S);
BPM_Ypos[3]:=StrToInt(S);
ReadLn(SF,S);
BPM_Ypos[4]:=StrToInt(S);
ReadLn(SF,S);
DatabaseF.Grid.Columns[0].
ReadLn(SF,S);
DatabaseF.Grid.Columns[1].
ReadLn(SF,S);
DatabaseF.Grid.Columns[2].
ReadLn(SF,S);
DatabaseF.Grid.Columns[3].
ReadLn(SF,S);
DatabaseF.Grid.Columns[4].
ReadLn(SF,S);
DatabaseF.Grid.Columns[5].
ReadLn(SF,S);
DatabaseF.Grid.Columns[6].
ReadLn(SF,S);
DatabaseF.Grid.Columns[7].
CloseFile(SF);
FriendlyStatusBar1.Panels[
End;
End;
LoadCurrentSet;
end;
Procedure LoadCurrentSet;
Begin
If BPM_SetInfo[ActiveSET]=Tru
If PITCH_SetInfo[ActiveSET]=T
If TIMEDATE_SetInfo[ActiveSET
If CHRONO_SetInfo[ActiveSET]=
If NOTEPAD_SetInfo[ActiveSET]
If PLAYLIST_SetInfo[ActiveSET
If CALCULATOR_SetInfo[ActiveS
If BPMBROWSER_SetInfo[ActiveS
If DATABASE_SetInfo[ActiveSET
If UPDATEDB_SetInfo[ActiveSET
If BpmForm.Visible Then
Begin
BpmForm.Left:=BPM_Xpos[Act
BpmForm.Top:=BPM_Ypos[Acti
End;
If PitchCalcForm.Visible Then
Begin
PitchCalcForm.Left:=PITCH_
PitchCalcForm.Top:=PITCH_Y
End;
If TimeDateForm.Visible Then
Begin
TimeDateForm.Left:=TIMEDAT
TimeDateForm.Top:=TIMEDATE
TimeDateForm.Height:=TIMED
TimeDateForm.Width:=TIMEDA
If TIMEDATE_Mode[ActiveSET]=1
Begin
TimeDateForm.AnalogClock.V
TimeDateForm.LCD_Time.Visi
TimeDateForm.LCD_Date.Visi
End
Else
Begin
TimeDateForm.AnalogClock.V
TimeDateForm.LCD_Time.Visi
TimeDateForm.LCD_Date.Visi
End;
End;
If ChronoForm.Visible Then
Begin
ChronoForm.Left:=CHRONO_Xp
ChronoForm.Top:=CHRONO_Ypo
End;
If NotePadForm.Visible Then
Begin
NotePadForm.Left:=NOTEPAD_
NotePadForm.Top:=NOTEPAD_Y
NotePadForm.Width:=NOTEPAD
NotePadForm.Height:=NOTEPA
End;
If PlayListForm.Visible Then
Begin
PlaylistForm.Left:=PLAYLIS
PlaylistForm.Top:=PLAYLIST
End;
If CalculatorForm.Visible Then
Begin
CalculatorForm.Left:=CALCU
CalculatorForm.Top:=CALCUL
End;
If DataBaseF.Visible Then
Begin
DataBaseF.Left:=DATABASE_X
DataBaseF.Top:=DATABASE_Yp
End;
If BpmBrowserForm.Visible Then
Begin
BpmBrowserForm.Left:=BPMBR
BpmBrowserForm.Top:=BPMBRO
BpmBrowserForm.Height:=BPM
End;
If DatabaseUpdateForm.Visible
Begin
DatabaseUpdateForm.Left:=U
DatabaseUpdateForm.Top:=UP
DatabaseUpdateForm.Height:
End;
End;
Procedure SaveFormsToOldSet;
Begin
<ERR> If BpmForm.Visible Then BPM_SetInfo[ActiveSET]:=Tr
If PitchCalcForm.Visible Then PITCH_SetInfo[ActiveSET]:=
If TimeDateForm.Visible Then TIMEDATE_SetInfo[ActiveSET
If ChronoForm.Visible Then CHRONO_SetInfo[ActiveSET]:
If NotePadForm.Visible Then NOTEPAD_SetInfo[ActiveSET]
If PlaylistForm.Visible Then PLAYLIST_SetInfo[ActiveSET
If DatabaseF.Visible Then DATABASE_SetInfo[ActiveSET
If BpmBrowserForm.Visible Then BPMBROWSER_SetInfo[ActiveS
If CalculatorForm.Visible Then CALCULATOR_SetInfo[ActiveS
If DatabaseUpdateForm.Visible
If BpmForm.Visible Then
Begin
BPM_Xpos[ActiveSET]:=BpmFo
BPM_Ypos[ActiveSET]:=BpmFo
End;
If PitchCalcForm.Visible Then
Begin
PITCH_Xpos[ActiveSET]:=Pit
PITCH_Ypos[ActiveSET]:=Pit
End;
If TimeDateForm.Visible Then
Begin
TIMEDATE_Xpos[ActiveSET]:=
TIMEDATE_Ypos[ActiveSET]:=
TIMEDATE_W[ActiveSET]:=Tim
TIMEDATE_H[ActiveSET]:=Tim
If TimeDateForm.AnalogClock.V
End;
If ChronoForm.Visible Then
Begin
CHRONO_Xpos[ActiveSET]:=Ch
CHRONO_Ypos[ActiveSET]:=Ch
End;
If NotePadForm.Visible Then
Begin
NOTEPAD_Xpos[ActiveSET]:=N
NOTEPAD_Ypos[ActiveSET]:=N
NOTEPAD_W[ActiveSET]:=Note
NOTEPAD_H[ActiveSET]:=Note
End;
If PlayListForm.Visible Then
Begin
PLAYLIST_Xpos[ActiveSET]:=
PLAYLIST_Ypos[ActiveSET]:=
End;
If CalculatorForm.Visible Then
Begin
CALCULATOR_Xpos[ActiveSET]
CALCULATOR_Ypos[ActiveSET]
End;
If DataBaseF.Visible Then
Begin
DATABASE_Xpos[ActiveSET]:=
DATABASE_Ypos[ActiveSET]:=
End;
If BpmBrowserForm.Visible Then
Begin
BPMBROWSER_Xpos[ActiveSET]
BPMBROWSER_Ypos[ActiveSET]
BPMBROWSER_H[ActiveSET]:=B
End;
If DatabaseUpdateForm.Visible
Begin
UPDATEDB_Xpos[ActiveSET]:=
UPDATEDB_Ypos[ActiveSET]:=
UPDATEDB_H[ActiveSET]:=Dat
End;
End;
--------------------------
When i remove the whole IF part marked with <!1!>, the program works.
But if i don't remove it the program will hang in line marked with <ERR>.
I tried to remove all .dcu's but it wont help.
I can get the program running now, by removing that default.set file's automatic
loading, but i really want to know whats wrong with the code..
I hope this code will show right..
Lazy Jeff
It seems that the BpmForm is still not created, when your main form runs through FormShow. But in your project code you create that BpmForm before you call Application.Run, which shows your mainform.
So I see two possibilites, what's going wrong:
(1) One of the other forms call "MainForm.Show" or "MainForm.ShowModal" or "MainForm.Visible := true" in their FormCreate handler.
(2) One of the other forms call the "MainForm.FormShow(...)" or "MainForm.OnShow(...)" event directly.
Can this be? If not, you can send me the whole code to "madshi@gmx.net". Then I'll have a look at it. (I promise not to copy anything for my use... :-)
Regards, Madshi.
BPM_SetInfo is no dynamic array (something like "var BPM_SetInfo : type of OtherType;", is it?
So I see two possibilites, what's going wrong:
(1) One of the other forms call "MainForm.Show" or "MainForm.ShowModal" or "MainForm.Visible := true" in their FormCreate handler.
(2) One of the other forms call the "MainForm.FormShow(...)" or "MainForm.OnShow(...)" event directly.
Can this be? If not, you can send me the whole code to "madshi@gmx.net". Then I'll have a look at it. (I promise not to copy anything for my use... :-)
Regards, Madshi.
BPM_SetInfo is no dynamic array (something like "var BPM_SetInfo : type of OtherType;", is it?
P.S: Please go with the Delphi debugger step by step through your project code (e.g. by pressing F8). After this line:
Application.CreateForm(TBP MForm, BPMForm);
Is the "BPMForm <> nil"? If not: Here is the problem!!! If yes: Continue with the step by step debugging. You should reach Application.Run this way. If not: Tell us, which is the last line in your project, which you reach with F8? If yes: Continue debugging. Check "BPMForm" after each step. Is it still <> nil? Continue until you reach the <ERR> line. Someone must set it to nil!!! You have to find who does that.
Regards, Madshi.
Application.CreateForm(TBP
Is the "BPMForm <> nil"? If not: Here is the problem!!! If yes: Continue with the step by step debugging. You should reach Application.Run this way. If not: Tell us, which is the last line in your project, which you reach with F8? If yes: Continue debugging. Check "BPMForm" after each step. Is it still <> nil? Continue until you reach the <ERR> line. Someone must set it to nil!!! You have to find who does that.
Regards, Madshi.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Jiihaa !!
It worked !
But, why the mainforms visible can't be true ? What goes wrong when it's true ?
This is still a mystery to me, but
thanx for solving it !
Now i can get back to work.
Experts-Exchange really is the place to be when you have problems ! Great service !
Happy Lazy Jeff
It worked !
But, why the mainforms visible can't be true ? What goes wrong when it's true ?
This is still a mystery to me, but
thanx for solving it !
Now i can get back to work.
Experts-Exchange really is the place to be when you have problems ! Great service !
Happy Lazy Jeff
The problem is the following: Look at your project's sources. In the line
Application.CreateForm(TMa inForm, MainForm);
your mainform is being created. No problem so far. Normally the "visible" property is set to "false". So normally Delphi would jump to the FormCreate handler, then continue with the project's sources, that is creating the other forms. And normally your mainform's "visible" property would be set to "true" by the "Application.Run" call in your project.
But in your case Delphi shows the form already in the Application.CreateForm line. So Delphi jumps to the FormShow handler BEFORE the other forms are created. That's the problem...
Regards, Madshi.
Application.CreateForm(TMa
your mainform is being created. No problem so far. Normally the "visible" property is set to "false". So normally Delphi would jump to the FormCreate handler, then continue with the project's sources, that is creating the other forms. And normally your mainform's "visible" property would be set to "true" by the "Application.Run" call in your project.
But in your case Delphi shows the form already in the Application.CreateForm line. So Delphi jumps to the FormShow handler BEFORE the other forms are created. That's the problem...
Regards, Madshi.
ASKER
Ahaa.. i see. Thank you for spending so much time to solve this problem, which seems to be my stupid mistake to turn visible property to true.. :)
Well, the 500 points motivated me... :-)
When you create those forms BEFORE your main form, the first you create will become your main form and will change it.
Solution:
Go to your project source, and cut the lines of
Application.CreateForm()
EXCEPT your main form out of the project source, and past them AT THE BEGINNING of your MainForm.OnCreate, before the Form.Show() command.
This should do the trick.