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.
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.
Comment