c# - Weird behavior saving application location and size -


I am using Windows Form (C #). I save my window location and size to disk in the closing event of my form using the following properties:

  (int) width, height -> gt; ; Using the form. Size Property (int) Location X, Location Y - & gt; Use of the form Place Property (BULL) Maximum - & gt; Using the form. WindState Property   

The form is primarily an application when the application loads, then I set those properties in the form. this is easy.

Well, most of the time it works right, but sometimes, only occasionally, the application is shown very little. I have added the debug info and these forms are returned values:

  2011-09-01 20: 02: 44,334 DEBUG 9884 man settings - width - & gt; 160 2011-09-01 20: 02: 44,334 DEBUG 9884 Mainframe Settings - Height - & gt; 27 2011-09-01 20: 02: 44,334 DEBUG 9884 Mainform Settings - Location X - & gt; -32000 2011-09-01 20: 02: 44,334 DEBUG 9884 Mainform Settings - Location - - & gt; -32000 2011-09-01 20: 02: 44,334 DEBUG 9884 Main form settings - max - & gt; I believe that my window was not of that size (160, 27) and the location was not even -32000, because I only use one monitor.  

It seems that when I have been opening the application for a long time, but not sure.

  • Do you know why ever for these strange values? Thanks

    The coordinates you are seeing are due to the fact that when it closes the application becomes less. Windows actually "hides" its form by transferring it from its coordinates to some ridiculously large negative X, Y coordinates.

    Verified Program:

    Output from a Forms app on Vista:

    Current coordinates X: 184 Y: 184 * Default location Current coordinates X: -32000 Y : -32000 * Minimum Position

    By Code:

    System. Diagnostics .Debug.WriteLine ("Current coordinates X:" + location.x + "Y:" + location .Y);

    To solve this, I'll just check the value when your app is closed, not actually saving it in the file.

    If you do not want to mess with mathematics on arbitrary coordination values, then you can also see WindowStat

    I found the answer in the previous SEO post above the answer.



Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

c# - Confused over DLL entry points (entry point not found exception) -