Domanda

Il controllo padre MDI predefinito ha un " desktop " area in cui è possibile visualizzare più moduli figlio. Gli utenti possono trascinare i moduli sul bordo di questa area desktop in modo che la maggior parte del modulo figlio sia fuori dallo schermo. (Viene visualizzata una barra di scorrimento nel genitore MDI) Non mi piace questa funzione. C'è un modo per bloccare il bordo dell'area del desktop in modo che i moduli figlio rimangano completamente visibili?

È stato utile?

Soluzione

  1. Disabilita le barre di scorrimento della finestra MDI
  2. Aggancia l'evento OnMove di tutte le finestre figlio. Se la finestra viene spostata oltre il limite, "quot" pop " ritorna lungo la xey finché non ritorna all'interno del genitore.

Altri suggerimenti

Il codice che ho usato per implementare la risposta che ho selezionato sopra:

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

Per chiarire, quello che dici è il "desktop" l'area del client MDI è l'area client.

È possibile gestire i ridimensionatori / spostare i gestori di eventi dei moduli figlio e quindi ridimensionare / limitare il movimento del figlio quando supera i limiti dell'area client MDI.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top