como cambiar la resolución
Hola
Espero me puedan ayudar a disipar esta duda que tengo, resulta que necesito cambiar la resolución de los formularios de mi proyecto, mas no la del monitor y no tengo idea de como hacerlo, me podrian ayudar con esto. Gracias
Espero me puedan ayudar a disipar esta duda que tengo, resulta que necesito cambiar la resolución de los formularios de mi proyecto, mas no la del monitor y no tengo idea de como hacerlo, me podrian ayudar con esto. Gracias
Podrías usar un Active x llamado ComponenOne Resize, o si no mediante código, aunque es bastante engorroso. En un módulo standard creas la siguiente función:
Sub SetDeviceIndependentWindow(TheForm As Form)
Dim DesignX%
Dim DesignY%
Dim XFactor As Single
Dim YFactor As Single
Dim Z As Integer
XFactor = Screen.Width / 9600
YFactor = Screen.Height / 7200
If XFactor = 1 And YFactor = 1 Then
Exit Sub
End If
TheForm.Move TheForm.Left * XFactor, TheForm.Top * YFactor, TheForm.Width * XFactor, TheForm.Height * YFactor
For Z = 0 To TheForm.Controls.Count - 1
If TypeOf TheForm.Controls(Z) Is Timer Then
ElseIf TypeOf TheForm.Controls(Z) Is Menu Then
ElseIf TypeOf TheForm.Controls(Z) Is Line Then
ElseIf TypeOf TheForm.Controls(Z) Is DriveListBox Then
TheForm.Controls(Z).Move TheForm.Controls(Z).Left * XFactor, TheForm.Controls(Z).Top * YFactor, TheForm.Controls(Z).Width * XFactor
TheForm.Controls(Z).FontSize = TheForm.Controls(Z).FontSize * XFactor
ElseIf TypeOf TheForm.Controls(Z) Is DirListBox Then
TheForm.Controls(Z).Move TheForm.Controls(Z).Left * XFactor, TheForm.Controls(Z).Top * YFactor, TheForm.Controls(Z).Width * XFactor, TheForm.Controls(Z).Height * YFactor
TheForm.Controls(Z).FontSize = TheForm.Controls(Z).FontSize * XFactor
ElseIf TypeOf TheForm.Controls(Z) Is FileListBox Then
TheForm.Controls(Z).Move TheForm.Controls(Z).Left * XFactor, TheForm.Controls(Z).Top * YFactor, TheForm.Controls(Z).Width * XFactor, TheForm.Controls(Z).Height * YFactor
TheForm.Controls(Z).FontSize = TheForm.Controls(Z).FontSize * XFactor
ElseIf TypeOf TheForm.Controls(Z) Is CommandButton Then
TheForm.Controls(Z).Move TheForm.Controls(Z).Left * XFactor, TheForm.Controls(Z).Top * YFactor, TheForm.Controls(Z).Width * XFactor, TheForm.Controls(Z).Height * YFactor
TheForm.Controls(Z).FontSize = TheForm.Controls(Z).FontSize * XFactor
ElseIf TypeOf TheForm.Controls(Z) Is ComboBox Then
If TheForm.Controls(Z).Style <> 1 Then
TheForm.Controls(Z).Move TheForm.Controls(Z).Left * XFactor, TheForm.Controls(Z).Top * YFactor, TheForm.Controls(Z).Width * XFactor
End If
Else
TheForm.Controls(Z).Move TheForm.Controls(Z).Left * XFactor, TheForm.Controls(Z).Top * YFactor, TheForm.Controls(Z).Width * XFactor, TheForm.Controls(Z).Height * YFactor
If TypeOf TheForm.Controls(Z) Is TextBox Then
TheForm.Controls(Z).FontSize = TheForm.Controls(Z).FontSize * XFactor
ElseIf TypeOf TheForm.Controls(Z) Is Label Then
TheForm.Controls(Z).FontSize = TheForm.Controls(Z).FontSize * XFactor
End If
End If
Next Z
End Sub
Luego, desde el formulario que quieras cambiar la resolución, ejecutas lo siguiente:
Me.Top = 0
Me.Left = 0
Me.Height = 7200 ' 480 pixels de alto
Me.Width = 9600 ' 640 pixels de ancho
Call SetDeviceIndependentWindow(Me)
Me.Show
End Sub
Este ejemplo es para algunos tipos de controles. Para agregar más tipos, basta con modificar el código, haciendo líneas equivalentes pero con los controles que necesites. Lo otro, es un ejemplo pensado para una resolución de 640x480. cambiando el número equivalente a los twips, puedes modificar también estos parámetros.
Saludos!
Bartolom
Chile
Sub SetDeviceIndependentWindow(TheForm As Form)
Dim DesignX%
Dim DesignY%
Dim XFactor As Single
Dim YFactor As Single
Dim Z As Integer
XFactor = Screen.Width / 9600
YFactor = Screen.Height / 7200
If XFactor = 1 And YFactor = 1 Then
Exit Sub
End If
TheForm.Move TheForm.Left * XFactor, TheForm.Top * YFactor, TheForm.Width * XFactor, TheForm.Height * YFactor
For Z = 0 To TheForm.Controls.Count - 1
If TypeOf TheForm.Controls(Z) Is Timer Then
ElseIf TypeOf TheForm.Controls(Z) Is Menu Then
ElseIf TypeOf TheForm.Controls(Z) Is Line Then
ElseIf TypeOf TheForm.Controls(Z) Is DriveListBox Then
TheForm.Controls(Z).Move TheForm.Controls(Z).Left * XFactor, TheForm.Controls(Z).Top * YFactor, TheForm.Controls(Z).Width * XFactor
TheForm.Controls(Z).FontSize = TheForm.Controls(Z).FontSize * XFactor
ElseIf TypeOf TheForm.Controls(Z) Is DirListBox Then
TheForm.Controls(Z).Move TheForm.Controls(Z).Left * XFactor, TheForm.Controls(Z).Top * YFactor, TheForm.Controls(Z).Width * XFactor, TheForm.Controls(Z).Height * YFactor
TheForm.Controls(Z).FontSize = TheForm.Controls(Z).FontSize * XFactor
ElseIf TypeOf TheForm.Controls(Z) Is FileListBox Then
TheForm.Controls(Z).Move TheForm.Controls(Z).Left * XFactor, TheForm.Controls(Z).Top * YFactor, TheForm.Controls(Z).Width * XFactor, TheForm.Controls(Z).Height * YFactor
TheForm.Controls(Z).FontSize = TheForm.Controls(Z).FontSize * XFactor
ElseIf TypeOf TheForm.Controls(Z) Is CommandButton Then
TheForm.Controls(Z).Move TheForm.Controls(Z).Left * XFactor, TheForm.Controls(Z).Top * YFactor, TheForm.Controls(Z).Width * XFactor, TheForm.Controls(Z).Height * YFactor
TheForm.Controls(Z).FontSize = TheForm.Controls(Z).FontSize * XFactor
ElseIf TypeOf TheForm.Controls(Z) Is ComboBox Then
If TheForm.Controls(Z).Style <> 1 Then
TheForm.Controls(Z).Move TheForm.Controls(Z).Left * XFactor, TheForm.Controls(Z).Top * YFactor, TheForm.Controls(Z).Width * XFactor
End If
Else
TheForm.Controls(Z).Move TheForm.Controls(Z).Left * XFactor, TheForm.Controls(Z).Top * YFactor, TheForm.Controls(Z).Width * XFactor, TheForm.Controls(Z).Height * YFactor
If TypeOf TheForm.Controls(Z) Is TextBox Then
TheForm.Controls(Z).FontSize = TheForm.Controls(Z).FontSize * XFactor
ElseIf TypeOf TheForm.Controls(Z) Is Label Then
TheForm.Controls(Z).FontSize = TheForm.Controls(Z).FontSize * XFactor
End If
End If
Next Z
End Sub
Luego, desde el formulario que quieras cambiar la resolución, ejecutas lo siguiente:
Me.Top = 0
Me.Left = 0
Me.Height = 7200 ' 480 pixels de alto
Me.Width = 9600 ' 640 pixels de ancho
Call SetDeviceIndependentWindow(Me)
Me.Show
End Sub
Este ejemplo es para algunos tipos de controles. Para agregar más tipos, basta con modificar el código, haciendo líneas equivalentes pero con los controles que necesites. Lo otro, es un ejemplo pensado para una resolución de 640x480. cambiando el número equivalente a los twips, puedes modificar también estos parámetros.
Saludos!
Bartolom
Chile