以最大大小启动应用程序 [英] Launching the application in maximized size

查看:106
本文介绍了以最大大小启动应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

朋友们...

我想在使用选择最大化按钮时以最大化形式启动应用程序,然后最小化应用程序,然后关闭..

我的代码是...在表单关闭事件中..

Hi frnds...

I want to launch the application in the maximized form when use select maximized button and then minimize the application, and then close..

My code is... In Form Closing event..

if (this.WindowState == FormWindowState.Minimized)
                {
                    Properties.Settings.Default.MyState = FormWindowState.Normal;
                }
                else
                {
                    Properties.Settings.Default.MyState = this.WindowState;
                }
                if (this.WindowState == FormWindowState.Normal)
                {
                    Properties.Settings.Default.MySize = this.Size;
                    Properties.Settings.Default.MyLoc = this.Location;
                }
                else
                {
                    Properties.Settings.Default.MySize = this.RestoreBounds.Size;
                    Properties.Settings.Default.MyLoc = this.RestoreBounds.Location;
                }
                Properties.Settings.Default.Save();



现在它仅在正常状态下启动..


请任何人帮助我...



Now it is launching in the normal state only..


Please anybody help me...

推荐答案

您应该在Form的Load事件中放入这样的代码
You should put some code like this in your Form''s Load event
this.WindowState = Properties.Settings.Default.MyState;


I我不确定我是否理解您的问题.让我尝试一下:

1.第一次应最大程度地打开表单(可以使用窗口状态属性来完成).
2.此后,每次打开表格时应与关闭时一样.如果已将其最小化,请正常打开. (对吗?)

您将需要保存已经在做的表格的位置和大小.但是,是否在下次打开表单时将值分配给适当的属性?这应该在Load事件之前完成.

处理该窗体的StateChanged事件,并保存用于告知该窗体已最大化的设置.在关闭表单中,再次检查状态,并根据需要更新设置.以下应该会有所帮助:

I am not really sure if I understood your problem. Let me try though:

1. First time the form should open maximized (This can be done using window state property).
2. After that every time the form should be opened as it was at the time of closing. If it was minimized, open normally. (Right?)

You will need to save the location and size of the form which you are already doing. But are you assigning the value to appropriate properties next time the form is opened? This should be done before Load event.

Handle the StateChanged event for the for the form and save the settings that tell that the form was maximized. In the form closing check the state again and update setting if needed. Following should help:

StateChangedEventHandler Begin

If WindowState is Maximized then

OpenMaximizedNextTimeSetting = true

End

End

FormClosingEventHandler Begin

If OpenMaximizedNextTimeSetting is true and (WindowState is not minimized OR WindowState is not maximized) then

OpenMaximizedNextTimeSetting = false

End

End



HTH



HTH


您是否正在回读这些设置,并在打开表单时应用它们?

顺便说一句:您不需要继续使用this.-所有非静态方法中都暗含了它.保存它,直到需要它来解决名称冲突为止.
And are you reading these settings back, and applying them when you open the form?

BTW: You don''t need to keep on using this. - it is implied in all non-static methods. Save it until you need it to sort out name conflicts.


这篇关于以最大大小启动应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆