Thanks Tim, I'm confussed by the behavior but I'm satisfied that I have a
solution. Sorry for the misplaced reply on my last post.
"Tim Wilson" wrote:
> I'm seeing this behavior now. I didn't have a MainMenu on my Form before but
> once I dropped one on an extra 19 pixels (the size of a menu according to
> the SystemInformation.MenuHeight value on my system) was added to the Form
> height. So it does look like it's related to the MainMenu. Unfortunately, I
> don't have a concrete reason for this. I searched through the google
> archives and this has come up before. Some one explained the issue and the
> link is below. However, like you have already done, it seems to work ok
> within a Load event handler.
>
>
http://groups.google.ca/group/microsoft.public.dotnet.framework.windowsforms/msg/9a43c8bf559c70a3?dmode=source&hl=en
>
> --
> Tim Wilson
> ..Net Compact Framework MVP
>
> "jlavallet" <jlavallet@discussions.microsoft.com> wrote in message
> news:36EE086B-3C8B-45EA-9C99-F1F57CC25A39@microsoft.com...
> > Yes, I set it to Manual. I used the property sheet in the Form designer
> to
> > set this property so it is called in InitializeComponent like so:
> >
> > this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
> >
> >
> >
> >
> > "jlavallet" wrote:
> >
> > > I'm using Bounds (although I did try Left, Top, and Size also).
> > >
> > > Here's some code:
> > >
> > > My Form constructor:
> > >
> > > public FormMDIContainer()
> > > {
> > > //
> > > // Required for Windows Form Designer support
> > > //
> > > InitializeComponent();
> > >
> > > //
> > > // TODO: Add any constructor code after InitializeComponent call
> > > //
> > > Rectangle bounds = Options.Instance.ApplicationOptions.Bounds;
> > > this.Bounds = bounds;
> > > }
> > >
> > > And my Form Closing handler
> > >
> > > private void FormMDIContainer_Closing(object sender,
> > > System.ComponentModel.CancelEventArgs e)
> > > {
> > > Rectangle bounds = this.Bounds;
> > > Options.Instance.ApplicationOptions.Bounds = bounds;
> > > Options.Instance.ApplicationOptions.PersistOptions();
> > > }
> > >
> > > The Options class is a singleton that persists and loads my app options
> to
> > > and from the Registry. The lines that load (called in the
> ApplicationOptions
> > > constructor) and persist the bounds are:
> > >
> > > public void LoadOptions()
> > > {
> > > // ... open the key
> > >
> > > string stringX = (string) keyApp.GetValue("X", "10");
> > > string stringY = (string) keyApp.GetValue("Y", "10");
> > > string stringWidth = (string) keyApp.GetValue("Width", "790");
> > > string stringHeight = (string) keyApp.GetValue("Height", "530");
> > >
> > > int intX = Convert.ToInt32(stringX);
> > > int intY = Convert.ToInt32(stringY);
> > > int intWidth = Convert.ToInt32(stringWidth);
> > > int intHeight = Convert.ToInt32(stringHeight);
> > >
> > > Bounds = new Rectangle(intX, intY, intWidth, intHeight);
> > > }
> > >
> > > public bool PersistOptions()
> > > {
> > > // ... get the key
> > >
> > > keyApp.SetValue("X", Bounds.X.ToString());
> > > keyApp.SetValue("Y", Bounds.Y.ToString());
> > > keyApp.SetValue("Width", Bounds.Width.ToString());
> > > keyApp.SetValue("Height", Bounds.Height.ToString());
> > >
> > > return true;
> > > }
> > >
> > > And my Bounds property:
> > >
> > > private Rectangle rectangleBounds;
> > >
> > > public Rectangle Bounds
> > > {
> > > get { return rectangleBounds; }
> > > set { rectangleBounds = value; }
> > > }
> > >
> > > "Tim Wilson" wrote:
> > >
> > > > How are you setting the size? Are you assigning to the Size property
> or
> > > > Bounds property or other? Post some code.
> > > >
> > > > --
> > > > Tim Wilson
> > > > ..Net Compact Framework MVP
> > > >
> > > > "jlavallet" <jlavallet@discussions.microsoft.com> wrote in message
> > > > news:BC606A27-DA48-4CB9-9E6D-7E4B324FA264@microsoft.com...
> > > > > Hi,
> > > > >
> > > > > I'm saving the bounds of my Form in the Registry in my Form's
> closing
> > > > event
> > > > > and restoring the bounds when my app is launched. Everything works
> well
> > > > > except the persisted Height increases by 20 each run of my app. No
> other
> > > > > dimensions change. My Form has a main menu and a status bar and
> both are
> > > > > part of the Form at design time (I had suspected the Height increase
> to
> > > > come
> > > > > from the Height of one of these controls). Any ideas?
> > > > >
> > > > > Thanks,
> > > > > Jack
> > > >
> > > >
> > > >
>
>