Hi everyone, i made an application with vb6 in my pc,but when i transferred it to a laptop,the relative positions of controls has changed..it seems it has something to do with the resolution..got any solution?
Making an application the same size in all resolutions
Collapse
X
-
-
Comment
-
thanks for ur reply..Originally posted by debasisdasfindout the resolution of the monitor and resize the form and other controls accordingly.
after finding out the resolution of the monitor,what do i do?
how do i size my form accordingly?i mean what size should i hav for one resolution and what for some other resolution?
how do i proceed??
an example would help..Comment
-
This code from Jim Cone worked for me...
Declare Function GetSystemMetric s Lib "user32" (ByVal nIndex As Long) As Long
Sub ResizeForm_R1()
' Adjusts userform size to compensate for screen resolution changes.
' Calls function GetSR
' Jim Cone - San Francisco, USA - Dec 2006
Dim varSize As Variant
Dim RatioX As Single
Dim RatioY As Single
Dim ActualX As Long
Dim ActualY As Long
'Screen resolution in development environment.
'Adjust as necessary <<<
Const BaseX As Long = 800
Const BaseY As Long = 600
'Call function to get actual screen resolution
varSize = GetSR
ActualX = varSize(0)
ActualY = varSize(1)
'Determine ratio of actual screen resolution to
'the original or base resolution.
RatioX = ActualX / BaseX
RatioY = ActualY / BaseY
'Adjust userform magnification and size.
UserForm1.Zoom = (100 * ((RatioX + RatioY) / 2))
UserForm1.Width = UserForm1.Width * RatioX
UserForm1.Heigh t = UserForm1.Heigh t * RatioY
UserForm1.Show
Unload UserForm1
Set UserForm1 = Nothing
End Sub
'---------------------------------
Public Function GetSR() As Variant
' x and y
GetSR = Array(GetSystem Metrics(0), GetSystemMetric s(1))
End Function
Originally posted by vdraceilthanks for ur reply..
after finding out the resolution of the monitor,what do i do?
how do i size my form accordingly?i mean what size should i hav for one resolution and what for some other resolution?
how do i proceed??
an example would help..Comment
-
This is only to keep a constant size form,isnt it?Originally posted by ubentookThis code from Jim Cone worked for me...
Declare Function GetSystemMetric s Lib "user32" (ByVal nIndex As Long) As Long
Sub ResizeForm_R1()
' Adjusts userform size to compensate for screen resolution changes.
' Calls function GetSR
' Jim Cone - San Francisco, USA - Dec 2006
Dim varSize As Variant
Dim RatioX As Single
Dim RatioY As Single
Dim ActualX As Long
Dim ActualY As Long
'Screen resolution in development environment.
'Adjust as necessary <<<
Const BaseX As Long = 800
Const BaseY As Long = 600
'Call function to get actual screen resolution
varSize = GetSR
ActualX = varSize(0)
ActualY = varSize(1)
'Determine ratio of actual screen resolution to
'the original or base resolution.
RatioX = ActualX / BaseX
RatioY = ActualY / BaseY
'Adjust userform magnification and size.
UserForm1.Zoom = (100 * ((RatioX + RatioY) / 2))
UserForm1.Width = UserForm1.Width * RatioX
UserForm1.Heigh t = UserForm1.Heigh t * RatioY
UserForm1.Show
Unload UserForm1
Set UserForm1 = Nothing
End Sub
'---------------------------------
Public Function GetSR() As Variant
' x and y
GetSR = Array(GetSystem Metrics(0), GetSystemMetric s(1))
End Function
Will it work for other controls too?
(I've not tried it yet)
Considering the above code,in vb6, a form doesnt have a "zoom" property!!Code:UserForm1.Zoom = (100 * ((RatioX + RatioY) / 2))
Comment
Comment