View Single Post
  #3 (permalink)  
Old 02-14-2009, 03:42 PM
digitaldon37 digitaldon37 is offline
Basic4ppc Veteran
 
Join Date: Jan 2008
Posts: 215
Default

Quote:
Originally Posted by klaus View Post
Till now I have only written programs for QVGA screens and added Fillipo's routine 'ChangeToVGA' to support VGA screens.

Answers to your questions:

1) The programing becomes a little bit more complicated because of the handling of the different screen sizes. From QVGA to VGA it's easy because the width-height ratio is the same and there is just the scale factor of 2. In that case all the Top, Left, Width and Height values are multiplied by the scale factor.

2) The change for screens with different width-height ratios it becomes more complicated.
For example:
-From 240/320 to 240/400 the lower part of the screen will be blank, or you should multiply all Height parameters of the controls by 400/320=1.25 to change their spacing.
-From 240/320 to 320/320 you could stretch the screen horizontally by multiplying all the Left and Width paramters of the controls by 320/240=1.33 otherwise the right third of the screen will be blank.

3) The same reasoning applyes here.
- From 320/320 to 240/320 you will miss the right third of the screen or you must shrink the screen width by 240/320=0.67 (same principle as stretching) with the risk that some controls are too small or you must foresee the control sizes to fit into a 240 pixel width.
- From 240/400 to 240/320 you will miss the lower 80 pixels or shrink the screen vertically.

Or you have a different source code for each screen size, which is also not that convenient.

Best regards.
I have a modified version of Filippos changetovga routine that works for all screen sizes (at least in the emulators).
Code:
Sub SetDisplay
' Msgbox("width: " & form1.Width & CRLF & "height: " & form1.Height)

Select form1.Width
        
Case 240
            ScaleW=
1
        
Case 320
            ScaleW=
1.5
        
Case 480
            ScaleW=
2
    
End Select
    
    
Select  form1.Height+52
        
Case 320
            ScaleH=
1
        
Case 400
            ScaleH=
1.5
        
Case 640
            ScaleH=
2
        
Case 800
            ScaleH=
2.5
    
End Select



    Controls() = GetControls(
"")
    
For i = 0 To ArrayLen(Controls())-1
        
Select ControlType(Controls(i))
            
Case "ListBox","NumUpDown","Button","TextBox","Label","ComboBox","Panel","RadioBtn","Table","ImageButton","CheckBox","Image"
               Control(Controls(i)).Left = scaleW * Control(Controls(i)).Left
               Control(Controls(i)).Top = scaleH * Control(Controls(i)).Top
                Control(Controls(i)).Height = scaleH * Control(Controls(i)).Height
                Control(Controls(i)).Width = scaleW * Control(Controls(i)).Width
'*** Uncomment these lines if your application includes Tables.
'
                If ControlType(Controls(i)) = "Table" Then
'
                    tbl = Controls(i)
'
                    For i2 = 0 To Control(tbl,Table).ColCount-1
'
                        col = Control(tbl,Table).ColName(i2)
'
                        Control(tbl,Table).ColWidth(col) = Control(tbl,Table).ColWidth(col) * 2
'
                    Next
'
                End If
        End Select
    
Next
End Sub
Reply With Quote