문제

기본 MDI 상위 제어에는 여러 자식 양식을 표시 할 수있는 큰 "데스크톱"영역이 있습니다. 사용자는 대부분의 자식 양식이 화면에서 벗어날 수 있도록이 데스크탑 영역의 가장자리로 양식을 드래그 할 수 있습니다. (스크롤 막대가 MDI 부모에 나타납니다)이 기능이 마음에 들지 않습니다. 아동 형태가 완전히 보이도록 데스크탑 영역의 가장자리를 잠그는 방법이 있습니까?

도움이 되었습니까?

해결책

  1. MDI 창 스크롤 바를 비활성화하십시오
  2. 모든 어린이 창문의 Onmove 이벤트를 연결하십시오. 창이 경계 밖으로 이동하면 부모 안으로 돌아올 때까지 X와 Y를 따라 다시 "팝"하십시오.

다른 팁

위에서 선택한 답변을 구현하는 데 사용한 코드는 다음과 같습니다.

Public alreadyMoved As Boolean = False
Public Const HEIGHT_OF_MENU_STATUS_BARS As Integer = 50
Public Const WIDTH_OF_MENU_STATUS_BARS As Integer = 141
Private Sub Form_Move(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles MyBase.Move
    If Not alreadyMoved Then
        alreadyMoved = True

        'If I'm over the right boundry, drop back to right against that edge
        If Me.Location.X + Me.Width > _
            MdiParent.ClientRectangle.Width - WIDTH_OF_MENU_STATUS_BARS Then
            MyBase.Location = New System.Drawing.Point( _
                (MdiParent.ClientRectangle.Width - Me.Width - _
                WIDTH_OF_MENU_STATUS_BARS), MyBase.Location.Y)
        End If

        'If I'm over the bottom boundry, drop back to right against that edge
        If Me.Location.Y + Me.Height > _
            MdiParent.ClientRectangle.Height - HEIGHT_OF_MENU_STATUS_BARS Then
            MyBase.Location = New System.Drawing.Point( _
                MyBase.Location.X, (MdiParent.ClientRectangle.Height - _
                Me.Height - HEIGHT_OF_MENU_STATUS_BARS))
        End If

        'If I'm over the top boundry, drop back to the edge
        If Me.Location.Y < 0 Then
            MyBase.Location = New System.Drawing.Point(MyBase.Location.X, 0)
        End If

        'If I'm over the left boundry, drop back to the edge
        If Me.Location.X < 0 Then
            MyBase.Location = New System.Drawing.Point(0, MyBase.Location.Y)
        End If
    End If
    alreadyMoved = False
End Sub

명확히하기 위해, 당신이 말하는 것은 MDI 클라이언트의 "데스크탑"영역이 클라이언트 영역입니다.

아동 양식의 크기 조정/이동 이벤트 핸들러를 처리 한 다음 MDI 클라이언트 영역의 한계를 초과 할 때 아동의 움직임을 크기를 조정/제한 할 수 있습니다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top