StrataFrame Forum

Problem with showing form...

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

By Ben Hayat - 7/12/2007

Note: I have tried the same following routine with a regular Windows application and SF Application, and the problem only occurs with SF form. Very simple to duplicate.



a) Create an SF application.

b) Stretch the form bigger than the default.

c) Set the the "WindowState" to Minimize.

d) Drop a "NotifyIcon" component and put the following code for the "Double Click" event:



if (this.WindowState == FormWindowState.Minimized)

{

this.StartPosition = FormStartPosition.CenterScreen;

this.WindowState = FormWindowState.Normal;

this.Activate();

}



When the form shows, the top left conner gets centered, rather than the form itself. Therefore, the form gets pushed to bottom right of the screen.



I did the exact thing with Windows app, and it works right. I think SF creates a collection of forms in the "Program.cs" and when it tries to paint the form, it gets messed up.



Can you advise please?

Thanks!


By Ben Hayat - 7/12/2007

Can you tell me how I can upload the test app in this forum?



Thanks!
By Greg McGuffey - 7/12/2007

Just zip up the solution and add it as an attachment (scroll down, its under the emotocons) (if I'm following your question).
By Ben Hayat - 7/13/2007

Greg McGuffey (07/12/2007)
Just zip up the solution and add it as an attachment (scroll down, its under the emotocons) (if I'm following your question).




Thanks Greg; I missed the bottom part.



Here is a small program for SF to look at.
By Trent L. Taylor - 7/13/2007

Ben,

This isn't a StrataFraem issue from what I can tell because we don't do anything with the form positions.  We don't stored off the loaded forms.  All of this functionality is native to .NET and we do not modify it.  However, you can fix your problem by adding the following code in the DoubleClick of the NotifyIcon.

this.WindowState = FormWindowState.Normal;
this.CenterToScreen();
By Ben Hayat - 7/13/2007

Trent L. Taylor (07/13/2007)
Ben,



This isn't a StrataFraem issue from what I can tell because we don't do anything with the form positions. We don't stored off the loaded forms. All of this functionality is native to .NET and we do not modify it. However, you can fix your problem by adding the following code in the DoubleClick of the NotifyIcon.



this.WindowState = FormWindowState.Normal;

this.CenterToScreen();




Hi Trent;



Your solution works, but seems like the only difference between my code and yours is:

Yours: this.CenterToScreen();

Mine: this.StartPosition = FormStartPosition.CenterScreen;



Why is that?



Secondly, here a sample that is identical to SF, but uses normal Windows form and my approach worked



But thanks for reply!
By Trent L. Taylor - 7/13/2007

Why is that?

The CenterToScreen is a method that immediately executes the code to center the window.   When you set the StartPosition it is not immediately evaluated and executed.  CenterToScreen will always work.

By Ben Hayat - 7/13/2007

The CenterToScreen is a method that immediately executes the code to center the window. When you set the StartPosition it is not immediately evaluated and executed. CenterToScreen will always work.


Now, how did you know this? Smile

You're "D" man! Thanks...