This archived discussion is "read only".
For the corresponding "live" discussions, post in the active topic forum here.
» hugoparkinson - I need some help please
I am writing a simulator using delphi and just need a little help with a couple of things:-- posted by hugoparkinson
» ilyapin - Re: I need some help please
In response to message posted by hugoparkinson:
Hi Hugo
>1. If I keep writing values to a TStringlist, what will it do if it runs
out
>of memory?
As far as I know a TStringList uses ReallocMem when expanding and therefore
it will raise EOutOfMemory exception
>Will it start using virtual memory, or just crash the program?
Of course Delphi memory menager uses system virtual memory but early or late
the program will run out of memory.
It's possible to capture the EOutOfMemory exception and try to save list to
disk file
But I must say it will not be easy to do because when you could not create
any more object or allocate memory while handling EOutOfMemory
Why not to limit the StringList growth to the fixed number of strings or a
fixed memory size?
May be a text file will better solve your problem?
If you need further help please let me have more information about your
project
>2. Is there a way to get the little panel telling you about the owner etc,
>that always appears with such applications as Word, at startup of my delphi
>program, only to quit and leave control to the main form?
May be they call it "a splash screen", but English is not the best of my
abilities.
You can create a new form in the main form OnCreate event hanler
show it
wait a little
close it
and then destroy it
Do not forget to call Application.Processmessages method in order to give
the form ability to redraw
It is good idea to place the pictures (if any) in DLL and load /unload DLL
dynamically in order to save memory
Fill free to contact me if you have questions
-- posted by ilyapin
» olavlind - Re: Re: I need some help please
In response to message posted by ilyapin:I do this in another way that I think is better.
What I do is create a new form, remove it from the autocreate list. I do not have any other windows than my applications mainform in the autocreate list. When I want to display/use a window, i use this code:
==============================
with (TForm1.Create(Self)) do
try
//Window is created here, but now shown.
//TForm1.FormCreate event has been fired.
//TForm1.FormShow will be on the next line.
//This is a good place to initiate vars
//in the TForm1.Formshow event.
ShowModal;
finally
Free;
end;
==============================
When using Splash screens, I set these up in the project file (*.dpr file). This is how I usually do it.
==============================
//Inside the begin/end of your
//main project file (*.dpr).
begin
//This is a good place to check for
//expire date, initiate stuff before
//any windows are shown etc. If any
//irregularities are detected,
//then you can safely do a Halt; here
//Create a Splash screen here
FrmSplash := TFrmSplash.Create(NIL);
try
Screen.Cursor := crHourglass;
//Show the splash screen form.
//TFrmSplash.Formstyle should be set to
//fsStayOnTop
//Put a timer on TFrmSplash set to 2-3
//seconds.
//In TFrmSplash.Timer1Timer event, set a
//global CloseOk boolean to true and
//call Close;
//In TFrmSplash.FormShow, load a nice image
//for your application, and update
//version info etc.
Application.Initialize;
Application.Title := 'Title';
//All the Application.CreateForm's go here.
Application.CreateForm(TFrmMain, FrmMain);
finally
Screen.Cursor := crDefault;
end;
Application.Run;
end.
===============================
//TFrmSplash code. Timer set to 2-5 seconds.
procedure TFrmSplash.Timer1Timer(Sender: TObject);
begin
CloseOk := True;
Close;
end;
procedure TFrmSplash.FormCloseQuery(Sender: TObject;
var CanClose: Boolean);
begin
CanClose := CloseOk;
end;
============================
If you want sourcecode, example project
or something, send me an email.
Good luck, Olav!
-- posted by olavlind
Please follow the guidelines set forth in the Suite101 Posting Etiquette when adding to the discussion.