 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
korax1214@gmail.com Guest
|
Posted: Sun Mar 13, 2005 10:37 pm Post subject: Debug window probs |
|
|
I'm writing a file-converter app, and the development build is in two
parts; the main form which is the GUI, and a debug form (just a Memo
object) to which messages informing me what's happening inside the app
are written.
The trouble is that rationalisation of some code caused the FormCreate
method to (indirectly) write to the debug window, thereby causing an
access violation as that window didn't exist yet! Rearranging the
windows so that the debug window is created first also makes it the
main window, which of course I don't want.
I've fixed this problem (at least for now) by adding a Boolean variable
which starts as False and which fmMain.FormCreate sets to True just
before it exits; and while this variable is False, debug messages are
spooled to a TStringList object, then written to the debug window in a
batch the first time the debug routine is called when the flag is True.
This works fine (I think), but is it possible to arrange things so
that the debug window is called first but is not the main window? Or
will I just have to keep using the spooling technique?
(For a multi-window project, having fmDebug.FormActivate set the flag
would probably be better, but I don't think I need to do that in the
present, single-window, app.)
|
|
| Back to top |
|
 |
korax1214@gmail.com Guest
|
Posted: Sun Mar 13, 2005 10:41 pm Post subject: Re: Debug window probs |
|
|
korax1... (AT) gmail (DOT) com wrote:
| Quote: | ...is it possible to arrange things so
that the debug window is called first but is not the main window?
|
Oops, brain-death intervened... I of course meant *created* first, not
called...
|
|
| Back to top |
|
 |
Jeremy Collins Guest
|
Posted: Mon Mar 14, 2005 8:10 am Post subject: Re: Debug window probs |
|
|
[email]korax1214 (AT) gmail (DOT) com[/email] wrote:
| Quote: | korax1... (AT) gmail (DOT) com wrote:
...is it possible to arrange things so
that the debug window is called first but is not the main window?
Oops, brain-death intervened... I of course meant *created* first, not
called...
|
Of course. The "main form" is usually the form featured in the
first call to Application.CreateForm in the project's DPR file.
So you can simply add a function which creates your debug form
before the main form:
program MyApp;
uses
main_form in '.main_form.pas',
debug_form in '.debug_form.pas';
{$R *.res}
function CreateDebugWnd : boolean;
begin
DebugForm := TDebugForm.Create(Application);
Result := DebugForm.SomeInitCode;
end;
begin
Application.Initialize;
Application.Title := 'My Application';
// add a function call here
if not CreateDebugWnd then
Exit;
Application.CreateForm(TMainForm, MainForm);
MainForm.Show;
Application.Run;
end.
--
jc
Remove the -not from email
|
|
| Back to top |
|
 |
Maarten Wiltink Guest
|
Posted: Mon Mar 14, 2005 10:28 am Post subject: Re: Debug window probs |
|
|
<korax1214 (AT) gmail (DOT) com> wrote
| Quote: | I'm writing a file-converter app, and the development build is in two
parts; the main form which is the GUI, and a debug form (just a Memo
object) to which messages informing me what's happening inside the app
are written.
The trouble is that rationalisation of some code caused the FormCreate
method to (indirectly) write to the debug window, thereby causing an
access violation as that window didn't exist yet! Rearranging the
windows so that the debug window is created first also makes it the
main window, which of course I don't want.
I've fixed this problem (at least for now) by adding a Boolean variable
which starts as False and which fmMain.FormCreate sets to True just
before it exits; and while this variable is False, debug messages are
spooled to a TStringList object, then written to the debug window in a
batch the first time the debug routine is called when the flag is True.
This works fine (I think), but is it possible to arrange things so
that the debug window is called first but is not the main window? Or
will I just have to keep using the spooling technique?
|
Quite possible. Just don't have it auto-created. If you don't call
Application.CreateForm, MainForm will not be affected.
You can dispense with the Boolean variable and use Assigned(fmLogging)
instead.
What I generally do is to have a global procedure in the logging form
unit, which checks if the form exists. If it doesn't, no logging happens.
This suits me, but you could have it create the form instead.
Groetjes,
Maarten Wiltink
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|