WQVGA Screen Detection?

Discussion in 'Questions (Windows Mobile)' started by dlfallen, Oct 21, 2009.

  1. dlfallen

    dlfallen Active Member Licensed User

    Is there any way to detect whether a program is running on a device with WQVGA (400 x 240) resolution?

    I would like to be able to take advantage of the additional screen space when it is available. Although I apparently cannot change the form size at runtime, I noticed that if a control extends well below the default 320, that extra part of the control is visible and useful. For example, I specify a form of 320 x 240 and place a label at Top = 240 and Height = 105. I give the label a long text that results in several lines of word wrapping. If I run this program on the IDE, only two lines of text are visible but if I run the compiled app on my WQVGA device then several lines of text are visible.
  2. klaus

    klaus Expert Licensed User

    I do by calculating the screen ratio.
    [FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]Form1.Show[/SIZE][/FONT]
    FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] Form1.Width>Form1.Height [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE][/FONT]
    FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]  ScreenRatio=Form1.Width/Form1.Height[/SIZE][/FONT]
    FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]Else[/COLOR][/SIZE][/FONT]
    FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]  ScreenRatio=Form1.Height/Form1.Width[/SIZE][/FONT]
    FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][/FONT]
    FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000][FONT=Courier New][SIZE=2][COLOR=#008000][FONT=Courier New][SIZE=2][COLOR=#008000]' If ScreenRatio<1.35 Then 240/320 or 480/640 [/COLOR][/SIZE][/FONT]
    2][FONT=Courier New][COLOR=#008000]' If ScreenRatio>1.35 Then 240/400 or 480/800 [/COLOR][/FONT][/SIZE][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT]
    Best regards.
  3. dlfallen

    dlfallen Active Member Licensed User

    I'm not sure I follow. The Form1.width and Form1.height are set by the designer, no? If the designer set Form1.width = 240 and Form1.height = 320 is this not what your screenratio is based on? In other words, wouldn't your screenratio return 1.333 in this instance, regardless of the device resolution?

    I want to detect the native resolution of the device, not the form dimensions set by the designer. In Basic4PPC version 6.8 you can calculate whether the device is qvga or vga, but I don't see a way to calculate if the device is wqva -- or am I missing something here?
  4. klaus

    klaus Expert Licensed User

    The size of a form on the device is allways the size of the screen.
    You can change the size of a form only on the desktop.
    On a device with a screen size of 240*320 the form size is this one even if you set a screen size of 240*400 on the desktop.

    Best regards.
  5. dlfallen

    dlfallen Active Member Licensed User

    Klaus - you are correct, as usual. I don't know why this critical concept escaped me, but I have it now.

    For the curious, I tested the reported form height and width in the various WM emulator scenarios. Here are the results (see attached jpg).

    Interesting, thanks Klaus!

    Attached Files:

  6. agraham

    agraham Expert Licensed User

    That is interesting. The value of ScreenScaleX/Y for a 320 x 320 device implies a logical dpi of 128 which I postulated in another thread but could not confirm myself. Thank you!
  7. klaus

    klaus Expert Licensed User

    I noticed that even with FullScreen without the title bar and also without both titlebar and menubar the width and height of the form are not updated in B4PPC.
    If you want the real user size of the form you can use the Door library and read the Width and Height properties of the form.
    In this case, when you remove the titlebar and or the menubar the values are updated.
    But it gives you the real values in pixels, that means when optimized compiled with AutoScale:
    on a QVGA / WQVGA screen you get
    Form1.Width = 240
    Form1.Height = 268 QVGA
    Form1.Height = 348 WQVGA
    obj.GetProperty("Width") = 240
    obj.GetProperty("Height") = 268 / 294 / 320 QVGA
    obj.GetProperty("Height") = 348 / 376 / 400 WQVGA

    and on a VGA / WVGA screen you get
    Form1.Width = 240
    Form1.Height = 268 VGA
    Form1.Height = 348 WVGA
    obj.GetProperty("Width") = 480
    obj.GetProperty("Height") = 536 / 588 / 640 VGA
    obj.GetProperty("Height") = 696 / 748 / 800 WVGA

    The difference of the height value is due the heights, 26 / 52 pixels, of the titlebar and menubar.

    Attached a small test program.

    Best regards.

    Attached Files:

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice