窗口大小调整问题 [英] window resizing problem

查看:95
本文介绍了窗口大小调整问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好.

我不知道为什么我要调整窗口大小.要求是
用户将重新调整窗口大小从运行时开始,当她退出并重新运行应用程序时,它将使用以前的设置加载,例如,窗口高度,重量,启动位置等.

Hi Guys..

I dont know why I''m suffering window resizing problem. The requirement is
user will re-size the window From run time, when s/he exit and re run the application it will load with the previous setting, For example, window height, weight, start up position etc.

Can any one help me to resolve this?

推荐答案

此CP ^ ]可能成为良好的开始位置.请确保还阅读注释.
this CP article[^] may be good starting position. Make sure to read the comments as well.


这也可能是 ^ ].


我知道您最好在C#中转换此VB.NET代码.
恢复表单的尺寸和大小非常简单职位.
仅代码,无设置用途.

I know you better can convert this VB.NET code in C#.
It''s very simple to restore a form''s size & positions.
Codes only, no settings usage.

Public Class Form1
    Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        Saveform()
    End Sub
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Restoreform()
    End Sub
    Private Regpath As String = "HKEY_CURRENT_USER\Software\"
    Sub Saveform()
        My.Computer.Registry.SetValue(Regpath & My.Application.Info.Title, "WindowState", Val(Me.WindowState))
        If Me.WindowState <> FormWindowState.Normal Then
            Return
        End If
        My.Computer.Registry.SetValue(Regpath & My.Application.Info.Title, "Top", Me.Top)
        My.Computer.Registry.SetValue(Regpath & My.Application.Info.Title, "Left", Me.Left)
        My.Computer.Registry.SetValue(Regpath & My.Application.Info.Title, "Height", Me.Height)
        My.Computer.Registry.SetValue(Regpath & My.Application.Info.Title, "Width", Me.Width)
    End Sub
    Sub Restoreform()
        'Dim xx = My.Computer.Registry.GetValue(Regpath & My.Application.Info.Title, "WindowState", Me.WindowState)
        Me.WindowState = Val(My.Computer.Registry.GetValue(Regpath & My.Application.Info.Title, "WindowState", Me.WindowState))
        If Me.WindowState <> FormWindowState.Normal Then
            'Return
        End If
        Me.Top = My.Computer.Registry.GetValue(Regpath & My.Application.Info.Title, "Top", Me.Top)
        Me.Left = My.Computer.Registry.GetValue(Regpath & My.Application.Info.Title, "Left", Me.Left)
        Me.Height = My.Computer.Registry.GetValue(Regpath & My.Application.Info.Title, "Height", Me.Height)
        Me.Width = My.Computer.Registry.GetValue(Regpath & My.Application.Info.Title, "Width", Me.Width)
    End Sub
End Class



我对这篇文章感到困惑:在C#中恢复表单的位置和大小 [ ^ ]
为什么对一个简单的操作如此复杂.



I''m confused about the article: Restore Form Position and Size in C#[^]
Why it is so complex for a simple operation.


这篇关于窗口大小调整问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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