StrataFrame Forum

RegistryRepositoryKey saving the wrong SF_FormHeight value

http://forum.strataframe.net/Topic21643.aspx

By Edhy Rijo - 1/23/2009

Hi,

I have a main MDI form and I have setup the following properties:

  • RegistryRepositoryKey = HKEY_CURRENT_USER\Software\Progytech\Card Tracking System\MainDialog
  • RememberFormLocation = True
  • RememberFormMaximizedState = True
  • RememberFormSize = True

Now when I open this form, it will update the registry as follow:

Without doing any change to the Main Form size, I close the application and run it again, then new values are being saved in the registry, causing the form to keep showing up with the wrong height value.

Notice that the SF_FormHeight and SF_FormY values are the one that changed without me resizing the form.  Now this form has an UltraToolbarsManager acting as a RibbonBar and an UltraStatusBar which I believe may be causing this effect, since I do have other projects using the same Main Form without the infragistics controls and does not show this behavior. 

I have the following code in the OnLoad method of the form:

Protected Overrides Sub OnLoad(ByVal e As System.EventArgs)

     MyBase.OnLoad(e)

     Dim applicationTitle As String = "Card Tracking System"

     Me.Text = String.Format("{0} ({1})", applicationTitle, My.Application.Info.Version.ToString)

     '-- Set the MDI backcolor to white

     _MDIClient.BackColor = System.Drawing.Color.White

     '-- Add the MDI

     Me.Controls.Add(_MDIClient)

     '-- Create a handle to the CurrentUserChanged event to update the user information shown in main form.

     AddHandler MicroFour.StrataFrame.Security.SecurityBasics.CurrentUserChanged, AddressOf UpdateCurrentUserInfo

     Me.UpdateCurrentUserInfo()

     '-- Set the Connection label on the status bar

     Me.UltraStatusBar1.Panels("sbConnectedTo").Text = "Connected to: " & GetApplicationActiveConnectionStringTitle(ConnectionManager.ApplicationKey, "")

End Sub

This Main Form was created based on the Main Form in the StrataFlix sample, you can see the MainFormSample.png file attached for a reference.

Is there any recommendation to solve this situation?

By Trent L. Taylor - 1/25/2009

Edhy, this is going to be next to impossible to diagnose like this.  I will need a sample reproducing the behavior.  The reason is that code that you have within your dialog can influence this and alter the instantiation order or pre/post restoration values.  This is a very common feature that is used so I will definitely need to have a sample so that I can trace this to see where the issue resides.
By Edhy Rijo - 1/25/2009

Hi Trent,

Sure, I understand, I will create a sample.

By Trent L. Taylor - 1/25/2009

Thanks! Smile
By Edhy Rijo - 1/26/2009

Hi Trent,

Attached please find a quick and dirty sample of my based ribbon project which uses the Infragistics UltraToolbarsManager as a Ribbon UI.

Many of my code has been either commented out or added an "Exit Sub" statement to make the sample functional to show the basic problem of the main form being resized each time the application is run until it will shrink completely.

I added 2 sample forms "First and Second Forms" in the ribbon first 2 buttons, so you can test.

After fixing any missing reference, all you need to do to test is just run the application and exit several times, you will noticed that the main form RegistryRepositoryKey "HKEY_CURRENT_USER\Software\Progytech\Ribbon_Sample\MainDialog" will change all the time the application is closed, and also will see the effect of the main form getting smaller every time it is ran.

By Edhy Rijo - 1/29/2009

A friendly reminder, just in case you guys have missed the sample posted in the previous thread.

Thanks!

By Trent L. Taylor - 1/29/2009

We haven't forgotten about this and you were supposed to have been informed on this.  But we do not have the Infragistics version that you are using here, so we have not yet even gotten this going.  From a cursory glance, though, it is going to most likely be injected code that is causing the issue.  This is not reproducable in any other format and we have verified that all of the SF plumbing in this regard is working properly.  Is there anyway that you can reproduce this without Infragistics?
By Edhy Rijo - 1/29/2009

Trent L. Taylor (01/29/2009)
But we do not have the Infragistics version that you are using here, so we have not yet even gotten this going.

I fogot to mention the version I have is NetAdvantage for .Net 8.1.20081.1000.  I was under the impression that if you have a newer version it would be a matter of just changing the references.

Trent L. Taylor (01/29/2009)
Is there anyway that you can reproduce this without Infragistics?

So far with other projects in which I am not using the UltraToolbarsManager I have not seen that side effect, so it must definately be related to that object being placed in the form which may be causing the code that saves the form size when closing to get the wrong values.

Maybe you could tell me which and where is the code responsible for saving the fomr's position on the registry and I could probably overwrite that method in the main form in order to debug it and find a fix.

By Trent L. Taylor - 1/29/2009

It is the OnFormClosing method within the BaseForm class in the Business assembly.  There is a method called SaveSizeAndLocation that gets called.
By Edhy Rijo - 1/29/2009

Hi Trent,

Thanks for the information.  I found the problem in the RestoreSizeAndLocation() method in this line of code:

'-- Set the size

If Me.RememberFormSize Then

     Me.Height = lnHeight

     Me.Width = lnWidth

End If

In this assignment Me.Height will not assume or accept the value in lnHeight, I would guess it has to do with the way the form is instantiated with the UltraToolbarsManager.  Here is what I did:

  • Override the RestoreSizeAndLocation() in my main form, of course I had to add the private Constant needed.
  • In my Onload, I added a call to Me.RestoreSizeAndLocation() which actually will be run twice and that seem to temporarily fix the problem.  Here is the code:
  •  

    Protected Overrides Sub OnLoad(ByVal e As System.EventArgs)

         MyBase.OnLoad(e)

         Dim applicationTitle As String = "Card Tracking System"

         Me.Text = String.Format("{0} ({1})", applicationTitle, My.Application.Info.Version.ToString)

         '-- Set the MDI backcolor to white

         _MDIClient.BackColor = System.Drawing.Color.White

         '-- Add the MDI

         Me.Controls.Add(_MDIClient)

         '-- Create a handle to the CurrentUserChanged event to update the user information shown in main form.

         AddHandler MicroFour.StrataFrame.Security.SecurityBasics.CurrentUserChanged, AddressOf UpdateCurrentUserInfo

         Me.UpdateCurrentUserInfo()

         '-- Set the Connection label on the status bar

         Me.UltraStatusBar1.Panels("sbConnectedTo").Text = "Connected to: " & GetApplicationActiveConnectionStringTitle(ConnectionManager.ApplicationKey, "")

         '-- This code is used temporarily until a final solution is available for the main form honoring the

         ' registry saved size and location.

         Me.RestoreSizeAndLocation()

    End Sub

Probably you can suggest a better temporary approach that does not require to overwrite the RestoreSizeAndLocation().

By Dustin Taylor - 1/30/2009

FYI, I went ahead and stripped out your references and replaced them with v7.3 infragistics (what I have on my dev machine), and the problem does not occur on my machine. Do you have any machines at your office on an older version of infragistics? Perhaps it is something in the newer version that is causing the disconnect?
By Edhy Rijo - 1/30/2009

Hehe
Dustin Taylor (01/30/2009)
Do you have any machines at your office on an older version of infragistics? Perhaps it is something in the newer version that is causing the disconnect?

Hi Dustin,

Thanks for trying it out, unfortunately I do not have v7.3, but calling Me.RestoreSizeAndLocation() after MyBase.OnLoad(e) in the MainForm does the trick and I believe that is a proof of an instantiation timing issue, don't know if something could be done in the SF source to prevent this issue with this control or any other in this case.

Could it be possible for you to install the new infragistics trial for further testing? Now that I have a custom fix there is no rush on this on your part