Problem with showing form...


Author
Message
Ben Hayat
Ben Hayat
Advanced StrataFrame User (548 reputation)Advanced StrataFrame User (548 reputation)Advanced StrataFrame User (548 reputation)Advanced StrataFrame User (548 reputation)Advanced StrataFrame User (548 reputation)Advanced StrataFrame User (548 reputation)Advanced StrataFrame User (548 reputation)Advanced StrataFrame User (548 reputation)Advanced StrataFrame User (548 reputation)
Group: Forum Members
Posts: 374, Visits: 1.2K
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!




..ßen
Ben Hayat
Ben Hayat
Advanced StrataFrame User (548 reputation)Advanced StrataFrame User (548 reputation)Advanced StrataFrame User (548 reputation)Advanced StrataFrame User (548 reputation)Advanced StrataFrame User (548 reputation)Advanced StrataFrame User (548 reputation)Advanced StrataFrame User (548 reputation)Advanced StrataFrame User (548 reputation)Advanced StrataFrame User (548 reputation)
Group: Forum Members
Posts: 374, Visits: 1.2K
Can you tell me how I can upload the test app in this forum?



Thanks!


..ßen
Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.4K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
Just zip up the solution and add it as an attachment (scroll down, its under the emotocons) (if I'm following your question).
Ben Hayat
Ben Hayat
Advanced StrataFrame User (548 reputation)Advanced StrataFrame User (548 reputation)Advanced StrataFrame User (548 reputation)Advanced StrataFrame User (548 reputation)Advanced StrataFrame User (548 reputation)Advanced StrataFrame User (548 reputation)Advanced StrataFrame User (548 reputation)Advanced StrataFrame User (548 reputation)Advanced StrataFrame User (548 reputation)
Group: Forum Members
Posts: 374, Visits: 1.2K
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.


..ßen
Attachments
WindowsApplication6.zip (85 views, 655.00 KB)
Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
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();

Ben Hayat
Ben Hayat
Advanced StrataFrame User (548 reputation)Advanced StrataFrame User (548 reputation)Advanced StrataFrame User (548 reputation)Advanced StrataFrame User (548 reputation)Advanced StrataFrame User (548 reputation)Advanced StrataFrame User (548 reputation)Advanced StrataFrame User (548 reputation)Advanced StrataFrame User (548 reputation)Advanced StrataFrame User (548 reputation)
Group: Forum Members
Posts: 374, Visits: 1.2K
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!

..ßen
Attachments
WindowsApplication5.zip (85 views, 33.00 KB)
Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
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.

Ben Hayat
Ben Hayat
Advanced StrataFrame User (548 reputation)Advanced StrataFrame User (548 reputation)Advanced StrataFrame User (548 reputation)Advanced StrataFrame User (548 reputation)Advanced StrataFrame User (548 reputation)Advanced StrataFrame User (548 reputation)Advanced StrataFrame User (548 reputation)Advanced StrataFrame User (548 reputation)Advanced StrataFrame User (548 reputation)
Group: Forum Members
Posts: 374, Visits: 1.2K
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...

..ßen
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search