Compile and run the below code and watch what happens when the screen is resized horizontally and vertically.
Press the F9 key several times to see how the screen can be controlled by the user or by the programmer depending on monitor resolution.
This is similar to the <div> tag and style sheets used in HTML for managing real estate based on the device.
After some feedback I tend to take this further and simplify the process for the programmer.
The underlying code would not change, only the STYLE syntax.
Code: Select all
#INCLUDE "dcdialog.ch"
#INCLUDE "appevent.CH"
FUNCTION Main()
LOCAL GetList[0], GetOptions, oGroup1, oGroup2, oGroup3, i, oDlg
@ 0,0 DCSAY 'Press F9 to change screen size' SAYSIZE 0 ;
RESIZE DCGUI_RESIZE_REPOSONLY_Y
DCHOTKEY xbeK_F9 ACTION {||ScreenSize(oDlg)}
@ 20,0 DCGROUP oGroup1 SIZE 210,210 CAPTION 'Group 1' ;
RESIZE { {|x,y,o|ResizeGroup1(x,y,o,oDlg)}, nil }
FOR i := 1 TO 8
@ i*20,20 DCSAY 'This is ' + Alltrim(Str(i)) SAYSIZE 0 ;
PARENT oGroup1
NEXT
@ 240,0 DCGROUP oGroup2 SIZE 210,210 CAPTION 'Group 2' ;
RESIZE { {|x,y,o|ResizeGroup2(x,y,o,oDlg,oGroup1)}, nil }
FOR i := 1 TO 8
@ i*20,20 DCSAY 'This is ' + Alltrim(Str(i)) SAYSIZE 0 ;
PARENT oGroup2
NEXT
@ 460,0 DCGROUP oGroup3 SIZE 210,210 CAPTION 'Group 3' ;
RESIZE { {|x,y,o|ResizeGroup3(x,y,o,oDlg,oGroup2)}, nil }
FOR i := 1 TO 8
@ i*20,20 DCSAY 'This is ' + Alltrim(Str(i)) SAYSIZE 0 ;
PARENT oGroup3
NEXT
DCGETOPTIONS RESIZE PIXEL
DCREAD GUI FIT TITLE 'Group Relocate Test' OPTIONS GetOptions ;
PARENT @oDlg
RETURN nil
* ----------
STATIC FUNCTION ResizeGroup1( x,y,o, oDlg )
LOCAL aRepos
aRepos := { o:currentPos()[1],o:CurrentPos()[2]+y }
RETURN aRepos
* ----------
STATIC FUNCTION ResizeGroup2( x,y,o, oDlg, oGroup1 )
LOCAL aRepos
IF oDlg:currentSize()[1] < 450
aRepos := { oGroup1:currentPos()[1], ;
oGroup1:CurrentPos()[2]-o:currentSize()[2]-10 }
ELSE
aRepos := { oGroup1:currentPos()[1]+oGroup1:currentSize()[1]+10, ;
oGroup1:CurrentPos()[2]}
ENDIF
RETURN aRepos
* ----------
STATIC FUNCTION ResizeGroup3( x,y,o, oDlg, oGroup2 )
LOCAL aRepos
IF oDlg:currentSize()[1] < 690
aRepos := { oGroup2:currentPos()[1], ;
oGroup2:CurrentPos()[2]-o:currentSize()[2]-10 }
ELSE
aRepos := { oGroup2:currentPos()[1]+oGroup2:currentSize()[1]+10, ;
oGroup2:CurrentPos()[2]}
ENDIF
RETURN aRepos
* ----------
STATIC FUNCTION ScreenSize( oDlg )
IF oDlg:currentSize()[1] >= 690
oDlg:setSize({250,730})
ELSEIF oDlg:currentSize()[1] >= 470
oDlg:setSize({690,290})
ELSEIF oDlg:currentSize()[1] < 300
oDlg:setSize({470,510})
ENDIF
RETuRN nil
* ----------
PROC appsys ; RETURN