Restore application settings

  • Thread starter Thread starter Udo Nesshoever
  • Start date Start date
U

Udo Nesshoever

Hi yall!

Has anyone expirienced the same?
I align some controls on a form (set the anchors, right align some so
everything resizes/moves nicely when the form is resized.
I store the forms size and position into the applications settings.

When I restart and reload these settings, the application first set's
the forms new size, then create all the controls (with the sizes
stored during design time) and sets all the anchors etc. That means,
the form had the "wrong" size during the creation of the controls.

Am I missing something? Do I have to store the position and size of
each and every control on this form?
I thought (coming from Delphi), the form is created, the controls are
set and THEN the formerlt stored size and position of rthe form is set
and therefore all controls are - of course - nice resized (by the
anchors), too.

I'd reeeeeeeeeeeeally like to avoid storing/reloading ALL controls'
sizes and positions. Any hints? Any help?

Anything appreciated!

Cheers,
Udo
 
Hi yall!

Has anyone expirienced the same?
I align some controls on a form (set the anchors, right align some so
everything resizes/moves nicely when the form is resized.
I store the forms size and position into the applications settings.

When I restart and reload these settings, the application first set's
the forms new size, then create all the controls (with the sizes
stored during design time) and sets all the anchors etc. That means,
the form had the "wrong" size during the creation of the controls.

Am I missing something? Do I have to store the position and size of
each and every control on this form?
I thought (coming from Delphi), the form is created, the controls are
set and THEN the formerlt stored size and position of rthe form is set
and therefore all controls are - of course - nice resized (by the
anchors), too.

I'd reeeeeeeeeeeeally like to avoid storing/reloading ALL controls'
sizes and positions. Any hints? Any help?

Anything appreciated!

Cheers,
Udo

We could really do with some sample code, but as far as I understand
it so far, it's more a matter of timing.
The IntializaComponent method creates all controls with their sizes.
You should set your form size etc after that (can't be done any other
way since the controls aren't properly initialized before).
BTW Don't mess around in the InitializeComponent chances are it gets
overwritten by the designer

Leon
 
I have a similar problem
See following posting in WindowsForms.Controls

Subject: Saving User Settings Problem with ClientSize and WindowState
Conflict
Date: Monday, April 10, 2006 12:46 PM

I am trying to save the Location, ClientSize and WindowState attributes for
restoration for each client upon restart, but am running into this problem.

Move the window, close, reopen -- no problem window is saved position
Try to maximise window -- returns to 0,0 Location and Client Size is the
same as original (i.e. Not Maximized).
Close Window and restart, window is maximized on restart.

Can you give me any insight.

Developing in Visual Studio 2005 Professional Edition.

Jamie
 
We could really do with some sample code, but as far as I understand
it so far, it's more a matter of timing.
The IntializaComponent method creates all controls with their sizes.
You should set your form size etc after that (can't be done any other
way since the controls aren't properly initialized before).
BTW Don't mess around in the InitializeComponent chances are it gets
overwritten by the designer

The problem is, that (using .net 2.0) I'm configuring the whole
settings just with the designer -> the designer produces "wrongly
timed code' - each time I change something in the UI.
I thought/hoped that there was something like a switch/flag to be set.

Cheers,
Udo
 
I have a similar problem
See following posting in WindowsForms.Controls

Subject: Saving User Settings Problem with ClientSize and WindowState
Conflict
Date: Monday, April 10, 2006 12:46 PM

I am trying to save the Location, ClientSize and WindowState attributes for
restoration for each client upon restart, but am running into this problem.

Move the window, close, reopen -- no problem window is saved position
Try to maximise window -- returns to 0,0 Location and Client Size is the
same as original (i.e. Not Maximized).
Close Window and restart, window is maximized on restart.

Can you give me any insight.

Looks like the same "wrong order of property setting" problem I'm
struggling with.
A workaround for yours is doing it manually.
Saving:
1. save the windows state
2. if WindowsState != normal -> set to normal
3. save size and location of your form.

Loading:
1. restore size and location of form
2. restore WindowsState.

Then it works!

And I guess, I have to do that with my problem, too.
Setting the form's WindowsState, Size and Location maually.
 
Back
Top