منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب
[مثال] Screen Resolution - نسخة قابلة للطباعة

+- منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب (http://vb4arb.com/vb)
+-- قسم : قسم لغات البرمجة الاخرى (http://vb4arb.com/vb/forumdisplay.php?fid=4)
+--- قسم : قسم لغة vb6.0 (http://vb4arb.com/vb/forumdisplay.php?fid=18)
+---- قسم : قسم أسئلة vb6.0 (http://vb4arb.com/vb/forumdisplay.php?fid=28)
+---- الموضوع : [مثال] Screen Resolution (/showthread.php?tid=18060)

الصفحات: 1 2


Screen Resolution - Ahmed Abdulla - 17-11-16

السلام عليكم

هذا مثال مرفق لضبط حجم الأدوات علي الفورم ... وعند اضافة Tool bar لا يعمل المثال .. أرجو تعديل الكود بحيث يعمل مع شريط الأدوات ولكم جزيل الشكر


RE: Screen Resolution - السرور - 17-11-16

العنوان Screen Resolution والشرح شي ثاني

انا شفت العنوان Screen Resolution خفت لتكون بتعدل في اجهزة المستسخدمين، فنصيحة لا تلعب في اجهزة المستخدمين فيكرهووك


RE: Screen Resolution - AL_BRNS - 17-11-16

السلام عليكم

غير كود  Form_Resize

PHP كود :
Private Sub Form_Resize()
On Error Resume Next
ResizeControls
End Sub 

بالتوفيق اخي .


RE: Screen Resolution - ahmedabdelaliem - 18-11-16

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

تفضل اخي الحبيب طلبك في المرفقات


بالتوفيق


RE: Screen Resolution - Ahmed Abdulla - 21-11-16

أخي الكريم ahmedabdelaliem جزاك الله خيرا وشكرا علي هذا المجهود الرائع ولكن عند اضافة اداة Image List لا يعمل الكود 


RE: Screen Resolution - ahmedabdelaliem - 21-11-16

حياك الله اخي

هذا الكود بالكامل بعد التعديل احذف الكود كاملا من البرنامج السابق و ضع هذ الكود وضع الاداه و اخبرني بالنتيجه

بالتوفيق


PHP كود :
Option Explicit

' Note that this example does not scale controls within
other controls. For example, if you place a TextBox
' inside a PictureBox, the TextBox's position and
' dimensions are relative to the PictureBox not the
formThis example does not handle this case.
'
It also does not adjust fontsstretch picturesetc.

Private 
Type ControlPositionType
    Left 
As Single
    Top 
As Single
    Width 
As Single
    Height 
As Single
    FontSize 
As Single
End Type

Private m_ControlPositions() As ControlPositionType
Private m_FormWid As Single
Private m_FormHgt As Single


' Arrange the controls for the new size.
Private Sub ResizeControls()
Dim i As Integer
Dim ctl As Control
Dim x_scale As Single
Dim y_scale As Single

    ' 
Don't bother if we are minimized.
    If WindowState = vbMinimized Then Exit Sub

    ' 
Get the form's current scale factors.
    x_scale = ScaleWidth / m_FormWid
    y_scale = ScaleHeight / m_FormHgt

    ' 
Position the controls.
 
   i 1
    For Each ctl In Controls
        With m_ControlPositions
(i)
 
           If TypeOf ctl Is Line Then
                ctl
.X1 x_scale * .Left
                ctl
.Y1 y_scale * .Top
                ctl
.X2 ctl.X1 x_scale * .Width
                ctl
.Y2 ctl.Y1 y_scale * .Height
            Else
            
            If Not 
(TypeOf ctl Is Toolbar Or TypeOf ctl Is ImageListThen
                ctl
.Left x_scale * .Left
                ctl
.Top y_scale * .Top
                ctl
.Width x_scale * .Width
            Else
                If Not 
(TypeOf ctl Is ImageListThen
                ctl
.Height y_scale * .Height
                End 
If
 
               End If
 
               If Not (TypeOf ctl Is ComboBox Or TypeOf ctl Is ImageListThen
                    
' Cannot change height of ComboBoxes.
                    ctl.Height = y_scale * .Height
                End If
                On Error Resume Next
                ctl.Font.Size = y_scale * .FontSize
                On Error GoTo 0
            End If
        End With
        i = i + 1
    Next ctl

End Sub
Save the form's and controls' dimensions.
Private 
Sub SaveSizes()
Dim i As Integer
Dim ctl 
As Control

    
' Save the controls' positions and sizes.
 
   ReDim m_ControlPositions(1 To Controls.Count)
 
   i 1
    For Each ctl In Controls
        With m_ControlPositions
(i)
 
           If TypeOf ctl Is Line Then
                
.Left ctl.X1
                
.Top ctl.Y1
                
.Width ctl.X2 ctl.X1
                
.Height ctl.Y2 ctl.Y1
            Else
            If Not 
(TypeOf ctl Is Toolbar Or TypeOf ctl Is ImageListThen
                
.Left ctl.Left
                
.Top ctl.Top
                
.Width ctl.Width
                
.Height ctl.Height
                
                End 
If
 
               
                On Error Resume Next
                
.FontSize ctl.Font.Size
                On Error 
GoTo 0
            End 
If
 
       End With
        i 
1
    Next ctl

    
' Save the form's size.
 
   m_FormWid ScaleWidth
    m_FormHgt 
ScaleHeight
End Sub

Private Sub Form_Load()
SaveSizes
End Sub

Private Sub Form_Resize()
ResizeControls
End Sub 



RE: Screen Resolution - Ahmed Abdulla - 22-11-16

للأسف أخي الكريم لا يعمل


RE: Screen Resolution - ahmedabdelaliem - 22-11-16

الكود يعمل اخي

انا رفعت لك البرنامج به نفس الكود

بالتوفيق


RE: Screen Resolution - Ahmed Abdulla - 23-11-16

أخي الكريم الأداة اسمها ImageList1

للأسف الكود يعمل جيدا مع Tool bar وكل الأدوات وعند اضافة Image List تحدث المشكلة

انظر الي الملف المرفق


RE: Screen Resolution - ahmedabdelaliem - 23-11-16

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

بصراحه شغال عندي تمام البرنامج شئ غريب سبحان الله ارجو من الاخوه الافاضل تجربة البرنامج هل يعمل ام لا واخباري

جرب مثال اخي امير ان شاء الله يعمل معاك

بالتوفيق