تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
[سؤال] كيف احل مشكلة نافذة البرنامج التي تختلف في كل شاشة ضروووري
#20
أعتقد الفكرة التالية ربما تكون مفيدة لك في ما تريده...لكن عليك أن تقوم بكتابة دوال أو روتين لكل أنواع الكونترول لديك في الفورم
لأن بعض الكونترول عبارة عن Nested Control و بالتالي عليك ان تكتب روتين يناسب كل كونترول علي حده
متهيألي من الأفضل أن تكتب مكتبة Library لعمل Scale لكل الكونترول الموجودة في الدوت نت


كود :
Public Class Form1

    Private scaleFactor As New SizeF(2.35F, 2.35F)

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Me.AutoScaleMode = Windows.Forms.AutoScaleMode.Dpi
    End Sub

    Protected Overrides Sub ScaleControl(factor As SizeF, specified As BoundsSpecified)
        MyBase.ScaleControl(factor, specified)
        scaleFactor = New SizeF(scaleFactor.Width * factor.Width, scaleFactor.Height * factor.Height)
        ScaleTabControl(Me, scaleFactor)
    End Sub

    Private Sub ScaleTabControl(form As Form, factor As SizeF)

        Dim frm As Form = form.FindForm
        For Each ctrl As Control In frm.Controls
            If TypeOf ctrl Is TabControl Then
                ctrl.Width = CInt(Math.Round(ctrl.Width * factor.Width))
                ctrl.Height = CInt(Math.Round(ctrl.Height * factor.Height))
                ctrl.Location = New Point((ctrl.Location.X * factor.Width), (ctrl.Location.Y * factor.Height))
            End If
        Next

        ' The panels (tabPages) shall adjust itself automatically so the current code is not required
        'For Each Panel As Panel In tabControl.TabPages
        '    Panel.Width = CInt(Math.Round(Panel.Width * factor.Width))
        '    Panel.Height = CInt(Math.Round(Panel.Height * factor.Height))
        '    Panel.Location = New Point((Panel.Location.X * factor.Width), (Panel.Location.Y * factor.Height))
        'Next

    End Sub

End Class


عليك أيضا أن تقوم بكتابة دوال لتغيير الفونت و الصور معا
الرد }}}
تم الشكر بواسطة:


الردود في هذا الموضوع
RE: كيف احل مشكلة نافذة البرنامج التي تختلف في كل شاشة ضروووري - بواسطة silverlight - 03-05-14, 06:11 PM


التنقل السريع :


يقوم بقرائة الموضوع: