Results 1 to 12 of 12

Thread: Fully load before showing

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2007
    Posts
    97

    Fully load before showing

    Hi there

    How do I make a windows form fully load before showing itself. This is so no one can see all the controls setting it self up when I say form1.show()


    Thanks in advance.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Fully load before showing

    That already happens. The controls are all created in the InitializeComponent method, which is called from the constructor, before you even call Show. If there's an issue it's because your controls are painting slowly. This should not be a problem in most UIs. If it is for you then setting the form's DoubleBuffered property to True may help.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Aug 2007
    Posts
    97

    Re: Fully load before showing

    Hey,

    Sorry I should of made it more clearer. In my form load event, I change background images of controls. The problem is that people can see one control by one changing images when it loads up .

    Also there is a specific button on the page that again changes the background images of all the controls on the page and some controls shift to the side of the page. you can see the changes to the GUI one by one here too.

    Is there away around this for at least one of the situations????

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Fully load before showing

    Can we see this code?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Aug 2007
    Posts
    97

    Re: Fully load before showing

    I haven't got the code with me right now, but I can make something similar up to give you a better idea.

    Private sub form1_load(byval sender as object, e as system.eventargs) handles me.load
    for each btn as button in Groupbox1.controls
    btn.backgroundImage = my.resources.bluebutton
    next
    end sub

    Private sub Button1_Click(byval sender as object, e as system.eventargs) handles button1.click
    for each btn as button in Groupbox1.controls
    btn.backgroundImage = my.resources.redbutton
    next
    groupbox1.location = new point(100,100)
    groupbox2.visible = true
    end sub



    Sorry about the colours not being there, I typed the code dirrectly on here.
    Last edited by Developer2007; Sep 20th, 2007 at 02:38 AM.

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Fully load before showing

    I can't quite see why you'd be setting the BackgroundImage of the Button's from resources in the Load event handler when you can set them at design time.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Aug 2007
    Posts
    97

    Re: Fully load before showing

    Some one help please

  8. #8
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Fully load before showing

    Quote Originally Posted by jmcilhinney
    I can't quite see why you'd be setting the BackgroundImage of the Button's from resources in the Load event handler when you can set them at design time.
    What is the answer to this? I share the confusion.

  9. #9
    PowerPoster 2.0 Negative0's Avatar
    Join Date
    Jun 2000
    Location
    Southeastern MI
    Posts
    4,367

    Re: Fully load before showing

    If I had to guess, based on the fact that he changes them to red buttons in a button click, that it may be some sort of skinning effect he is going for.

    If I recall correctly the Form_Load code will complete before the form is shown unless you explicitly set Me.Visible = True.

  10. #10
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: Fully load before showing

    try this... before you start changing the images... jsut before your loop add this:

    me.SuspendLayout

    Then after the loop and you are done changing things add this:
    me.ResumeLayout

    See if that helps.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  11. #11
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,109

    Re: Fully load before showing

    I agree, the basic problem is that the screen is refreshing faster than your changes are happening, and each individual change is repainting. What you want to have happen is that all the changes are made, then the whole form re-draws itself. What TG suggested might cover it. You might look up the DoubleBuffering, but I'm not sure that will necessarily work in this case, as I think the drawing will be too slow for double buffering to completely take care of the case.
    My usual boring signature: Nothing

  12. #12

    Thread Starter
    Lively Member
    Join Date
    Aug 2007
    Posts
    97

    Re: Fully load before showing

    The following as I said is only a sample to give everyone an idea of what the situation is. I'm fully aware of what a waste of time it would be to load all the buttions red when you could have don't that during design time. Just an example guys\girls.

    Thanks for all the repies, I will be trying the suspend layout and resume layout to see if it is any better. I'll give you an update on how it went once my cold get's better, hopefully this will solve the problem.

    More suggestions are welcome, I will test them all once I feel better.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width