Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jul 12th, 2007, 10:01 PM   #1
NightShade01
Programmer
 
Join Date: Oct 2005
Posts: 52
Rep Power: 3 NightShade01 is on a distinguished road
Design Question

This might sound like a really newbie question but I figure it really has an impact on the runtime and speed of applications so I wanted an opinion. Suppose you create a project that contains a screen for the main page, sending in emails, an information page, and an about page. Would it be better design wise to create seperate forms for each one and then hide/show each as needed or would it be better to make one form with controls that can be created within the main page for email, information, and about information. I guess what i'm asking is what is the benefit to hand coding controls, and specifics when visual studio can just as easily create individual forms and show them as needed.

Also as a side note when i run apps with multiple windows and click to change between forms the taskbar always shows one form hiding and a new form appearing (kinda of like opening a new form everytime). How can you make it so that this "effect" doesn't occur.
NightShade01 is offline   Reply With Quote
Old Jul 13th, 2007, 12:40 PM   #2
john Wesley
Hobbyist Programmer
 
john Wesley's Avatar
 
Join Date: May 2006
Location: United Kingdom
Posts: 119
Rep Power: 3 john Wesley is on a distinguished road
Send a message via MSN to john Wesley Send a message via Yahoo to john Wesley
To tackle your last query first - if I have a grasp of what your talking about, but it all depends how you handle this behaviour within your application along with Windows settings. For instance, the number of these taskbar tabs that will be grouped is relevant to a Windows setting however your problem lies with the way your using forms, from what I imagine.

If a form is loaded and displayed, then depending on your property settings it will have a tab in the taskbar, hiding it will then remove the tab and I presume your hiding one form to show another hence the 'effect', on the other hand you may not be hiding the other form in which case my advice is to detect the form and bring it forward instead of displaying it again.

Loading all forms at run-time to hide\show as and when is really quite insane unless you have a reason other than one which is to display interfaces faster. You should strive to write code in such a manner that executing the code units to initialise and display a form is efficient as possible and not rely on a users memory.

The benefits of controls can be used to implement full-featured forms, but generally used to write elemental feature's which can be used widely accross the application, and even to be exposed to calling applications, such as a login dialog for a database for example. Another example is a custom control I had to write for a client this week, which was a folder browser control, this control is to be shown in mutliple places as its own dialog but in one circumstance it acts as a toolbar in an MDI container.

So for non-standard circumstances, including times where you are required to draw your own control, which is another good reason for custom controls, then do so, otherwise dont go through the effort, IMO.
__________________
Mona Lisa must of had the highway blues you can tell by the way she smiles..
john Wesley is offline   Reply With Quote
Old Jul 14th, 2007, 4:20 PM   #3
NightShade01
Programmer
 
Join Date: Oct 2005
Posts: 52
Rep Power: 3 NightShade01 is on a distinguished road
Thanks for the info it makes more sense now. I have a follow up question though. Suppose I have the same application with 4 different forms. Each form has a "next" button that "shows" the next form. When i run the comlied .exe file it only shows one instance of the program however like you were saying all the forms are loaded, because if they weren't i wouldn't be able to "show" them i would have to create an instance of them first. How do i then get just the main form to load when the exe starts this way when i hit "next" i can create an instance of the forms i want and dispose of them when i'm done.
NightShade01 is offline   Reply With Quote
Old Jul 14th, 2007, 4:45 PM   #4
bigguy
Professional Programmer
 
bigguy's Avatar
 
Join Date: Sep 2005
Location: Arkansas
Posts: 298
Rep Power: 0 bigguy is an unknown quantity at this point
Send a message via AIM to bigguy Send a message via MSN to bigguy Send a message via Yahoo to bigguy
On your main form_load do you habe like
form1.show
form2.show
form3.show
form4.show

Cause that could cause it. I made a small program just now and compiled and done like you said, only showing the form when clicking next. It worked, all the forms didnt show up on startup. They only showed up when I hit Next.

This kind of what you looking for?
__________________
Forgiveness is the fragrance that the violet sheds on the heal that has crushed it. - Mark Twain

Destruction leads to a very rough road, but it also breeds creation.
bigguy is offline   Reply With Quote
Old Jul 14th, 2007, 5:04 PM   #5
john Wesley
Hobbyist Programmer
 
john Wesley's Avatar
 
Join Date: May 2006
Location: United Kingdom
Posts: 119
Rep Power: 3 john Wesley is on a distinguished road
Send a message via MSN to john Wesley Send a message via Yahoo to john Wesley
Yes, its simple, just dont instatiate the forms on initial execution of your program but do it within the 'next' buttons click event.

If you need to remember the state of specific elements on the form between switches, use settings to store and retrieve the relevant values etc.
__________________
Mona Lisa must of had the highway blues you can tell by the way she smiles..
john Wesley is offline   Reply With Quote
Old Jul 14th, 2007, 11:41 PM   #6
NightShade01
Programmer
 
Join Date: Oct 2005
Posts: 52
Rep Power: 3 NightShade01 is on a distinguished road
@bigguy yeah I have something simliar to that...
@john How would I not instantiate them? I have two forms the main form has one button that says next. The other form just has a label on it. When the main form loads and you click next the code reads:

form2.show()

Which it does and only one instance of it (no matter how many times you hit next). which leads me to beleive that like you were saying originally all forms are being loaded at startup. btw thanks for all the help on this
NightShade01 is offline   Reply With Quote
Old Jul 15th, 2007, 8:20 AM   #7
john Wesley
Hobbyist Programmer
 
john Wesley's Avatar
 
Join Date: May 2006
Location: United Kingdom
Posts: 119
Rep Power: 3 john Wesley is on a distinguished road
Send a message via MSN to john Wesley Send a message via Yahoo to john Wesley
NightShade01,

Just got up and read your post but give me a little time, simply because I have not used VB.NET for a while and would not want to give you false information, if you wait until I get back and fire up VS il let you know.
__________________
Mona Lisa must of had the highway blues you can tell by the way she smiles..
john Wesley is offline   Reply With Quote
Old Jul 15th, 2007, 12:18 PM   #8
john Wesley
Hobbyist Programmer
 
john Wesley's Avatar
 
Join Date: May 2006
Location: United Kingdom
Posts: 119
Rep Power: 3 john Wesley is on a distinguished road
Send a message via MSN to john Wesley Send a message via Yahoo to john Wesley
Yes it is just as I thought, I simply needed to double check VB.NET gave control over this matter...

Create a new instance of a and show as below:

    Dim CurrentForm As New TheForm()
    CurrentForm.Show()

Then you can just dispose of the object as neccesary, or the GC will clean it up if you neglect to do so.
__________________
Mona Lisa must of had the highway blues you can tell by the way she smiles..
john Wesley is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
OOP design question rwm C++ 7 May 28th, 2007 2:46 AM
object design question rwm C++ 21 May 11th, 2007 7:11 AM
The Black Art of Video Game Console Design lostcauz Book Reviews 0 Apr 26th, 2006 7:31 PM
Attitudes Oddball Coder's Corner Lounge 29 Mar 18th, 2006 9:34 PM
How to post a question nnxion C++ 0 Jun 3rd, 2005 8:55 AM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 6:37 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC