Greetings,
My application looks untidy when run on screens smaller or larger than the one i used to design it. Is there a way to take care of this?
Programming for different screen sizes
Moderator: Rathinagiri
- karweru
- Posts: 220
- Joined: Fri Aug 01, 2008 1:51 pm
- DBs Used: DBF,mysql,mariadb,postgresql,sqlite,odbc
- Contact:
Programming for different screen sizes
Kind regards,
Gilbert.
Gilbert.
- esgici
- Posts: 4543
- Joined: Wed Jul 30, 2008 9:17 pm
- DBs Used: DBF
- Location: iskenderun / Turkiye
- Contact:
Re: Programming for different screen sizes
Did you tried ON SIZE event of window definition ?
Happy HMG'ing
Viva INTERNATIONAL HMG
- serge_girard
- Posts: 3165
- Joined: Sun Nov 25, 2012 2:44 pm
- DBs Used: 1 MySQL - MariaDB
2 DBF - Location: Belgium
- Contact:
Re: Programming for different screen sizes
Gilbert,
You will need to RESIZE all controls!
Not perfect but give it a try!
Serge
You will need to RESIZE all controls!
Code: Select all
DEFINE WINDOW ...
...
ON INIT _AutoAdjust( ThisWindow.Name );
ON MAXIMIZE _AutoAdjust( ThisWindow.Name );
ON SIZE _AutoAdjust( ThisWindow.Name )
END WINDOW ...
ACTIVATE WINDOW ...
*-----------------------------------------------------------------------------*
PROCEDURE _AutoAdjust( hWnd, cForm )
*-----------------------------------------------------------------------------*
LOCAL i, k, ParentForm, ControlCount, ControlName, ControlType, nWidth, nHeight, lvisible:=.T., nDivw, nDivh
LOCAL lOK
LOCAL cFile
IF GetDesktopWidth() < GetWindowWidth ( hWnd )
nWidth := GetDesktopWidth()
ELSE
nWidth := GetWindowWidth ( hWnd )
ENDIF
//? ' nWidth ' , nWidth
IF GetDesktopHeight() < GetWindowHeight ( hWnd )
nHeight := GetDesktopHeight()
ELSE
nHeight := GetWindowHeight ( hWnd )
ENDIF
//? ' nHeight ' , nHeight
IF IsWindowVisible ( hWnd ) .AND. ! IsAppXPThemed()
HideWindow ( hWnd )
ELSE
lvisible := .F.
ENDIF
i := aScan ( _HMG_SYSDATA [67] , hWnd )
//? 'i ' , i
ParentForm := _HMG_SYSDATA [66] [i]
//? 'ParentForm ' , ParentForm
//? 'cForm ' , cForm
//? '_HMG_SYSDATA [91] [i] ' , _HMG_SYSDATA [91] [i]
//? '_HMG_SYSDATA [92] [i] ' , _HMG_SYSDATA [92] [i]
IF _HMG_SYSDATA [92] [i] > 0 .AND. _HMG_SYSDATA [91] [i] > 0
nDivw := nWidth / _HMG_SYSDATA [92] [i]
nDivh := nHeight / _HMG_SYSDATA [91] [i]
ELSE
nDivw := 1
nDivh := 1
ENDIF
//? 'nDivw ' , nDivw
//? 'nDivh ' , nDivh
ControlCount := LEN ( _HMG_SYSDATA [3] )
//? 'ControlCount ', ControlCount
lOK := .F.
FOR k := 1 TO ControlCount // VAN ALLE FORM'S
IF cForm == ParentForm
ControlName := _HMG_SYSDATA [2] [k]
IF _IsControlDefined ( ControlName, ParentForm ) .and. cForm == ParentForm
//? ' ControlName ' , ParentForm + '.' + ControlName
ControlType := _HMG_SYSDATA [1] [k]
//? '====>ControlType ' , ParentForm + '.' + ControlName + '.' + ControlType
IF !EMPTY( ControlName ) .AND. !( ControlType $ "MENU,HOTKEY,TOOLBAR,MESSAGEBAR,ITEMMESSAGE,TIMER" ) //.And.;
//Empty( GetControlContainerHandle ( ControlName, ParentForm ) )
IF ControlType == 'RADIOGROUP'
_HMG_aControlSpacing := _HMG_SYSDATA [ 22 ]
_HMG_aControlMiscData1 := _HMG_SYSDATA [ 8 ]
_HMG_aControlSpacing [k] := _HMG_aControlSpacing [k] * IIF(_HMG_aControlMiscData1 [k], nDivw, nDivh)
ENDIF
//IF ControlType # 'CHECK'
_SetControlSizePos ( ControlName, ParentForm,;
_GetControlRow ( ControlName, ParentForm ) * nDivh, _GetControlCol ( ControlName, ParentForm ) * nDivw,;
_GetControlWidth ( ControlName, ParentForm ) * nDivw, _GetControlHeight ( ControlName, ParentForm ) * nDivh )
//ENDIF
IF ControlType <> 'SLIDER'
IF EMPTY(_HMG_SYSDATA [28] [k] )
_SetFontSize ( ControlName, ParentForm , 8 * nDivh )
ELSE
_SetFontSize ( ControlName, ParentForm , _HMG_SYSDATA [28] [K] * nDivh )
ENDIF
ENDIF
ENDIF
IF ControlType == 'GRID'
FOR iJ = 1 TO GetProperty (ParentForm, ControlName, "ColumnCount")
ZZ := GetProperty (ParentForm, ControlName, "ColumnWIDTH", iJ ) * nDivw
SetProperty (ParentForm, ControlName, "ColumnWIDTH", iJ, ZZ)
NEXT iJ
ENDIF
ENDIF
ENDIF
NEXT k
_HMG_SYSDATA [92] [i] := nWidth
_HMG_SYSDATA [91] [i] := nHeight
//? '_HMG_SYSDATA [91] [i] ' , _HMG_SYSDATA [91] [i]
//? '_HMG_SYSDATA [92] [i] ' , _HMG_SYSDATA [92] [i]
IF lvisible
ShowWindow ( hWnd )
ENDIF
RETURN
Serge
There's nothing you can do that can't be done...
Re: Programming for different screen sizes
I've ueef auto resize function, but this solution slows down app.
It's better to define controls with size ans coordinates depending from screen resolution
It's better to define controls with size ans coordinates depending from screen resolution
- Rathinagiri
- Posts: 5471
- Joined: Tue Jul 29, 2008 6:30 pm
- DBs Used: MariaDB, SQLite, SQLCipher and MySQL
- Location: Sivakasi, India
- Contact:
Re: Programming for different screen sizes
I have a screen resolution of 1920 x 1080 while designing and whenever my applications are used by others many times I had seen that either most of the controls are out of place or total application being unusable.
Only after a while I realized that it is not necessary to do go for BIG windows. Instead I plan to have the window with lesser resolution. My favourite being 800 x 600. Maximum at 1000 x 800. Now my windows are compact. If the people having bigger screens and higher resolutions feel the window is so small, I tell them this way you need not move your hands much. They do agree for that.
If they need really a BIG form to enter so much of data, I suggest them to buy a bigger screen with higher resolution. Having a smaller screen and expecting a higher resolution is impossible and monitors are not that much costly.
This is just my experience.
Only after a while I realized that it is not necessary to do go for BIG windows. Instead I plan to have the window with lesser resolution. My favourite being 800 x 600. Maximum at 1000 x 800. Now my windows are compact. If the people having bigger screens and higher resolutions feel the window is so small, I tell them this way you need not move your hands much. They do agree for that.
If they need really a BIG form to enter so much of data, I suggest them to buy a bigger screen with higher resolution. Having a smaller screen and expecting a higher resolution is impossible and monitors are not that much costly.
This is just my experience.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
South or North HMG is worth.
...the possibilities are endless.
- serge_girard
- Posts: 3165
- Joined: Sun Nov 25, 2012 2:44 pm
- DBs Used: 1 MySQL - MariaDB
2 DBF - Location: Belgium
- Contact:
Re: Programming for different screen sizes
Good idea Rathi!
Serge
Serge
There's nothing you can do that can't be done...
- karweru
- Posts: 220
- Joined: Fri Aug 01, 2008 1:51 pm
- DBs Used: DBF,mysql,mariadb,postgresql,sqlite,odbc
- Contact:
Re: Programming for different screen sizes
Thank you all for the insights. I'll explore Serge's solution further...looks promising. Much appreciated
Kind regards,
Gilbert.
Gilbert.