BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Delphi design question

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> comp.lang.pascal.delphi.misc
View previous topic :: View next topic  
Author Message
Nicholas Sherlock
Guest





PostPosted: Sat Feb 19, 2005 8:15 am    Post subject: Delphi design question Reply with 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? 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





PostPosted: Sat Feb 19, 2005 8:53 am    Post subject: Re: Delphi design question Reply with quote



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





PostPosted: Sat Feb 19, 2005 9:33 pm    Post subject: Re: Delphi design question Reply with quote



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 Smile. 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





PostPosted: Sun Feb 20, 2005 10:45 am    Post subject: Re: Delphi design question Reply with quote

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 Smile. 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





PostPosted: Sun Feb 20, 2005 11:12 am    Post subject: Re: Delphi design question Reply with quote

"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 Smile. 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
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> comp.lang.pascal.delphi.misc All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.