Slow drawing forms


Author
Message
Ben Kim
Ben Kim
StrataFrame Novice (115 reputation)StrataFrame Novice (115 reputation)StrataFrame Novice (115 reputation)StrataFrame Novice (115 reputation)StrataFrame Novice (115 reputation)StrataFrame Novice (115 reputation)StrataFrame Novice (115 reputation)StrataFrame Novice (115 reputation)StrataFrame Novice (115 reputation)
Group: Forum Members
Posts: 99, Visits: 253
Has anyone come up with a solution to this issue?  I have seen this on the simplist of forms (20-30 controls).  You can watch the forms draw.  Sometimes taking 4-5 seconds.  I know .NET needs to compile it the first time when run so I reran the form and it after the initial compile.  Same results.

I have tried adding Me.SuspendLayout() prior to enabling/disabling controls (buttons with graphics seem to flicker when you Disable/Enable them), then .ResumeLayout after my settings.  I have tried turning on DoubleBuffering which seemed to do nothing.

I do not have the fastest machine or best graphics card available.  I use other development environments that compile to Win32 code and do not exhibit this behavior.  Yes I know .NET is compiled/optimized at runtime, but once compiled I would expect it to perform at the same level as a native Win32 generate application.

Am I expecting too much from .NET?

Ben

StrataFrame Team
S
StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
No, with only 20-30 controls on the form, it should initialize and render much faster than 4-5 seconds.  Most likely, something else is causing a problem.  The SecurityDialog in the RBS has something like 60 controls on it. 

If you need to analyze the problem, I would recommend ANTS from Red-Gate software.  You can download their trial, which runs for 14 days.  Profile your application, and it will tell you how much time each line of code took when it ran.  That might give you a clue as to what is chewing up 4+ seconds in your form's loading.

Michael Cobb
Michael Cobb
StrataFrame Beginner (26 reputation)StrataFrame Beginner (26 reputation)StrataFrame Beginner (26 reputation)StrataFrame Beginner (26 reputation)StrataFrame Beginner (26 reputation)StrataFrame Beginner (26 reputation)StrataFrame Beginner (26 reputation)StrataFrame Beginner (26 reputation)StrataFrame Beginner (26 reputation)
Group: Forum Members
Posts: 26, Visits: 1K
I have a related question.  My machine is probably slightly better equipped than what my customer base uses.  My specs are 1GB RAM and 128MB VRAM.  I have an MDI child form that was created from the StrataFrame Maintenance template.  Because I want to utilize themes, I dropped themed panel onto the background of the form.  On top of that, I dropped a SF TabControl to which I added two pages.  On each page of the TabControl I dropped a themed panel.  On the themed panel for the first tab page, I added 64 label controls (half SF and half Windows standard), a SF themed GroupBox, a SF RadioButtonGroup with three radio buttons and a SF button.  This gives me a total of less than 80 controls that I added to the form. 

In Design Mode, before I even linked anything to a BO, the tab page that has all of the controls on it drew slowly in (about a second but definitly able to visibly see the controls drawing, especially the labels).  If I click the 2nd tab page and back to the 1st it redraws slowly.  If I put another window on top of the VS IDE, the form draws slowly when I close or move the other window.

At run time, I received the same results.

I've tried different approaches to speed this up.  1) I placed all of the UI controls on a SF Standard Form with no panels or tabs (faster, but still visible).  2) All of the UI controls replaced by standard windows controls, placed on a standard windows form (about the same as #1).  3) All of the SF labels on the original form replaced with SF Text boxes (still slow).  All of these forms draw faster at run time if they are launched as standalone instead of MDI children.

Is there anything out of the ordinary that I've mentioned (about my system or what I'm doing) that might cause such a slow rendering of forms in both design mode and at run time?

TIA.

StrataFrame Team
S
StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
There are a couple of options we've done that help drawing stuff like that.

1) Setting DoubleBuffered = True on the parent form.  This will cause all of the drawing to be done on a buffer and then painted to the screen to help reduce flickering.

2) Research into the LockWindow() method of the User32.dll (it's a windows API call).  You can make the IP call by passing the .Handle of the parent form and it will prevent the entire form from painting.  Then, when you know that all of the controls are visible, you can call the LockWindow() again and pass IntPtr.Zero to unlock the window and all of the controls will paint at the same time.

Michael Cobb
Michael Cobb
StrataFrame Beginner (26 reputation)StrataFrame Beginner (26 reputation)StrataFrame Beginner (26 reputation)StrataFrame Beginner (26 reputation)StrataFrame Beginner (26 reputation)StrataFrame Beginner (26 reputation)StrataFrame Beginner (26 reputation)StrataFrame Beginner (26 reputation)StrataFrame Beginner (26 reputation)
Group: Forum Members
Posts: 26, Visits: 1K
Thanks for the advice Ben, I'll give those methods a shot and see if that helps.  It might not help much since they are also slow drawing during design time, but at least maybe I can delay showing the form until everything is in place.
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search