![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| Guest | Storing and accessing application settings I want to store the location and size of my application window when the app closes and reuse this information when the app is started again. How can I do this? This is what my app code looks like: public class MyApp : Application { protected override void OnStartup(StartupEventArgs e) { MyWin win = new MyWin(); win.Left = 222; win.Top = 111; win.Width = 666; win.Height = 444; win.Show(); } } Instead of having the fixed numbers I want to read them from a location where they are stored when the app closes. Thanks, fö |
My System Specs![]() |
| | #2 (permalink) |
| Guest | RE: Storing and accessing application settings You can use the new application settings concept from .NET 2.0 You add to the project settings the window parameters (four doubles or a rectangle), at startup you read the values, at shutdown you save the values. For example, right-click the project -> Properties -> Settings Add 4 settings (WindowLeft, WindowTop, WindowWidth, WindowHeight) of type double, scope User and some default values. On startup: win.Left = Settings.Default.WindowLeft; win.Top = Settings.Default.WindowTop; .... On shutdown or when the window is closed: Settings.Default.WindowLeft = win.Left; Settings.Default.WindowTop = win.Top; .... Settings.Default.Save(); -- Valentin Iliescu [MVP C#] "fö" wrote: > I want to store the location and size of my application window > when the app closes and reuse this information when the app > is started again. How can I do this? > This is what my app code looks like: > > public class MyApp : Application > { > protected override void OnStartup(StartupEventArgs e) > { > MyWin win = new MyWin(); > > win.Left = 222; > win.Top = 111; > win.Width = 666; > win.Height = 444; > > win.Show(); > } > } > > Instead of having the fixed numbers I want to read them > from a location where they are stored when the app closes. > > Thanks, > fö > |
My System Specs![]() |
| | #3 (permalink) |
| Guest | RE: Storing and accessing application settings Hi Valentin, well that sounds real good, but it doesn't work! The compiler does not know the type "Settings" (I suppose it should be in namespace System.Configuration). Furthermore the Dec CTP SDK Documentation does not know a Settings class. In addition the SDK documents a class ConfigurationManager which should have an AppSettings property of type AppSettingsSection (all included in System.Configuration). But even these types are not known by the compiler. So what's going wrong? Thanks. "viliescu" wrote: > You can use the new application settings concept from .NET 2.0 > > You add to the project settings the window parameters (four doubles or a > rectangle), > at startup you read the values, at shutdown you save the values. > > For example, right-click the project -> Properties -> Settings > Add 4 settings (WindowLeft, WindowTop, WindowWidth, WindowHeight) of type > double, scope User and some default values. > > On startup: > win.Left = Settings.Default.WindowLeft; > win.Top = Settings.Default.WindowTop; > ... > > On shutdown or when the window is closed: > Settings.Default.WindowLeft = win.Left; > Settings.Default.WindowTop = win.Top; > ... > Settings.Default.Save(); > > -- > Valentin Iliescu [MVP C#] > > > "fö" wrote: > > > I want to store the location and size of my application window > > when the app closes and reuse this information when the app > > is started again. How can I do this? > > This is what my app code looks like: > > > > public class MyApp : Application > > { > > protected override void OnStartup(StartupEventArgs e) > > { > > MyWin win = new MyWin(); > > > > win.Left = 222; > > win.Top = 111; > > win.Width = 666; > > win.Height = 444; > > > > win.Show(); > > } > > } > > > > Instead of having the fixed numbers I want to read them > > from a location where they are stored when the app closes. > > > > Thanks, > > fö > > |
My System Specs![]() |
| | #4 (permalink) |
| Guest | RE: Storing and accessing application settings Settings class is not in .Net libraries but is created automatically in the project (look in Solution Explorer for Properties directory and you will find the Settings.Designer.cs file). It is defined in MyProject.Properties namespace (if "MyProject" is the name of the project) so you'll have to import it. -- Valentin Iliescu [MVP C#] "fö" wrote: > Hi Valentin, > > well that sounds real good, but it doesn't work! > The compiler does not know the type "Settings" > (I suppose it should be in namespace System.Configuration). > Furthermore the Dec CTP SDK Documentation does not know > a Settings class. > > In addition the SDK documents a class ConfigurationManager > which should have an AppSettings property of type > AppSettingsSection (all included in System.Configuration). > But even these types are not known by the compiler. > > So what's going wrong? > > Thanks. > > "viliescu" wrote: > > > You can use the new application settings concept from .NET 2.0 > > > > You add to the project settings the window parameters (four doubles or a > > rectangle), > > at startup you read the values, at shutdown you save the values. > > > > For example, right-click the project -> Properties -> Settings > > Add 4 settings (WindowLeft, WindowTop, WindowWidth, WindowHeight) of type > > double, scope User and some default values. > > > > On startup: > > win.Left = Settings.Default.WindowLeft; > > win.Top = Settings.Default.WindowTop; > > ... > > > > On shutdown or when the window is closed: > > Settings.Default.WindowLeft = win.Left; > > Settings.Default.WindowTop = win.Top; > > ... > > Settings.Default.Save(); > > > > -- > > Valentin Iliescu [MVP C#] > > > > > > "fö" wrote: > > > > > I want to store the location and size of my application window > > > when the app closes and reuse this information when the app > > > is started again. How can I do this? > > > This is what my app code looks like: > > > > > > public class MyApp : Application > > > { > > > protected override void OnStartup(StartupEventArgs e) > > > { > > > MyWin win = new MyWin(); > > > > > > win.Left = 222; > > > win.Top = 111; > > > win.Width = 666; > > > win.Height = 444; > > > > > > win.Show(); > > > } > > > } > > > > > > Instead of having the fixed numbers I want to read them > > > from a location where they are stored when the app closes. > > > > > > Thanks, > > > fö > > > |
My System Specs![]() |
| | #5 (permalink) |
| Guest | RE: Storing and accessing application settings Thanks, it works! "viliescu" wrote: > Settings class is not in .Net libraries but is created automatically in the > project (look in Solution Explorer for Properties directory and you will find > the Settings.Designer.cs file). > It is defined in MyProject.Properties namespace (if "MyProject" is the name > of the project) so you'll have to import it. > -- > Valentin Iliescu [MVP C#] > > > "fö" wrote: > > > Hi Valentin, > > > > well that sounds real good, but it doesn't work! > > The compiler does not know the type "Settings" > > (I suppose it should be in namespace System.Configuration). > > Furthermore the Dec CTP SDK Documentation does not know > > a Settings class. > > > > In addition the SDK documents a class ConfigurationManager > > which should have an AppSettings property of type > > AppSettingsSection (all included in System.Configuration). > > But even these types are not known by the compiler. > > > > So what's going wrong? > > > > Thanks. > > > > "viliescu" wrote: > > > > > You can use the new application settings concept from .NET 2.0 > > > > > > You add to the project settings the window parameters (four doubles or a > > > rectangle), > > > at startup you read the values, at shutdown you save the values. > > > > > > For example, right-click the project -> Properties -> Settings > > > Add 4 settings (WindowLeft, WindowTop, WindowWidth, WindowHeight) of type > > > double, scope User and some default values. > > > > > > On startup: > > > win.Left = Settings.Default.WindowLeft; > > > win.Top = Settings.Default.WindowTop; > > > ... > > > > > > On shutdown or when the window is closed: > > > Settings.Default.WindowLeft = win.Left; > > > Settings.Default.WindowTop = win.Top; > > > ... > > > Settings.Default.Save(); > > > > > > -- > > > Valentin Iliescu [MVP C#] > > > > > > > > > "fö" wrote: > > > > > > > I want to store the location and size of my application window > > > > when the app closes and reuse this information when the app > > > > is started again. How can I do this? > > > > This is what my app code looks like: > > > > > > > > public class MyApp : Application > > > > { > > > > protected override void OnStartup(StartupEventArgs e) > > > > { > > > > MyWin win = new MyWin(); > > > > > > > > win.Left = 222; > > > > win.Top = 111; > > > > win.Width = 666; > > > > win.Height = 444; > > > > > > > > win.Show(); > > > > } > > > > } > > > > > > > > Instead of having the fixed numbers I want to read them > > > > from a location where they are stored when the app closes. > > > > > > > > Thanks, > > > > fö > > > > |
My System Specs![]() |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Accessing Windows application from Web application? | its_faiz | .NET General | 0 | 07-09-2008 08:04 AM |
| Application Settings user settings storage directory | Chris Crowther MBCS | .NET General | 5 | 04-09-2008 04:02 AM |
| Accessing Firewall settings from WMI | Keith Hill | PowerShell | 6 | 04-24-2007 02:31 PM |
| ASP application accessing a C++ COM DLL is giving security error. | John | Vista General | 0 | 08-03-2006 07:51 AM |
| ASP application accessing a C++ COM DLL is giving security error. | John | Vista security | 0 | 08-03-2006 07:50 AM |