I have a vb6 application where I am trying to change the form size and the form controls based on the users screen resolution. I have gotten the size of the form to change based on the screen resolution but the controls are staying the same size. Can anyone help me figure this out. Here is what the module looks like that contains the code.
<CODE>
Option Explicit
Public iHeight As Integer
Public iWidth As Integer
Public x_size As Double
Public y_size As Double
Public List() As Control
Public curr_obj As Object
Public Type RECT
x1 As Long
y1 As Long
x2 As Long
y2 As Long
End Type
Public Declare Function GetDesktopWindow Lib "User32" () As Long
Public Declare Function GetWindowRect Lib "User32" _
(ByVal hWnd As Long, rectangle As RECT) As Long
Public Sub UserForm_Activate(UserForm1 As Form)
Dim r As RECT
Dim hWnd As Long
Dim RetVal As Long
Dim ScrRes As String
Dim FtSz As Integer
Dim curScreen As Object
hWnd = GetDesktopWindow()
RetVal = GetWindowRect(hWnd, r)
ScrRes = (r.x2 - r.x1) & "X" & (r.y2 - r.y1)
'Use ScrRes variable to decide how to size the userform.
' If ScrRes = "640X480" Then
' With UserForm1
' UserForm1.Width = 7680
' UserForm1.Height = 5760
' End With
If ScrRes = "800X600" Then
With UserForm1
UserForm1.Width = 11140
UserForm1.Height = 9000
End With
ElseIf ScrRes = "1024X768" Then
With UserForm1
UserForm1.Width = 11428
UserForm1.Height = 9612
End With
ElseIf ScrRes = "1280X800" Then
With UserForm1
UserForm1.Width = 14500
UserForm1.Height = 9600
End With
ElseIf ScrRes = "1360X768" Then
With UserForm1
UserForm1.Width = 15460
UserForm1.Height = 9612
End With
ElseIf ScrRes = "1680X1050" Then
With UserForm1
UserForm1.Width = 15940
UserForm1.Height = 10500
End With
End If
End Sub
</CODE>
<CODE>
Option Explicit
Public iHeight As Integer
Public iWidth As Integer
Public x_size As Double
Public y_size As Double
Public List() As Control
Public curr_obj As Object
Public Type RECT
x1 As Long
y1 As Long
x2 As Long
y2 As Long
End Type
Public Declare Function GetDesktopWindow Lib "User32" () As Long
Public Declare Function GetWindowRect Lib "User32" _
(ByVal hWnd As Long, rectangle As RECT) As Long
Public Sub UserForm_Activate(UserForm1 As Form)
Dim r As RECT
Dim hWnd As Long
Dim RetVal As Long
Dim ScrRes As String
Dim FtSz As Integer
Dim curScreen As Object
hWnd = GetDesktopWindow()
RetVal = GetWindowRect(hWnd, r)
ScrRes = (r.x2 - r.x1) & "X" & (r.y2 - r.y1)
'Use ScrRes variable to decide how to size the userform.
' If ScrRes = "640X480" Then
' With UserForm1
' UserForm1.Width = 7680
' UserForm1.Height = 5760
' End With
If ScrRes = "800X600" Then
With UserForm1
UserForm1.Width = 11140
UserForm1.Height = 9000
End With
ElseIf ScrRes = "1024X768" Then
With UserForm1
UserForm1.Width = 11428
UserForm1.Height = 9612
End With
ElseIf ScrRes = "1280X800" Then
With UserForm1
UserForm1.Width = 14500
UserForm1.Height = 9600
End With
ElseIf ScrRes = "1360X768" Then
With UserForm1
UserForm1.Width = 15460
UserForm1.Height = 9612
End With
ElseIf ScrRes = "1680X1050" Then
With UserForm1
UserForm1.Width = 15940
UserForm1.Height = 10500
End With
End If
End Sub
</CODE>