Results 1 to 18 of 18

Thread: Form_Load - Slow Painting

  1. #1

    Thread Starter
    Frenzied Member MrGTI's Avatar
    Join Date
    Oct 2000
    Location
    Ontario, Canada
    Posts
    1,277

    Question Form_Load - Slow Painting

    This is a very minor issue, but i have a form with a background image and a few controls, but when i open this form, the form is painted in blocks/sections, and it looks very poor during that 1 or 2 seconds.

    How can i make the form load itself first, and then show itself, without the delay to paint itself that it currently has??

    ~Peter


  2. #2
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Try this in the form's constructor .
    VB Code:
    1. SetStyle(ControlStyles.DoubleBuffer, True)

  3. #3

    Thread Starter
    Frenzied Member MrGTI's Avatar
    Join Date
    Oct 2000
    Location
    Ontario, Canada
    Posts
    1,277

    Thumbs down

    I tried that in the Form_Load and the InitializeComponent routines, and the choppy appearance still occurs.

    While it's drawing the form on the screen, you can see through it in sections. I've got a fast computer. Any ideas?
    ~Peter


  4. #4

    Thread Starter
    Frenzied Member MrGTI's Avatar
    Join Date
    Oct 2000
    Location
    Ontario, Canada
    Posts
    1,277

    Question

    Any ideas ??
    ~Peter


  5. #5
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Does this happen while the image is there ? or do you think it's because there are a lot of controls ?

  6. #6

    Thread Starter
    Frenzied Member MrGTI's Avatar
    Join Date
    Oct 2000
    Location
    Ontario, Canada
    Posts
    1,277

    Post

    First the image appears on the screen - but it's got holes in it where the controls are supposed to be. Then the controls appear, and the form is complete.

    This all happens in a second or two, but the effect is strange to see happen, because it basically paints only a portion of the form on the screen at a time.

    I even tried placing a Me.Hide/Me.Visible=False at the begining of the Form_Load event, and then reversing this at the end of the event.
    ~Peter


  7. #7
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Try these two links . They might give you some tips , hopefully .
    http://www.syncfusion.com/FAQ/WinFor...73c.asp#q1023q http://www.syncfusion.com/FAQ/WinForms/FAQ_c3c.asp
    Last edited by Pirate; Jan 13th, 2004 at 02:28 PM.

  8. #8

    Thread Starter
    Frenzied Member MrGTI's Avatar
    Join Date
    Oct 2000
    Location
    Ontario, Canada
    Posts
    1,277

    Post

    The form does have a series of labels, and they are the items that are not being drawn quickly enough to avoid the holes in the form. They also all have transparent background colours.

    So i tried playing with the backcolor and Flatstyle of the controls (which was Flatstyle.Standard, not system). I even coloured the labels (backcolor=White), but you see can see right through the form when it loads.

    In VB6 we could do a variety of things to allow the form to load before it appears. But so far i haven't been able to find a way to load the form before drawing it.
    ~Peter


  9. #9
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Umm what about starting that form in a thread different than the UI thread . I believe this would give you positive result .

  10. #10

    Thread Starter
    Frenzied Member MrGTI's Avatar
    Join Date
    Oct 2000
    Location
    Ontario, Canada
    Posts
    1,277

    Question

    It's worth a shot i guess. Can you even open a form in a thread and still have it modal to the current form? I'd guess yes, but i never tried.
    ~Peter


  11. #11
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Yes , I believe . I've seen a splash screen example done by threading . It's pretty cool but it's in C# in Codeproject.com . You wanna have a look ?

  12. #12

    Thread Starter
    Frenzied Member MrGTI's Avatar
    Join Date
    Oct 2000
    Location
    Ontario, Canada
    Posts
    1,277

    Thumbs down

    I just tried it, and it didn't work in both ways. The form was still painted choppy and broken, and the new form was not modal.

    Unless i'm doing it wrong,.....
    VB Code:
    1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    2.         'Call zzz()
    3.         Dim t As New System.Threading.Thread(AddressOf zzz)
    4.         t.Priority = System.Threading.ThreadPriority.AboveNormal
    5.         t.Start()
    6.     End Sub
    7.  
    8.     Private Sub zzz()
    9.         Dim xx As New Form2
    10.         xx.ShowDialog(Me)
    11.     End Sub
    ~Peter


  13. #13
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    This might give you a clue .It's splash screen examples but sure should handles such problems .

    http://www.codeproject.com/csharp/Pr...plash%7Cscreen
    http://www.codeproject.com/csharp/ap...plash%7Cscreen

  14. #14

    Thread Starter
    Frenzied Member MrGTI's Avatar
    Join Date
    Oct 2000
    Location
    Ontario, Canada
    Posts
    1,277

    Post

    My problem is with an About form, not a splash form, but some of the same concepts still exist. I will review the C# code and see if i can find a solution in the way they do it.
    ~Peter


  15. #15
    Lively Member Atte's Avatar
    Join Date
    Feb 2004
    Posts
    79

    Re: Form_Load - Slow Painting

    hi, did you ever find a solution to this problem (Form_Load - slow painting)...? i would be more than interested to hear.....

  16. #16
    Junior Member
    Join Date
    Jan 2005
    Posts
    27

    Re: Form_Load - Slow Painting

    There are a couple of posts about it in this blog that may help, here's one of the days:

    http://www.codinghorror.com/blog/archives/000177.html

  17. #17
    Hyperactive Member anna7's Avatar
    Join Date
    Sep 2005
    Location
    Catalonia
    Posts
    481

    Re: Form_Load - Slow Painting

    Hi!

    I have a similar problem. Any solution, please?

    regards

  18. #18
    PowerPoster BruceG's Avatar
    Join Date
    May 2000
    Location
    New Jersey (USA)
    Posts
    2,657

    Re: Form_Load - Slow Painting

    Well, this is an old thread, but I am having a similar issue (i.e., when the form loads, you can initially see "holes" where the controls are supposed to be). Much of the code in the form load event has to do with loading comboboxes and other startup tasks. I still experience the issue (although not as bad) when moving the code to the Activated event.

    Can anyone offer a solution?
    "It's cold gin time again ..."

    Check out my website here.

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