Announcement

Collapse

New Sub-Forum

In an effort to help make sure there are appropriate categories for topics of discussion that are happening, there is now a sub-forum for databases and database programming under Special Interest groups. Please direct questions, etc., about this topic to that sub-forum moving forward. Thank you.
See more
See less

Crude but Effective Scaling Method

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Crude but Effective Scaling Method

    I recently needed to add scaling to a demonstration program I wrote for a new product my company is introducing. The program was originally written to run on a 1280 x 1024 screen. Several sales / marketing people asked if the program could resized to run on their laptops which have 1024 x 768 screens.

    The method I employed is not elegant (read: crude), but it does work.

    Psuedo Code:
    %X = 1280
    %Y = 1024

    LOCAL ClientX AS DWORD
    LOCAL ClientY AS DWORD

    STATIC XScale AS SINGLE
    STATIC YScale AS SINGLE

    DESKTOP GET CLIENT TO ClientX, ClientY
    DIALOG SET SIZE hDlg, ClientX, ClientY

    XScale = ClientX / %X
    YScale = ClientY / %Y

    CONTROL ADD LABEL, hDlg, %Id, "", Xposition * XScale, Yposition * YScale, Xsize * XScale, Ysize * YScale, %SS_CENTERIMAGE + %SS_CENTER OR %SS_NOTIFY, %WS_EX_CLIENTEDGE

    This method has been tested on screen sizes from 1024 x 768 to 1920 x 1200. Is there a more elegant way of scaling a GUI? Scaling in this case means that GUI retains the correct proportions and all of its elements are visible. GUI size rang would be 1024 x 768 through 1920 x 1200.

  • #2
    Actually the pseudo code is better than the one I stuck with (I just picked a small number of resolutions that were the most likely picked ones based of instinct and experience).

    After that, although not perfect but real close would be AutoResize.inc (I can not remember at the moment who gets credit for that one...but EXCELLENT job):top:
    That you can use to resize and keep relative placement of your controls if you resize the dialog.
    Engineer's Motto: If it aint broke take it apart and fix it

    "If at 1st you don't succeed... call it version 1.0"

    "Half of Programming is coding"....."The other 90% is DEBUGGING"

    "Document my code????" .... "WHYYY??? do you think they call it CODE? "

    Comment


    • #3
      What you have looks fine to me for its basic purpose.

      A search of the PB forums for "Autosize.inc" turned up lots more that I found interesting if not pertinent, including a general solution for coordinate conversions that I posted in 1999:
      http://www.powerbasic.com/support/pb...ad.php?t=10830

      Comment

      Working...
      X