منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب
الحل الأمثل لتعديل حجم الفورم و الأدوات طبقا لحجم الشاشة - نسخة قابلة للطباعة

+- منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب (http://vb4arb.com/vb)
+-- قسم : الأقسام التعليمية - المنتدى القديم (http://vb4arb.com/vb/forumdisplay.php?fid=90)
+--- قسم : مكتبة أكواد المنتدى (http://vb4arb.com/vb/forumdisplay.php?fid=111)
+--- الموضوع : الحل الأمثل لتعديل حجم الفورم و الأدوات طبقا لحجم الشاشة (/showthread.php?tid=7882)



الحل الأمثل لتعديل حجم الفورم و الأدوات طبقا لحجم الشاشة - AHMED HUSSIEN - 09-03-13

السلا عليكم ورحمة الله و بركاته

مرحبا بكم اقدم لكم اليوم الحل الأمثل لتعديل حجم الفورم والأدوات عند تغيير حجم الشاشة

قم بأضافة Class جديد باسم FormResizer

وأنسخ هذا الكود


كود :
[align=left]Imports System
Imports System.Collections.Generic
Imports System.Text
Imports System.Windows.Forms
Imports System.Drawing
Imports System.ComponentModel

Public Class FormResizer

    'Considerations:
    'Change the Form AutoSize Mode to None.
    Private f_HeightRatio As New Single()
    Private f_WidthRatio As New Single()

    Public Sub ResizeForm(ObjForm As Form, DesignerHeight As Integer, DesignerWidth As Integer)
        '#Region "Code for Resizing and Font Change According to Resolution"
        'Specify Here the Resolution Y component in which this form is designed
        'For Example if the Form is Designed at 800 * 600 Resolution then DesignerHeight=600
        Dim i_StandardHeight As Integer = DesignerHeight

        'Specify Here the Resolution X component in which this form is designed
        'For Example if the Form is Designed at 800 * 600 Resolution then DesignerWidth=800
        Dim i_StandardWidth As Integer = DesignerWidth
        Dim i_PresentHeight As Integer = Screen.PrimaryScreen.Bounds.Height

        'Present Resolution Height
        Dim i_PresentWidth As Integer = Screen.PrimaryScreen.Bounds.Width

        'Presnet Resolution Width
        f_HeightRatio = CSng(CSng(i_PresentHeight) / CSng(i_StandardHeight))
        f_WidthRatio = CSng(CSng(i_PresentWidth) / CSng(i_StandardWidth))
        ObjForm.AutoScaleMode = AutoScaleMode.None

        'Make the Autoscale Mode=None
        ObjForm.Scale(New SizeF(f_WidthRatio, f_HeightRatio))
        For Each c As Control In ObjForm.Controls
            If c.HasChildren Then
                ResizeControlStore(c)
            Else
                c.Font = New Font(c.Font.FontFamily, c.Font.Size * f_HeightRatio, c.Font.Style, c.Font.Unit, CByte(0))
            End If
        Next
        ObjForm.Font = New Font(ObjForm.Font.FontFamily, ObjForm.Font.Size * f_HeightRatio, ObjForm.Font.Style, ObjForm.Font.Unit, CByte(0))
    End Sub

    ''' <summary>
    ''' This Function is Used to Change the Font of Controls that are Nested in Other Controls.
    ''' </summary>
    ''' <param name="objCtl"></param>
    Private Sub ResizeControlStore(objCtl As Control)
        If objCtl.HasChildren Then
            For Each cChildren As Control In objCtl.Controls
                If cChildren.HasChildren Then
                    ResizeControlStore(cChildren)
                Else
                    cChildren.Font = New Font(cChildren.Font.FontFamily, cChildren.Font.Size * f_HeightRatio, cChildren.Font.Style, cChildren.Font.Unit, CByte(0))
                End If
            Next
            objCtl.Font = New Font(objCtl.Font.FontFamily, objCtl.Font.Size * f_HeightRatio, objCtl.Font.Style, objCtl.Font.Unit, CByte(0))
        Else
            objCtl.Font = New Font(objCtl.Font.FontFamily, objCtl.Font.Size * f_HeightRatio, objCtl.Font.Style, objCtl.Font.Unit, CByte(0))
        End If
    End Sub
End Class[/align]

فى حدث Form_Load

كود :
[align=left]        Dim Resizer As New FormResizer
        Resizer.ResizeForm(Me, 864, 1152)[/align]



RE: الحل الأمثل لتعديل حجم الفورم و الأدوات طبقا لحجم الشاشة - Mostafa Saad - 24-02-15

Class رائع من شخص راثع
شكرًا جزيلاً على مشاركاتك الطيبة



RE: الحل الأمثل لتعديل حجم الفورم و الأدوات طبقا لحجم الشاشة - ahmedtonsy - 04-11-18

مشكووور علي الكود
سكس سحاق سكس مصري سكس حيوانات افلام سكس مصري قصص سكس محارم