|
-
Jan 10th, 2004, 06:53 PM
#1
Thread Starter
Frenzied Member
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

-
Jan 11th, 2004, 09:18 AM
#2
Sleep mode
Try this in the form's constructor .
VB Code:
SetStyle(ControlStyles.DoubleBuffer, True)
-
Jan 11th, 2004, 10:22 AM
#3
Thread Starter
Frenzied Member
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

-
Jan 13th, 2004, 12:55 PM
#4
Thread Starter
Frenzied Member
-
Jan 13th, 2004, 01:03 PM
#5
Sleep mode
Does this happen while the image is there ? or do you think it's because there are a lot of controls ?
-
Jan 13th, 2004, 01:18 PM
#6
Thread Starter
Frenzied Member
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

-
Jan 13th, 2004, 01:29 PM
#7
Sleep mode
Last edited by Pirate; Jan 13th, 2004 at 02:28 PM.
-
Jan 13th, 2004, 02:51 PM
#8
Thread Starter
Frenzied Member
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

-
Jan 13th, 2004, 03:11 PM
#9
Sleep mode
Umm what about starting that form in a thread different than the UI thread . I believe this would give you positive result .
-
Jan 14th, 2004, 01:42 PM
#10
Thread Starter
Frenzied Member
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

-
Jan 14th, 2004, 01:51 PM
#11
Sleep mode
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 ?
-
Jan 14th, 2004, 02:03 PM
#12
Thread Starter
Frenzied Member
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:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'Call zzz()
Dim t As New System.Threading.Thread(AddressOf zzz)
t.Priority = System.Threading.ThreadPriority.AboveNormal
t.Start()
End Sub
Private Sub zzz()
Dim xx As New Form2
xx.ShowDialog(Me)
End Sub
~Peter

-
Jan 14th, 2004, 02:12 PM
#13
Sleep mode
-
Jan 14th, 2004, 03:16 PM
#14
Thread Starter
Frenzied Member
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

-
Jan 22nd, 2005, 05:44 PM
#15
Lively Member
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.....
-
Jan 22nd, 2005, 10:23 PM
#16
Junior Member
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
-
May 22nd, 2006, 11:36 AM
#17
Hyperactive Member
Re: Form_Load - Slow Painting
Hi!
I have a similar problem. Any solution, please?
regards
-
Oct 17th, 2007, 09:51 PM
#18
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|