Winform rendering pretty slow


Author
Message
Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
Glad it helped you with your problem.  Smile
Edhy Rijo
E
StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Trent L. Taylor (04/15/2008)
This at least gives you more control than just setting the IsMDIContainer proeprty to True and then you can start to create your application environment.

Trent,

You certainly nailed the problem with this sample solution.  In no time I was able to replace the old code in my Main Form and now the rendering problem is virtually gone.

I took the liberty of adding some functionality to the LaunchForm method that will do the following:

  1. Before creating a new form object, check through the _MDI form's collection for an existing instance.
  2. If found then activate that instance and bring it to the front.

Here is the changed code:

''' <summary>

''' Common method for automatically launching a form and making it an MDI child.

''' If the form exist in the _MDI collection then show it to the user instead.

''' This functionality could be controlled by passing a 2nd parameter

''' </summary>

''' <param name="FormType"></param>

''' <remarks></remarks>

Private Sub LaunchForm(ByVal FormType As System.Type)

     '-- Establish Locals

     Dim loForm As Form

     '-- Create the form

     loForm = CType(Activator.CreateInstance(FormType), Form)

     For Each currentForm As Form In Me._MDI.Controls

          If currentForm.Name = loForm.Name Then

               '-- If the form is minimized then restore it.

               If currentForm.WindowState = FormWindowState.Minimized Then

                    currentForm.WindowState = FormWindowState.Normal

               End If

               '-- Show the form on top of the others.

               currentForm.BringToFront()

               Exit Sub

          End If

     Next

     '-- Set the MDI parent

     loForm.MdiParent = Me

     '-- Show the form

     loForm.Show()

End Sub



Edhy Rijo

Edhy Rijo
E
StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Thanks Trent,

Will check your sample and implement in my current project.  Once again, your help is must appreciated.Tongue

Edhy Rijo

Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
This is turning into somewhat of a lesson on windows, rendering, and handles....all things that are related to WinForms development versus StrataFrame itself.  We too ran into rendering issues in some of our applications...and we had to stop, figure out where the issues were, and work through them.  One of the primary issues that we ran into were MDI forms and the MDIClient class.

We wrote our own MDI environment for our medical application so that rendering would be faster.  However, one thing that is generally a bad idea is to just set the IsMDIContainer property to true...many issues come from doing this.

You are always better of creating an MDIClient class and then adding it to your form, which will in affect turn that form into an MDI.  I have attached a sample of how to do this.  You can then take this to the next level by adding form loading logic, etc, when it is added to the MDI.  You can render the back of the MDI client (in this sample I just set the background to white).  But there are a lot of things that you can do.

This at least gives you more control than just setting the IsMDIContainer proeprty to True and then you can start to create your application environment.

Attachments
MDIClientSample.zip (151 views, 79.00 KB)
Edhy Rijo
E
StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Hi Trent,

Thanks again for the support.

I tried your code in the CRM and as you said, it worked as expected.BigGrin

Now I put the code in the Maintenance Form as suggested in my project and what I am seeing is that the form will not render until it is moved by me using the mouse.

Please take a look at this small video sample that illustrate what I am experiencing: http://www.progytech.com/videos/SF_Sample2/SF_Sample2.html

Just to clarify:

  • The MDI MainForm is using the DevExpress Ribbon control (not the Ribbon form class).
  • The Maintenance Form is using SF controls including the modified ListView (SynchListView) posted by Greg McGuffey in this link http://forum.strataframe.net/FindPost14966.aspx


Edhy Rijo

Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
Edhy,

I reproduced your problem through an MDI environment identically to you video...so you must be placing the code in the wrong places or have something else that is overriding the locks.

Ok, I am not sure where to put this code, in the Main Form or in one of the maintenance forms?

The maintenance form...NOT the main form!!!

Even thought I tried on both and the result was basically the same, the rendering is pretty slow.

I took the CRM Sample Application and reproduced the problem, took the Customer Maintenance Form and added the code above, I also changed the Themed controls to not render transparents and render with solid backgrounds and all issues that you were talking about...to the "T" went away.

Edhy Rijo
E
StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Hi Trent,

Sorry I could not get back to you earlier, I was out today the whole day.

Ok, I am not sure where to put this code, in the Main Form or in one of the maintenance forms?

Even thought I tried on both and the result was basically the same, the rendering is pretty slow.

Edhy Rijo

Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
Edhy,

I was testing something in the CRM sample and noticed a similar behavior to your video.  One thing that you can do to resolve this very easily is to lock the screen once a handle is created and then unlock it once it is shown:

Protected Overrides Sub OnHandleCreated(ByVal e As System.EventArgs)
    MyBase.OnHandleCreated(e)
    MicroFour.StrataFrame.Tools.LockScreen.Lock(Me)
End Sub

Protected Overrides Sub OnShown(ByVal e As System.EventArgs)
    MyBase.OnShown(e)
    MicroFour.StrataFrame.Tools.LockScreen.Unlock()
End Sub

I will play with is some more later to see what events are being raised and what the MDI client is doing, but this should give you a quick fix.

Note:  If you use this in conjunction with the non-transparent controls...it is instantanious!  No flicker at all!

Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
OK...a final, final thought BigGrin

I am working from home today and on a really slow machine (I totally need to rebuild my home computer).  I am also talking to a remote data source in another town via a cable modem VPN.  On top of that, I just installed a new version of Camtasia and I didn't adjust anything and when I ran the app with Camtasia running and it slowed my machine WAY down.  But even with all of that, the screens loaded pretty quickly.  When running in a normal environment there is no lag or delay at all.  I just though you might want to see what I was talking about.  I have attached a video here running a very small portion of our medical application.  So you can see this coming from a large scale real-world application.

Attachments
QuickSample.zip (147 views, 6.00 MB)
Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
One other thing I thought about that can improve performance is to preload your assemblies into the AppDoman.  This will improve the initial instantiation speed the first time.  An assembly reference won't be loaded into the AppDomain until it is first used.  So if you preload these it will speed up the performance the first time an assembly is used.  Just another idea.
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