programing

사용자가 양식의 크기를 조정하지 못하도록하려면 어떻게합니까?

coolbiz 2021. 1. 18. 08:14
반응형

사용자가 양식의 크기를 조정하지 못하도록하려면 어떻게합니까?


VB.net에서 최대화해야하는 양식이 있습니다. 사용자가 크기를 변경하거나 이동하는 것을 원하지 않습니다. 어떻게 할 수 있습니까?


강조 표시된 속성을 설정합니다. MaximimSize 및 MinimizeSize 속성을 동일한 크기로 설정

여기에 이미지 설명 입력


//Set fixed border
yourForm.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D

//Set the state of your form to maximized       
yourForm.WindowState = FormWindowState.Maximized

//Disable the minimize box and the maximize box
yourForm.MinimizeBox = False
yourForm.MaximizeBox = False

사용자가 크기를 조정하지 못하도록하려면 속성 창이나 코드에서 FormBoderStyle을 Fixed3D 또는 FixedDialog로 설정합니다.

frmYour.BorderStyle = System.WinForms.FormBorderStyle.Fixed3D

그리고 WindowState 속성을 Maximized로 설정하고 MaximizeBox 및 MinimizeBox 속성을 false로 설정합니다.

사용자가 이동하는 것을 방지하려면 WndProc를 재정의하십시오.

Protected Overrides Sub WndProc(ByRef m As Message)
        Const WM_NCLBUTTONDOWN As Integer = 161
        Const WM_SYSCOMMAND As Integer = 274
        Const HTCAPTION As Integer = 2
        Const SC_MOVE As Integer = 61456

        If (m.Msg = WM_SYSCOMMAND) And (m.WParam.ToInt32() = SC_MOVE) Then
            Return
        End If

        If (m.Msg = WM_NCLBUTTONDOWN) And (m.WParam.ToInt32() = HTCAPTION) Then
            Return
        End If

        MyBase.WndProc(m)
    End Sub

창 시작 스타일을 최대화로 설정하십시오. 그런 다음 최소화 및 최대화 버튼을 숨 깁니다.


다음을 사용하여이를 제어하기 위해 UI를 제거 할 수 있습니다.

frmYour.MinimizeBox = False
frmYour.MaximizeBox = False

Form Load 이벤트에 몇 가지 코드를 추가합니다.

me.maximumsize = new size(Width, Height)
me.minimumsize = me.maximumsize
me.maximizebox = false
me.minimizebox = false

예 : 양식 높이와 너비가 각각 50 픽셀 인 경우 :

me.maximumsize = new size(50, 50)
me.minimumsize = me.maximumsize
me.maximizebox = false
me.minimizebox = false

Note that setting maximumsize and minimumsize to the same size as shown here prevents resizing the Form.


Set FormBorderStyle to 'FixedDialog'

FixedDialog


If you want to prevent resize by dragging sizegrips and by the maximize button and by maximize by doubleclick on the header text, than insert the following code in the load event of the form:

    Me.FormBorderStyle = Windows.Forms.FormBorderStyle.FixedSingle ' Prevent size grips
    Me.MaximumSize = Me.Size ' Prevent maximize (also by doubleclick of header text)

Of course all choices of a formborderstyle beginning with Fixed will do.


Set the min and max size of form to same numbers. Do not show min and max buttons.


Just change these settings in the Solution Explorer.

MaximizeBox = False
MinimizeBox = False 

The other things such as ControlBox, Locked, and FormBorderStyle are extra.


There is an option in vb.net that lets you do all this.

<code> lock = false </ code>를 <code> locked = true </ code>로 설정합니다.

The user wont be able to re-size the form or move it around, although there are other ways, this I think is the best.

참조 URL : https://stackoverflow.com/questions/1119256/how-do-i-prevent-a-form-from-being-resized-by-the-user

반응형