 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Nicholas Sherlock Guest
|
Posted: Sat Feb 19, 2005 8:15 am Post subject: Delphi design question |
|
|
Hey all,
I've made a few editors (for various things) over the years in Delphi,
but I always run into a problem: What do you do with all of your
controls for editing files if the user has not yet opened a file? It's
easy to miss one when you do your big SetEnabledState(state:boolean)
call. If all of your edits are applied to a single object instance,
where do you store this instance? Do you check every time you want to
access it to make sure that the user really does have a file open and
the object has been created?
When I made my first editor as an MDI application (a few months ago), it
solved all of these worries. My object could be a property of the MDI
window: It was created when a file was opened and the window was
created, and was destroyed along with the window when the window was
closed. All of the menus and controls for editing the object belonged to
the MDI window, so that they were not available unless a file was
actually open.
So how do I carry these MDI advantages to my SDI editors? Or should I
convert them to MDI?
Cheers,
Nicholas Sherlock
|
|
| Back to top |
|
 |
Jeremy Collins Guest
|
Posted: Sat Feb 19, 2005 8:53 am Post subject: Re: Delphi design question |
|
|
Nicholas Sherlock wrote:
| Quote: | Hey all,
I've made a few editors (for various things) over the years in Delphi,
but I always run into a problem: What do you do with all of your
controls for editing files if the user has not yet opened a file?
|
I use Actions for everything. As part of the OnUpdate event you
have something like
ThisAction.Enabled := FFileLoaded;
--
jc
Remove the -not from email
|
|
| Back to top |
|
 |
Nicholas Sherlock Guest
|
Posted: Sat Feb 19, 2005 9:33 pm Post subject: Re: Delphi design question |
|
|
Jeremy Collins wrote:
| Quote: | Nicholas Sherlock wrote:
Hey all,
I've made a few editors (for various things) over the years in Delphi,
but I always run into a problem: What do you do with all of your
controls for editing files if the user has not yet opened a file?
I use Actions for everything. As part of the OnUpdate event you
have something like
ThisAction.Enabled := FFileLoaded;
|
This works, but I have heaps of controls on my form such as treeviews,
checkboxes, toolbars, spinedits, buttons, edits and and TGLScene window
rendering the object being edited . I disable them in a big loop
through my forms controls, but this just isn't neat.
Cheers,
Nicholas Sherlock
|
|
| Back to top |
|
 |
Jeremy Collins Guest
|
Posted: Sun Feb 20, 2005 10:45 am Post subject: Re: Delphi design question |
|
|
Nicholas Sherlock wrote:
| Quote: | Jeremy Collins wrote:
Nicholas Sherlock wrote:
Hey all,
I've made a few editors (for various things) over the years in
Delphi, but I always run into a problem: What do you do with all of
your controls for editing files if the user has not yet opened a file?
I use Actions for everything. As part of the OnUpdate event you
have something like
ThisAction.Enabled := FFileLoaded;
This works, but I have heaps of controls on my form such as treeviews,
checkboxes, toolbars, spinedits, buttons, edits and and TGLScene window
rendering the object being edited . I disable them in a big loop
through my forms controls, but this just isn't neat.
|
In these situations I contain all of the controls within a parent, such
as a TForm, TFrame or TPanel, and disable / hide the parent as
appropriate. For an SDI application, it's simplest to have a TPanel,
aligned alClient, with no borders. Put all your controls on the panel
and show or hide it depending on whether a file is loaded or not. The
logic for keeping the UI updated is simple; this just makes the code
cleaner.
--
jc
Remove the -not from email
|
|
| Back to top |
|
 |
Maarten Wiltink Guest
|
Posted: Sun Feb 20, 2005 11:12 am Post subject: Re: Delphi design question |
|
|
"Nicholas Sherlock" <n_sherlock (AT) hotmail (DOT) com> wrote
| Quote: | Jeremy Collins wrote:
Nicholas Sherlock wrote:
I've made a few editors (for various things) over the years in
Delphi, but I always run into a problem: What do you do with all
of your controls for editing files if the user has not yet opened
a file?
I use Actions for everything. As part of the OnUpdate event you
have something like
ThisAction.Enabled := FFileLoaded;
This works, but I have heaps of controls on my form such as
treeviews, checkboxes, toolbars, spinedits, buttons, edits and
and TGLScene window rendering the object being edited . I
disable them in a big loop through my forms controls, but this
just isn't neat.
|
You're not thinking actions then. With actions, the controls would
be enabling and disabling themselves autonomously, without the form
having to know about all the interactions. As an extra bonus, actions
can be more abstract than controls.
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
|
|