سؤال

يحتوي عنصر التحكم الأصل 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