Working with VGA screens

Discussion in 'Tutorials' started by Erel, Feb 7, 2008.

  1. Erel

    Erel Administrator Staff Member Licensed User

    Edit: Basic4ppc version 6.30 includes a new compilation target: Forced QVGA. In this method VGA screens will behave as regular QVGA screens, making it simpler to target both VGA and QVGA devices.

    Windows Mobile devices come with two types of screens.
    The regular QVGA screen: 240 * 320 (regular), 240 * 240 (square screen) or 320 * 240 (landscape).
    High resolution screens - VGA: 480 * 640 (regular), 480 * 480 (square screen) or 640 * 480 (landscape).

    VGA devices use a special mechanism to properly show applications which were not designed for VGA screens. It is called pixel doubling.
    Each pixel is doubled and the result is a pseudo lower resolution screen (QVGA).

    Non-optimized compiled applications use pixel doubling. Therefore your application will show exactly the same on VGA and QVGA screens.

    Optimized compiled applications do not use this method (.Net CF 2.0 restriction).
    This allows you to take advantage of the higher resolution screen.
    However if you don't explicitly handle VGA screens, your application will not show properly on such devices.

    The following code automatically changes the layout of all controls to match the VGA screen:
    Code:
    Sub Globals
        
    Dim Controls(0)
    End Sub

    Sub App_Start
        
    If form1.Height > 400 Then ChangeToVGA
        Form1.Show
    End Sub

    Sub ChangeToVGA
        
    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 = 2 * Control(Controls(i)).Left
                    
    Control(Controls(i)).Top = 2 * Control(Controls(i)).Top
                    
    Control(Controls(i)).Height = 2 * Control(Controls(i)).Height
                    
    Control(Controls(i)).Width = 2 * 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
    'Controls' is an array that later holds all controls.
    Somewhere in the beginning of the program you should check one of the forms height (doesn't matter which form), and call ChangeToVGA if necessary.
    ChangeToVGA should only be called once and it will handle all the controls on all forms.

    * Calendars controls do not show properly on VGA screens (with the optimized compiler). It will be fixed in the future.
    * The image in ImageButtons and Images controls not in cStretchImage mode will be smaller on VGA screens. You should use two sets of images in that case.
     
  2. peacemaker

    peacemaker Well-Known Member Licensed User

    Seems to me each "Panel" contaning other controls should be called, too.

    Edit:
    Oh, Control(Controls(i)).
     
  3. Erel

    Erel Administrator Staff Member Licensed User

    GetControls("") returns all the controls on all forms. Unlike GetConfrols("Form1") which will return only Form1 direct sons.
     
  4. peacemaker

    peacemaker Well-Known Member Licensed User

    Yes, thanks, all works fine.
     
  5. berndgoedecke

    berndgoedecke Active Member Licensed User

    What's about the Treeview icons?

    Hello Erel,
    with controls that are dirrectly placed in the Form your workaround works well, but the first time I had problems with it where the controls on a panel.
    I scaled that controls separatly and it computes well. But now I have a VGA-problem with the Treeview-icons. How should I scale them?
    On the way: working with VGA in B4P is very hard, because the appereance is three times different: The desktop is another as the device and both are different as the compiled version, particulary if you should work with Fullscreen2(False,True), which will not work if you run the source in the device editor.
    Isn't it possible to have a real VGA-compatible device-editor :confused:

    Best regards

    berndgoedecke
     
  6. Erel

    Erel Administrator Staff Member Licensed User

    You can add this code to handle the TreeView control:
    Code:
    Case "TreeView.TreeView":
                    
    Control(Controls(i),TreeView).Left = 2 * Control(Controls(i),TreeView).Left
                    
    Control(Controls(i),TreeView).Top = 2 * Control(Controls(i),TreeView).Top
                    
    Control(Controls(i),TreeView).Height = 2 * Control(Controls(i),TreeView).Height
                    
    Control(Controls(i),TreeView).Width = 2 * Control(Controls(i),TreeView).Width
                    
    Control(Controls(i),TreeView).ImageSize(50,50)
    You should initialize the treeviews (with New1) before calling the ChangeToVGA sub.
    Load images and assign them only after calling this sub.

    A VGA device IDE will be available in the future.
     
  7. berndgoedecke

    berndgoedecke Active Member Licensed User

    Thanks for TreeView-scaling

    Hello Erel,
    Much hanks for TreeView-scaling and the hint of an in future avaliable VGA-IDE.
    I do it await in the hope to have an easier job.

    Best Regards

    berndgoedecke
     
  8. yildi

    yildi Member Licensed User

    Hi,

    I am trying to adapt my TRPPC applet to make it automatically compatible with QVGA/VGA and Portrait/Landscape screens.
    I have come upon a strange problem (maybe I am stupid). I am trying to set the height of a table in a panel in a way to occupy the totality of the residual height after having accounted the space for other controls and the margins I want around them. But this automatically computed height gets bigger that the real residual space if the table needs scroll bars. So I understand that the size of these bars are not included in the .Height property of a Table. Am I wright?
    In order to solve the problem, I subtract some supplementary height when I set the height of the table (52 pixels in VGA). I have a menu in my application.

    Is there a better way to automatically set the height of the table?

    Regards,

    Murat
     
    Last edited: Feb 23, 2008
  9. Erel

    Erel Administrator Staff Member Licensed User

    I'm not sure that I correctly understood your problem.
    I suggest that you start a new thread and post a small code that demonstrates it if possible.
     
  10. yildi

    yildi Member Licensed User

    OK. I will do it when I have sometime to simplify my code.
     
  11. yildi

    yildi Member Licensed User

    In the waiting, my problem comes from the fact that the Width property of a table gives the external width of the control but not the internal net width in which one can place the columns. This is perfectly normal of course. But I have a problem when I try to programmatically fix the the width of the columns of my table, like

    Code:
    colWidth = Round((Table1.Width)/Table1.ColCount)
    For i = 0 To Table1.ColCount-1
       Table1.ColWidth (Table1.ColName(i)) = colWidth
    Next
    Indeed, when a vertical scroll bar appears, it eats the internal space of the Table and given that the columns' total width is equal to to table width, I also get a horizontal scroll bar. I ignore the exact thickness of these bars but I change the preceding code by

    colWidth = Round((Table1.Width-rightMargin)/Table1.ColCount)

    and adjust rightMargin by trial and error. But this is not a very elegant solution, since if I do not have a scroll bar, this leaves a small empty border on the left of the table, where the scroll bar is supposed to appear if necessary.

    Am I stupid or is this a real aesthetic problem?

    I hope that this is better understandable.:)

    Regards,

    Murat
     
  12. Erel

    Erel Administrator Staff Member Licensed User

    This is not a VGA problem. Same problem will appear on a regular screen.
    I think that the best solution is to set the last column width a little wider than the rest of the columns.
    When the scroll bar will appear it will truncate the last column.
     
  13. yildi

    yildi Member Licensed User

    Thank you Erel,
    Yes, It is not a VGA problem but my efforts to make my program VGA compatible by adjusting different margins (in complement of the sizes of the controls) made this problem more bothering. Your tip is very simple and smart! I will definitely use it.

    Best regards,

    Murat
     
  14. abastien

    abastien Member Licensed User

    Using mutiple forms

    :sign0104:
    Instead of this code to double the size of everything. I'd like to know if it is possible to have two forms with duplicate control names with different resolutions?
     
  15. Erel

    Erel Administrator Staff Member Licensed User

    It is not possible to have controls with duplicate names.
     
  16. berndgoedecke

    berndgoedecke Active Member Licensed User

    AutoScale-Features in CF 2.0

    Hello Erel,
    while I zaped through the Help-File of the CF 2.0 I found some AutoScale-Features in CF 2.0 like:
    ContainerControl.AutoScaleDimensions-property
    ContainerControl.AutoScaleFactor-property
    ContainerControl.AutoScaleMode-property
    Isn't it possible to solve the VGA-problem with the new CF 2.0 proprties ??

    Best regards

    berndgoedecke
     
  17. Erel

    Erel Administrator Staff Member Licensed User

    There are some differences in the way Basic4ppc handles the forms, although these properties may help in a future version.
     
  18. enonod

    enonod Well-Known Member Licensed User

    A bit late but I have only just arrived at this.
    Would it be true to say that your snippet produces pixel doubling, and if not used, the VGA screen can have control sizes/positions set to my choice and the result will be true use of a VGA screen with optimized compiling? I get more on screen but would not be QVGA compatible.
     
  19. Erel

    Erel Administrator Staff Member Licensed User

    This code snippet is not relevant since version 6.30.
    You should use Forced QVGA if you want to use double pixel mode. Otherwise you will get true VGA screen on VGA devices.
     
  20. Rioven

    Rioven Active Member Licensed User

    High resulution 3" screen : 480x800

    I am currently testing B4PPC V6.50 on my SE XPERIA X1i WM6.1, and .NET CF 3.5 installed.

    I just need quick procedures on how to configure the forms and the controls and the compiling for 480x800 display...I have problem displaying on the HEIGHT of the screen :sign0085:

    Thanks!
     
Loading...