| | |
C# Multi-form pre-render?
Please support our C# advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Nov 2009
Posts: 2
Reputation:
Solved Threads: 0
Hi
I'm creating a multiple form GUI app using a scene-manager to set the current visible form.
There isn't an issue regarding it working, that's fine. What I am noticing is that when each form is set to be active/visible, it takes a few seconds to load each component, and looks horrid. This is potentially for a business related endeavor, so I'm looking for a way to buffer the form so it loads fully before it is displayed.
I'm not sure if this is an issue with the use of a scene-manager, or it is something that is consistent across all C# form applications.
I've done a few google searches relating to this, but there was little aside from using "hide()" until it was loaded. That doesn't really work.
Any information would be great
I'm creating a multiple form GUI app using a scene-manager to set the current visible form.
There isn't an issue regarding it working, that's fine. What I am noticing is that when each form is set to be active/visible, it takes a few seconds to load each component, and looks horrid. This is potentially for a business related endeavor, so I'm looking for a way to buffer the form so it loads fully before it is displayed.
I'm not sure if this is an issue with the use of a scene-manager, or it is something that is consistent across all C# form applications.
I've done a few google searches relating to this, but there was little aside from using "hide()" until it was loaded. That doesn't really work.
Any information would be great
0
#3 18 Days Ago
if you are referring to the controls on the form, suspend and resume layout methods of the forms class tells the form not to bother painting the controls until its finished creating them, but I don't know about this scene manager you speak of, so it may not support suspendlayout or resumelayout.
Create a new windows forms application project in visual studio and then drag some buttons onto the form from the tool box, then in the solution expand the item for Form1 and open Form1.Designer.cs notice that in the initializecomponents method defined there that before any controls are added this.suspendLayout() is called. Then after each control is added this.resumeLayout() is called. This prevents the display from acting crazy until all the controls are successfully added.
Hope this helps.
Create a new windows forms application project in visual studio and then drag some buttons onto the form from the tool box, then in the solution expand the item for Form1 and open Form1.Designer.cs notice that in the initializecomponents method defined there that before any controls are added this.suspendLayout() is called. Then after each control is added this.resumeLayout() is called. This prevents the display from acting crazy until all the controls are successfully added.
Hope this helps.
0
#4 18 Days Ago
>>There isn't an issue regarding it working, that's fine. What I am noticing is that when each form is set to be active/visible, it takes a few seconds to load each component, and looks horrid. This is potentially for a business related endeavor, so I'm looking for a way to buffer the form so it loads fully before it is displayed.
Using hide until it is loaded won't really work. When you "make a form visible" or "make a control visible" it will fire the Load event for that control/form. It uses a delayed initialization, I forget the MS terminology for it. This way the application doesn't expense creating controls that will never show.
That being said what Diamonddrake told you is true. The designer should stop controls from showing until everything is ready to render with
Perhaps you could upload a demo project demonstrating this behavior?
Using hide until it is loaded won't really work. When you "make a form visible" or "make a control visible" it will fire the Load event for that control/form. It uses a delayed initialization, I forget the MS terminology for it. This way the application doesn't expense creating controls that will never show.
That being said what Diamonddrake told you is true. The designer should stop controls from showing until everything is ready to render with
ISupportInitialize.BeginInit() . I can't think of a scenario like this and I have forms withs lots of controls.Perhaps you could upload a demo project demonstrating this behavior?
•
•
Join Date: Nov 2009
Posts: 2
Reputation:
Solved Threads: 0
0
#5 18 Days Ago
That seems to have done something, thank you very much.
Thanks for the post, forms are still created in the usual way, I've made not change to the automated form creation, so suspend/resume aer still there.
Sure. I'm not sure what I've done, but it seems to have been quashed somewhat. The forms load faster, but there's still a flicker.
I think it was originally something to do with the images I was using as buttons, they were PNGs. it seemed like they were loading after the form as already displayed. It's still happening, but it's much quicker now.
•
•
•
•
if you are referring to the controls on the form, suspend and resume layout methods of the forms class tells the form not to bother painting the controls until its finished creating them, but I don't know about this scene manager you speak of, so it may not support suspendlayout or resumelayout.
Create a new windows forms application project in visual studio and then drag some buttons onto the form from the tool box, then in the solution expand the item for Form1 and open Form1.Designer.cs notice that in the initializecomponents method defined there that before any controls are added this.suspendLayout() is called. Then after each control is added this.resumeLayout() is called. This prevents the display from acting crazy until all the controls are successfully added.
Hope this helps.
•
•
•
•
That being said what Diamonddrake told you is true. The designer should stop controls from showing until everything is ready to render withISupportInitialize.BeginInit(). I can't think of a scenario like this and I have forms withs lots of controls.
Perhaps you could upload a demo project demonstrating this behavior?
I think it was originally something to do with the images I was using as buttons, they were PNGs. it seemed like they were loading after the form as already displayed. It's still happening, but it's much quicker now.
c# Syntax (Toggle Plain Text)
//Main Program using System; using System.Collections.Generic; using System.Linq; using System.Windows.Forms; using BPM_C_Sharp_Touchscreen.Scenes; namespace BPM_C_Sharp_Touchscreen { class Program { private static SceneManager sceneManager; public static SceneManager SceneManager { get { return sceneManager; } } public Program() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); sceneManager = new SceneManager(); SceneManager.addScene(new Home()); SceneManager.selectScene("Home"); Application.Run(sceneManager); } /// <summary> /// The main entry point for the application. /// </summary> [STAThread] static void Main() { new Program(); } } } //SceneManager using System; using System.Collections; using System.Linq; using System.Text; using System.Windows.Forms; using System.Collections.Generic; namespace BPM_C_Sharp_Touchscreen { public class SceneManager : ApplicationContext { private List<Form> forms = new List<Form>(); protected bool exitAppOnClose; public void selectScene(string scene) { foreach (Form f in forms) { if ((f.Name).Equals(scene)) { if (MainForm != null) MainForm.Hide(); MainForm = f; MainForm.Show(); } } } public void addScene(Form toAdd) { forms.Add(toAdd); } public void removeScene(Form toRemove) { forms.Remove(toRemove); } // when a form is closed, don't exit the application if this is a swap protected override void OnMainFormClosed(object sender, EventArgs e) { if (exitAppOnClose) { base.OnMainFormClosed(sender, e); } } //Getters and setters public List<Form> Forms { get { return forms; } set { forms = value; } } } }
![]() |
Similar Threads
- Multi form help needed (C#)
- Suppress field if blank in email submission from PHP Form (PHP)
- Allowing multiple adds to SQL database (PHP)
- Multi class multi form j2me app getting NullPointerException (Java)
- Trouble rending form in firefox and netscape. (ASP.NET)
- Printing Embedded JComponents (Java)
Other Threads in the C# Forum
- Previous Thread: Retrieveing binary data out of the database
- Next Thread: Field Initialiser problem
| Thread Tools | Search this Thread |
.net access algorithm alignment app array barchart bitmap box broadcast c# c#gridviewcolumn cast check checkbox client combobox communication concurrency control conversion csharp custom database datagrid datagridview dataset datatable datetime degrees development draganddrop drawing elevated encryption enum excel file focus form format forms function gdi+ hospitalmanagementsystem image index input install java label list listbox localization login mandelbrot math messagebox mouseclick mysql operator path photoshop picturebox pixelinversion plotting pointer post programming radians read regex remote remoting richtextbox server sleep socket sql statistics stream string stringformatting sun table text textbox thread time timer update usercontrol validation visualstudio webbrowser whileloop windows winforms wpf xml






