Beyond Screen Resolution 
Author Message
 Beyond Screen Resolution

Try something like this:
What it does: It maximizes the form then rescales every control on that form
to fit the new window size using the .WindowHeight and .WindowWidth
properties.

Public Function resize_me(frm As Form)
On Error GoTo err_resize_me:
    Dim CurH As Integer, CurW As Integer, ChangeH As Single, ChangeW As
Single
    Dim PrevH As Integer, PrevW As Integer
    Dim ctl As Control, PrevFontSize As Single, CurFontSize As Single
    DoCmd.Echo False
    With frm
        .SetFocus
        DoCmd.Maximize
        If .CurrentView = 2 Then GoTo exit_resize_me:
        CurH = .WindowHeight
        CurW = .WindowWidth
        ChangeH = CurH / PrevH
            If ChangeH < 1 Then
                ChangeH = ChangeH / SizeDown
            ElseIf ChangeH > 1 Then
                ChangeH = ChangeH * SizeUp
            End If
        ChangeW = CurW / PrevW
        CurFontSize = PrevFontSize * ChangeW
        If ChangeW > 1 Then
            .Width = .Width * ChangeW
        End If
        If ChangeH > 1 Then
            With .Section(0)
                .Height = .Height * ChangeH
            End With
        End If
        If ChangeH <> 1 Or ChangeW <> 1 Then
            For Each ctl In .Controls
                With ctl
                    .Top = .Top * ChangeH
                    .Height = .Height * ChangeH
                    .Left = .Left * ChangeW
                    .Width = .Width * ChangeW
                    If .ControlType = acCustomControl Then
                        .Font.Size = CurFontSize
                    Else
                        .FontSize = CurFontSize
                    End If
                End With
            Next
        End If
        If ChangeW < 1 Then
            .Width = .Width * ChangeW
        End If
        If ChangeH < 1 Then
            With .Section(0)
                .Height = .Height * ChangeH
            End With
        End If
    End With
End Function


Quote:
>I saw the post about how to find out the current screen resolution.
>But, the only problem I have is if the user has changed the font size to
>large from normal in the screen settings in Windows.  In that case, a
>800x600 screen looks more like a 640x480 screen.  Does anyone know of a
>way to find out what that value is set at.  What I am planning to do is
>the maximize the forms I have if the resolution is below 800x600.  They
>just look better.  How does anyone else handle this problem.  You create
>a form that looks good in say "800x600" resolution, but when you open up
>the form in 640x480, just doesn't look as good, it would be better if it
>was maximized.  If you always maximize it, it would not look as good in
>higher resolutions.



Sat, 03 Nov 2001 03:00:00 GMT  
 Beyond Screen Resolution
You could also dynamically resize your controls based on the screen SIZE.
Use the GetDeviceCaps api (Private Declare Function api_GetDeviceCaps Lib
"gdi32" Alias "GetDeviceCaps" (ByVal hdc As Long, ByVal nIndex As Long) As
Long) to retrive the screen size in millimeters.

Multiply that number by 0.03937 to get inches, and then multiply it again by
1440 for twips.

You can then manipulate controls to always fit on a users screen, regardless
of the resolution.
--
Paul Brower
BEST Consulting

"I Love DSL!"

Quote:
> I saw the post about how to find out the current screen resolution.
> But, the only problem I have is if the user has changed the font size to
> large from normal in the screen settings in Windows.  In that case, a
> 800x600 screen looks more like a 640x480 screen.  Does anyone know of a
> way to find out what that value is set at.  What I am planning to do is
> the maximize the forms I have if the resolution is below 800x600.  They
> just look better.  How does anyone else handle this problem.  You create
> a form that looks good in say "800x600" resolution, but when you open up
> the form in 640x480, just doesn't look as good, it would be better if it
> was maximized.  If you always maximize it, it would not look as good in
> higher resolutions.



Sat, 03 Nov 2001 03:00:00 GMT  
 Beyond Screen Resolution
This all seems great, but what are sizedown and size up?
Quote:

> Try something like this:
> What it does: It maximizes the form then rescales every control on that form
> to fit the new window size using the .WindowHeight and .WindowWidth
> properties.

> Public Function resize_me(frm As Form)
> On Error GoTo err_resize_me:
>     Dim CurH As Integer, CurW As Integer, ChangeH As Single, ChangeW As
> Single
>     Dim PrevH As Integer, PrevW As Integer
>     Dim ctl As Control, PrevFontSize As Single, CurFontSize As Single
>     DoCmd.Echo False
>     With frm
>         .SetFocus
>         DoCmd.Maximize
>         If .CurrentView = 2 Then GoTo exit_resize_me:
>         CurH = .WindowHeight
>         CurW = .WindowWidth
>         ChangeH = CurH / PrevH
>             If ChangeH < 1 Then
>                 ChangeH = ChangeH / SizeDown
>             ElseIf ChangeH > 1 Then
>                 ChangeH = ChangeH * SizeUp
>             End If
>         ChangeW = CurW / PrevW
>         CurFontSize = PrevFontSize * ChangeW
>         If ChangeW > 1 Then
>             .Width = .Width * ChangeW
>         End If
>         If ChangeH > 1 Then
>             With .Section(0)
>                 .Height = .Height * ChangeH
>             End With
>         End If
>         If ChangeH <> 1 Or ChangeW <> 1 Then
>             For Each ctl In .Controls
>                 With ctl
>                     .Top = .Top * ChangeH
>                     .Height = .Height * ChangeH
>                     .Left = .Left * ChangeW
>                     .Width = .Width * ChangeW
>                     If .ControlType = acCustomControl Then
>                         .Font.Size = CurFontSize
>                     Else
>                         .FontSize = CurFontSize
>                     End If
>                 End With
>             Next
>         End If
>         If ChangeW < 1 Then
>             .Width = .Width * ChangeW
>         End If
>         If ChangeH < 1 Then
>             With .Section(0)
>                 .Height = .Height * ChangeH
>             End With
>         End If
>     End With
> End Function


> >I saw the post about how to find out the current screen resolution.
> >But, the only problem I have is if the user has changed the font size to
> >large from normal in the screen settings in Windows.  In that case, a
> >800x600 screen looks more like a 640x480 screen.  Does anyone know of a
> >way to find out what that value is set at.  What I am planning to do is
> >the maximize the forms I have if the resolution is below 800x600.  They
> >just look better.  How does anyone else handle this problem.  You create
> >a form that looks good in say "800x600" resolution, but when you open up
> >the form in 640x480, just doesn't look as good, it would be better if it
> >was maximized.  If you always maximize it, it would not look as good in
> >higher resolutions.



Mon, 05 Nov 2001 03:00:00 GMT  
 Beyond Screen Resolution
Sorry for not having added a comment about this. Those are constants that I
used to finetune the sizes. You may find this necessary, but you can skip
them in the beginning.


Quote:
>This all seems great, but what are sizedown and size up?


>> Try something like this:
>> What it does: It maximizes the form then rescales every control on that
form
>> to fit the new window size using the .WindowHeight and .WindowWidth
>> properties.

>> Public Function resize_me(frm As Form)
>> On Error GoTo err_resize_me:
>>     Dim CurH As Integer, CurW As Integer, ChangeH As Single, ChangeW As
>> Single
>>     Dim PrevH As Integer, PrevW As Integer
>>     Dim ctl As Control, PrevFontSize As Single, CurFontSize As Single
>>     DoCmd.Echo False
>>     With frm
>>         .SetFocus
>>         DoCmd.Maximize
>>         If .CurrentView = 2 Then GoTo exit_resize_me:
>>         CurH = .WindowHeight
>>         CurW = .WindowWidth
>>         ChangeH = CurH / PrevH
>>             If ChangeH < 1 Then
>>                 ChangeH = ChangeH / SizeDown
>>             ElseIf ChangeH > 1 Then
>>                 ChangeH = ChangeH * SizeUp
>>             End If
>>         ChangeW = CurW / PrevW
>>         CurFontSize = PrevFontSize * ChangeW
>>         If ChangeW > 1 Then
>>             .Width = .Width * ChangeW
>>         End If
>>         If ChangeH > 1 Then
>>             With .Section(0)
>>                 .Height = .Height * ChangeH
>>             End With
>>         End If
>>         If ChangeH <> 1 Or ChangeW <> 1 Then
>>             For Each ctl In .Controls
>>                 With ctl
>>                     .Top = .Top * ChangeH
>>                     .Height = .Height * ChangeH
>>                     .Left = .Left * ChangeW
>>                     .Width = .Width * ChangeW
>>                     If .ControlType = acCustomControl Then
>>                         .Font.Size = CurFontSize
>>                     Else
>>                         .FontSize = CurFontSize
>>                     End If
>>                 End With
>>             Next
>>         End If
>>         If ChangeW < 1 Then
>>             .Width = .Width * ChangeW
>>         End If
>>         If ChangeH < 1 Then
>>             With .Section(0)
>>                 .Height = .Height * ChangeH
>>             End With
>>         End If
>>     End With
>> End Function


>> >I saw the post about how to find out the current screen resolution.
>> >But, the only problem I have is if the user has changed the font size to
>> >large from normal in the screen settings in Windows.  In that case, a
>> >800x600 screen looks more like a 640x480 screen.  Does anyone know of a
>> >way to find out what that value is set at.  What I am planning to do is
>> >the maximize the forms I have if the resolution is below 800x600.  They
>> >just look better.  How does anyone else handle this problem.  You create
>> >a form that looks good in say "800x600" resolution, but when you open up
>> >the form in 640x480, just doesn't look as good, it would be better if it
>> >was maximized.  If you always maximize it, it would not look as good in
>> >higher resolutions.



Mon, 05 Nov 2001 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Changing screen resolution in full-screen programs?

2. Changing screen resolution in full-screen programs?

3. Screen coordinates change after changing screen resolution???

4. How to Change Screen Resolution in VBA

5. Screen resolution problem

6. Screen Resolution

7. Screen Resolution

8. Resize - screen resolution code

9. Screen resolution

10. Retrieving display information (screen resolution)

11. Screen Resolution

12. Checking Screen Resolution

 

 
Powered by phpBB® Forum Software