Resolución de pantalla variable
Hola a todos:
Necesito saber si existe alguna propiedad que haga que el contenido de un formulario se vea tanto en una resolución de 1024 como en una resolución de 800x600. Es decir, que los botones me aparezcan bien colocados sea cual sea la resolución de la pantalla.
¿Me he explicado bien?
Gracias de antemano y un saludo.
Necesito saber si existe alguna propiedad que haga que el contenido de un formulario se vea tanto en una resolución de 1024 como en una resolución de 800x600. Es decir, que los botones me aparezcan bien colocados sea cual sea la resolución de la pantalla.
¿Me he explicado bien?
Gracias de antemano y un saludo.
Hola,
No existe tal propiedad. Lo tendrás que hacer a pinrel
saludos y suerte
sdemingo
No existe tal propiedad. Lo tendrás que hacer a pinrel
saludos y suerte
sdemingo
Hay que hacerlo a mano y es un trabajo más o menos, porque hay que aplicar el procedimiento a cada control del formulario.
Acá va un ejemplo de código de como podrías hacerlo. Creas un módulo estandard, colocas este procedure y lo llamas desde el formulario que quieras aplicarlo mediante
Call SetDeviceIndependentWindow(Me)
Me.Show
El porcedure que hay que incluir en el módulo sería el siguiente (para este caso es para algunos controles como commandbutton, filelistbox,dirlistbox,combobox). Para otros comandos sería cosa de agregarle las mismas líneas de manera análoga:
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
Acá va un ejemplo de código de como podrías hacerlo. Creas un módulo estandard, colocas este procedure y lo llamas desde el formulario que quieras aplicarlo mediante
Call SetDeviceIndependentWindow(Me)
Me.Show
El porcedure que hay que incluir en el módulo sería el siguiente (para este caso es para algunos controles como commandbutton, filelistbox,dirlistbox,combobox). Para otros comandos sería cosa de agregarle las mismas líneas de manera análoga:
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
