Page 1 of 2
Resize dialog
Posted: Tue Oct 13, 2020 9:12 pm
by mauri.menabue
Hi all
I would like to create a dialog whose controls are resizable by resizing the dialog.
I made a test program but the resize doesn't work when i increase the size of the dialog,
when i reduce the size of the dialog it seems to work.
Can someone help me to understand where i am wrong.
Code: Select all
#include "FiveWin.ch"
*----------------------------------------------------------------------------
function TestDlgREs
*----------------------------------------------------------------------------
local oDlg
local oFol
local oFont1
local oFont2
local oFont3
local nResOrr
local nResVer
local nAltCor
local nTop
local nLeft
local nWidth
local nHeight
local nBottom
local nRight
local cCodice
local aItem
local cNumeri
local lFlag
local nPeso
local oBrw
nAltCor := GETSYSMETRICS( 4 )
nTop := 0
nLeft := 0
nWidth := 1000
nHeight := 800
nBottom := nTop + nHeight + nAltCor
nRight := nLeft + nWidth
cCodice := "22"
nPeso := 33.60
aItem := {"Uno", "Due", "Tre", "Quattro", "Cinque", "Sei"}
DEFINE FONT oFont1 NAME "VERDANA" SIZE 0, -14
DEFINE FONT oFont2 NAME "VERDANA" SIZE 0, -13
DEFINE FONT oFont3 NAME "TAHOMA" SIZE 0, -14
DEFINE DIALOG oDlg FROM nTop , nLeft TO nBottom, nRight ;
PIXEL TRUEPIXEL;
FONT oFont1 ;
TITLE "Resize Dialog"
@ 30, 20 SAY "Codice" OF oDlg SIZE 80,24 PIXEL FONT oFont1 BORDER
@ 30, 110 GET cCodice OF oDlg SIZE 80,24 PIXEL FONT oFont1 ACTION Msginfo("ok")
@ 60, 20 SAY "Numeri" OF oDlg SIZE 80,24 PIXEL FONT oFont1 BORDER
@ 60, 110 COMBOBOX cNumeri PROMPTS aItem OF oDlg SIZE 120,20*6 PIXEL FONT oFont2
@ 62, 250 CHECKBOX lFlag PROMPT "Attiva" OF oDlg SIZE 80,22 PIXEL FONT oFont1
@ 94 , 4 FOLDEREX oFol ;
OF oDlg ;
SIZE oDlg:nWidth - 8 , 250 ;
PIXEL ;
PROMPTS "Vendite",;
"Spedizione",;
"Note",;
"Allegati , Black List",;
"Appoggi bancari"
oFol:SetFont( oFont1 )
@ 10, 20 SAY "Peso" OF oFol:aDialogs[1] SIZE 30,12 PIXEL FONT oFont1 BORDER
@ 10, 55 GET nPeso OF oFol:aDialogs[1] SIZE 60,12 PIXEL FONT oFont1 RIGHT PICTURE "@E 999,999.99"
@ 380, 4 XBROWSE oBrw OF oDlg ;
SIZE oDlg:nWidth - 8, 250 ;
PIXEL ;
AUTOCOLS ;
ALIAS {{"aaa", "1111"}, {"BBB", "22222"}, {"CCC", "33333"}} ;
FONT oFont3 ;
NOBORDER
oBrw:nMarqueeStyle := MARQSTYLE_HIGHLWIN7
oBrw:CreateFromCode()
@ nBottom - 80, 20 BUTTON "Exit" OF oDlg SIZE 90,30 PIXEL FONT oFont1 ACTION oDlg:End()
oDlg:bInit := { | oDlg | InitDlg( oDlg ) }
oDlg:bResized := { | nSizeType, nWidth, nHeight | ResDlg( nSizeType, nWidth, nHeight, oDlg ) }
ACTIVATE DIALOG oDlg CENTERED
RELEASE oFont1
RELEASE oFont2
RELEASE oFont3
return nil
*----------------------------------------------------------------------------
Function InitDlg (oDlg )
*----------------------------------------------------------------------------
SET MESSAGE OF oDlg TO "Test message bar" NOINSET CENTER 2010 FONT oDlg:oFont
oDlg:CoorsUpdate()
oDlg:cargo := hash()
HSetCaseMatch( oDlg:cargo, .F. )
oDlg:cargo['nOldTop'] := oDlg:nTop
oDlg:cargo['nOldLeft'] := oDlg:nLeft
oDlg:cargo['nOldBottom'] := oDlg:nBottom
oDlg:cargo['nOldRight'] := oDlg:nRight
oDlg:cargo['nOldWidth'] := oDlg:nWidth
oDlg:cargo['nOldHeight'] := oDlg:nHeight
return NIL
*----------------------------------------------------------------------------
function ResDlg( nSizeType, nW, nH, oDlg )
*----------------------------------------------------------------------------
LOCAL nWidth
LOCAL nHeight
LOCAL nOldWidth
LOCAL nOldHeight
LOCAL nRx
LOCAL nRy
oDlg:CoorsUpdate()
nWidth := oDlg:nWidth
nHeight := oDlg:nHeight
nOldWidth := oDlg:cargo['nOldWidth']
nOldHeight := oDlg:cargo['nOldHeight']
nRx := nWidth / nOldWidth
nRy := nHeight / nOldHeight
oDlg:CoorsUpdate()
oDlg:cargo['nOldTop'] := oDlg:nTop
oDlg:cargo['nOldLeft'] := oDlg:nLeft
oDlg:cargo['nOldBottom'] := oDlg:nBottom
oDlg:cargo['nOldRight'] := oDlg:nRight
oDlg:cargo['nOldWidth'] := oDlg:nWidth
oDlg:cargo['nOldHeight'] := oDlg:nHeight
Adatta( oDlg , nRx, nRy)
return NIL
*----------------------------------------------------------------------------
function Adatta (oDlg, nRx, nRy )
*----------------------------------------------------------------------------
LOCAL nI1
LOCAL nI2
LOCAL nI3
LOCAL oOgg1
LOCAL oOgg2
LOCAL oOgg3
LOCAL nWidth
LOCAL nHeight
LOCAL nTop
LOCAL nLeft
LOCAL nNewWidth
LOCAL nNewHeight
LOCAL nNewTop
LOCAL nNewLeft
*------------------------------------------------------------------------
*- Ridimensionamento
*------------------------------------------------------------------------
For nI1 := 1 to len(oDlg:aControls)
oOgg1 := oDlg:aControls[nI1]
nWidth := oOgg1:nWidth
nHeight := oOgg1:nHeight
nTop := oOgg1:nTop
nLeft := oOgg1:nLeft
nNewWidth := nWidth * nRx
nNewHeight := nHeight * nRy
nNewTop := nTop * nRy
nNewLeft := nLeft * nRx
oOgg1:move( nNewTop, nNewLeft, nNewWidth, nNewHeight, .T. )
*------------------------------------------------------------
*- TFOLDER
*------------------------------------------------------------
if oOgg1:ClassName() $ "/TFOLDER/TPAGES/TFOLDEREX/"
If ValType( oOgg1:aDialogs ) = "A"
FOR nI2 := 1 TO LEN(oOgg1:aDialogs)
oOgg2 := oOgg1:aDialogs[nI2]
FOR nI3 := 1 TO LEN(oOgg2:aControls)
oOgg3 := oOgg2:aControls[nI3]
nWidth := oOgg3:nWidth
nHeight := oOgg3:nHeight
nTop := oOgg3:nTop
nLeft := oOgg3:nLeft
nNewWidth := ( nWidth * nRx )
nNewHeight := ( nHeight * nRy )
nNewTop := ( nTop * nRy )
nNewLeft := ( nLeft * nRx )
oOgg3:move( nNewTop, nNewLeft, nNewWidth, nNewHeight, .F. )
NEXT
NEXT
endif
*------------------------------------------------------------
*- TXBROWSE
*------------------------------------------------------------
elseif oOgg1:ClassName() $ "/TXBROWSE/"
If ValType( oOgg1:aCols ) = "A"
FOR nI2 := 1 TO LEN(oOgg1:aCols)
oOgg2 := oOgg1:aCols[nI2]
oOgg2:nWidth := (oOgg2:nWidth * nRx)
oOgg2:nCellHeight := oOgg2:nCellHeight * nRy
NEXT
endif
endif
NEXT
return NIL
Thank you
Re: Resize dialog
Posted: Wed Oct 14, 2020 8:11 am
by Silvio.Falconi
If you wish use resources I have a class made by Charles Kwon
or
on source you can make this :
Code: Select all
#include "FiveWin.ch"
*----------------------------------------------------------------------------
function TestDlgREs
*----------------------------------------------------------------------------
local oDlg
local oFol
local oFont1
local oFont2
local oFont3
local nResOrr
local nResVer
local nAltCor
local nTop
local nLeft
local nWidth
local nHeight
local nBottom
local nRight
/* local cCodice
local aItem
local cNumeri
local lFlag
local nPeso*/
local oBrw
local oSay[20]
local aGet[20]
local oExit
nAltCor := GETSYSMETRICS( 4 )
nTop := 0
nLeft := 0
nWidth := 1000
nHeight := 800
nBottom := nTop + nHeight + nAltCor
nRight := nLeft + nWidth
cCodice := "22"
nPeso := 33.60
aItem := {"Uno", "Due", "Tre", "Quattro", "Cinque", "Sei"}
DEFINE FONT oFont1 NAME "VERDANA" SIZE 0, -14
DEFINE FONT oFont2 NAME "VERDANA" SIZE 0, -13
DEFINE FONT oFont3 NAME "TAHOMA" SIZE 0, -14
DEFINE DIALOG oDlg FROM nTop , nLeft TO nBottom, nRight ;
PIXEL TRUEPIXEL RESIZABLE;
FONT oFont1 ;
TITLE "Resize Dialog"
@ 30, 20 SAY oSay[1] Prompt "Codice" OF oDlg SIZE 80,24 PIXEL FONT oFont1 BORDER
@ 30, 110 GET aGet[1] VAR cCodice OF oDlg SIZE 80,24 PIXEL FONT oFont1 ACTION Msginfo("ok")
@ 94 , 4 FOLDEREX oFol ;
OF oDlg ;
SIZE oDlg:nWidth - 8 , 250 ;
PIXEL ;
PROMPTS "Vendite",;
"Spedizione",;
"Note",;
"Allegati , Black List",;
"Appoggi bancari"
oFol:SetFont( oFont1 )
@ 380, 4 XBROWSE oBrw OF oDlg ;
SIZE oDlg:nWidth - 8, 250 ;
PIXEL ;
AUTOCOLS ;
ALIAS {{"aaa", "1111"}, {"BBB", "22222"}, {"CCC", "33333"}} ;
FONT oFont3 ;
NOBORDER
oBrw:nMarqueeStyle := MARQSTYLE_HIGHLWIN7
oBrw:CreateFromCode()
@ nBottom - 80, 20 BUTTON oExit Prompt "Exit" OF oDlg SIZE 90,30 PIXEL FONT oFont1 ACTION oDlg:End()
oDlg:bResized := <||
local oRect := oDlg:GetCliRect()
oSay[1]:nTop := oRect:nTop+5
oSay[1]:nLeft:= oRect:nLeft+10
aGet[1]:nTop := oRect:nTop+ 5
aGet[1]:nleft := oRect:nleft+95
oFol:ntop := oRect:nTop+30
oFol:nWidth := oRect:nWidth -5
oFol:nHeight := oRect:nbottom/2
oExit:ntop:= oFol:nHeight+30
oExit:nLeft:= oRect:nRight-100
oBrw:ntop := oFol:nHeight+70
oBrw:nWidth := oRect:nWidth -5
oBrw:nbottom:= oRect:nbottom-300
RETURN nil
>
*
ACTIVATE DIALOG oDlg CENTERED ;
ON INIT eval( oDlg:bResized)
RELEASE oFont1
RELEASE oFont2
RELEASE oFont3
return nil
Please see oExit button, it is always between the folder and the oBrw
I use the same on my Calculator I use on tablet
Re: Resize dialog
Posted: Wed Oct 14, 2020 3:37 pm
by Otto
Thank you Silvio for this sample.
Regards,
Otto
Re: Resize dialog
Posted: Wed Oct 14, 2020 4:39 pm
by mauri.menabue
Hi all,
Silvio thanks with your example
I found the way to resize the controls according
to the dialog area.
Now I have to find a way to change the font size
according to the size of the controls.
Is it possible to change the font size on fly?
I am attaching an example of the new test.
Thanks again !
Code: Select all
#include "FiveWin.ch"
*----------------------------------------------------------------------------
function ResDlg
*----------------------------------------------------------------------------
local oFont1
local oFont2
local oFont3
local nAltCor
local nTop
local nLeft
local nWidth
local nHeight
local nBottom
local nRight
local aCon := Hash()
local aVar := Hash()
HSetCaseMatch( aCon, .F. )
HSetCaseMatch( aVar, .F. )
aVar['cCodice'] := space(2)
DEFINE FONT oFont1 NAME "VERDANA" SIZE 0, -10
nAltCor := GETSYSMETRICS( 4 )
nTop := 0
nLeft := 0
nWidth := 1000
nHeight := 800
nBottom := nTop + nHeight + nAltCor
nRight := nLeft + nWidth
DEFINE DIALOG aCon['oDlg'] ;
FROM nTop , nLeft TO nBottom, nRight ;
PIXEL TRUEPIXEL RESIZABLE;
FONT oFont1 ;
TITLE "Resize Dialog"
@ 30 , 20 SAY aCon['oSay1'] ;
PROMPT "Codice" ;
OF aCon['oDlg'] ;
SIZE 60,24 ;
PIXEL ;
FONT oFont1 ;
BORDER
@ 30 , 110 GET aCon['oGet1'] ;
VAR aVar['cCodice'] ;
OF aCon['oDlg'] ;
SIZE 80,24 ;
PIXEL ;
FONT oFont1 ;
ACTION Msginfo("ok")
@ 94 , 4 FOLDEREX aCon['oFol1'] ;
SIZE aCon['oDlg']:nWidth - 8 , 250 ;
OF aCon['oDlg'] ;
PIXEL ;
PROMPTS "Vendite",;
"Spedizione",;
"Note",;
"Allegati , Black List",;
"Appoggi bancari"
aCon['oFol1']:SetFont( oFont1 )
@ 354, 120 BUTTON aCon['oBtn1'] ;
Prompt "Exit" ;
OF aCon['oDlg'] ;
SIZE 90,30 ;
PIXEL ;
FONT oFont1 ;
ACTION aCon['oDlg']:End()
@ 394, 4 XBROWSE aCon['oBrw1'] ;
OF aCon['oDlg'] ;
SIZE aCon['oDlg']:nWidth - 8, 200 ;
PIXEL ;
AUTOCOLS ;
ALIAS {{"aaa", "1111"}, {"BBB", "22222"}, {"CCC", "33333"}} ;
FONT oFont3 ;
NOBORDER
aCon['oBrw1']:nMarqueeStyle := MARQSTYLE_HIGHLWIN7
aCon['oBrw1']:CreateFromCode()
aCon['oDlg']:bInit := { || InitDialog( aCon['oDlg'], aCon ) }
aCon['oDlg']:bResized := { || ResizeDialog( aCon['oDlg'], aCon ) }
ACTIVATE DIALOG aCon['oDlg'] CENTERED
RELEASE oFont1
return nil
*---------------------------------------------------------------------
function InitDialog( oDlg, aCon )
*---------------------------------------------------------------------
local oRect := oDlg:GetCliRect()
local nI1
local oCon
for nI1 := 1 TO len(oDlg:aControls)
oCon := oDlg:aControls[nI1]
oCon:Cargo := hash()
oCon:Cargo['%ROW'] := oCon:nTop * 100 / oRect:nHeight
oCon:Cargo['%COL'] := oCon:nLeft * 100 / oRect:nWidth
oCon:Cargo['%ALT'] := oCon:nHeight * 100 / oRect:nHeight
oCon:Cargo['%LAR'] := oCon:nWidth * 100 / oRect:nWidth
next
Eval( oDlg:bResized )
return NIL
*---------------------------------------------------------------------
function ResizeDialog( oDlg, aCon )
*---------------------------------------------------------------------
local oRect := oDlg:GetCliRect()
local nI1
local oCon
for nI1 := 1 TO len(oDlg:aControls)
oCon := oDlg:aControls[nI1]
oCon:nTop := oRect:nTop + PERC(oRect:nHeight , oCon:Cargo['%ROW'])
oCon:nLeft := oRect:nLeft + PERC(oRect:nWidth , oCon:Cargo['%COL'])
oCon:nHeight := PERC(oRect:nHeight , oCon:Cargo['%ALT'])
oCon:nWidth := PERC(oRect:nWidth , oCon:Cargo['%LAR'])
next
return NIL
*---------------------------------------------------------------------
function Perc (nVal, nPrc)
*---------------------------------------------------------------------
return( nVal * nPrc / 100)
Re: Resize dialog
Posted: Wed Oct 14, 2020 5:57 pm
by Otto
Hello Mauri,
I tried your code and made following changes.
Code: Select all
#include "FiveWin.ch"
*----------------------------------------------------------------------------
function ResDlg
*----------------------------------------------------------------------------
local oFont1
local oFont2
local oFont3
local nAltCor
local nTop
local nLeft
local nWidth
local nHeight
local nBottom
local nRight
local aCon := Hash()
local aVar := Hash()
HSetCaseMatch( aCon, .F. )
HSetCaseMatch( aVar, .F. )
aVar['cCodice'] := space(2)
DEFINE FONT oFont1 NAME "VERDANA" SIZE 0, -10
nAltCor := GETSYSMETRICS( 4 )
nTop := 0
nLeft := 0
nWidth := 1000
nHeight := 800
nBottom := nTop + nHeight + nAltCor
nRight := nLeft + nWidth
DEFINE DIALOG aCon['oDlg'] ;
FROM nTop , nLeft TO nBottom, nRight ;
PIXEL TRUEPIXEL RESIZABLE;
FONT oFont1 ;
TITLE "Resize Dialog"
@ 30 , 20 SAY aCon['oSay1'] ;
PROMPT "Codice" ;
OF aCon['oDlg'] ;
SIZE 60,24 ;
PIXEL ;
FONT oFont1 ;
BORDER
@ 30 , 110 GET aCon['oGet1'] ;
VAR aVar['cCodice'] ;
OF aCon['oDlg'] ;
SIZE 80,24 ;
PIXEL ;
FONT oFont1 ;
ACTION Msginfo("ok")
@ 94 , 4 FOLDEREX aCon['oFol1'] ;
SIZE aCon['oDlg']:nWidth - 8 , 250 ;
OF aCon['oDlg'] ;
PIXEL ;
PROMPTS "Vendite",;
"Spedizione",;
"Note",;
"Allegati , Black List",;
"Appoggi bancari"
aCon['oFol1']:SetFont( oFont1 )
@ 354, 120 BUTTON aCon['oBtn1'] ;
Prompt "Exit" ;
OF aCon['oDlg'] ;
SIZE 90,30 ;
PIXEL ;
FONT oFont1 ;
ACTION aCon['oDlg']:End()
@ 394, 4 XBROWSE aCon['oBrw1'] ;
OF aCon['oDlg'] ;
SIZE aCon['oDlg']:nWidth - 8, 200 ;
PIXEL ;
AUTOCOLS ;
ALIAS {{"aaa", "1111"}, {"BBB", "22222"}, {"CCC", "33333"}} ;
FONT oFont3 ;
NOBORDER
aCon['oBrw1']:nMarqueeStyle := MARQSTYLE_HIGHLWIN7
aCon['oBrw1']:CreateFromCode()
aCon['oDlg']:bInit := { || InitDialog( aCon['oDlg'], aCon ) }
aCon['oDlg']:bResized := { || ResizeDialog( aCon['oDlg'], aCon, oFont1 ) }
ACTIVATE DIALOG aCon['oDlg'] CENTERED
RELEASE oFont1
return nil
*---------------------------------------------------------------------
function InitDialog( oDlg, aCon )
*---------------------------------------------------------------------
local oRect := oDlg:GetCliRect()
local nI1
local oCon
for nI1 := 1 TO len(oDlg:aControls)
oCon := oDlg:aControls[nI1]
oCon:Cargo := hash()
oCon:Cargo['%ROW'] := oCon:nTop * 100 / oRect:nHeight
oCon:Cargo['%COL'] := oCon:nLeft * 100 / oRect:nWidth
oCon:Cargo['%ALT'] := oCon:nHeight * 100 / oRect:nHeight
oCon:Cargo['%LAR'] := oCon:nWidth * 100 / oRect:nWidth
next
Eval( oDlg:bResized )
return NIL
*---------------------------------------------------------------------
function ResizeDialog( oDlg, aCon,oFont1 )
*---------------------------------------------------------------------
local oRect := oDlg:GetCliRect()
local nI1
local oCon
if oDlg:nWidth > 1000
DEFINE FONT oFont1 NAME "VERDANA" SIZE 0, -20
else
oFont1:Modify( -13 )
endif
for nI1 := 1 TO len(oDlg:aControls)
oCon := oDlg:aControls[nI1]
oCon:nTop := oRect:nTop + PERC(oRect:nHeight , oCon:Cargo['%ROW'])
oCon:nLeft := oRect:nLeft + PERC(oRect:nWidth , oCon:Cargo['%COL'])
oCon:nHeight := PERC(oRect:nHeight , oCon:Cargo['%ALT'])
oCon:nWidth := PERC(oRect:nWidth , oCon:Cargo['%LAR'])
oCon:SetFont(oFont1)
next
return NIL
*---------------------------------------------------------------------
function Perc (nVal, nPrc)
*---------------------------------------------------------------------
return( nVal * nPrc / 100)
Re: Resize dialog
Posted: Wed Oct 14, 2020 6:30 pm
by Silvio.Falconi
Otto wrote:Hello Mauri,
I tried your code and made following changes.
Otto,
it might be fine, but there is font change that gets big right away it's not scaled to window sizing
Re: Resize dialog
Posted: Wed Oct 14, 2020 7:46 pm
by Otto
Hello Silvio,
I think we have to check similar as bootstrap does:
Extra small <576px
Small ≥576px
Medium ≥768px
Large ≥992px
Extra large ≥1200px
Then set the Fonts.
Best regards,
Otto
Re: Resize dialog
Posted: Wed Oct 14, 2020 8:07 pm
by Silvio.Falconi
but you'are trying the test ?
can't you see that you see tugs and then immediately change the font to large or small?
instead look at the calculator animation above
Re: Resize dialog
Posted: Wed Oct 14, 2020 8:18 pm
by Silvio.Falconi
mauri.menabue wrote:Hi all,
Silvio thanks with your example
I found the way to resize the controls according
to the dialog area.
Now I have to find a way to change the font size
according to the size of the controls.
Is it possible to change the font size on fly?
I am attaching an example of the new test.
Thanks again !
Menabue
write to private email pls
silvio[dot]falconi[at]gmail[dot]com
thanks
Re: Resize dialog
Posted: Wed Oct 14, 2020 8:49 pm
by mauri.menabue
hi all
I was able to adjust the height of the font
but I can't adjust the width, any ideas?
Code: Select all
#include "FiveWin.ch"
*----------------------------------------------------------------------------
function ResDlg
*----------------------------------------------------------------------------
local oFont1
local oFont2
local oFont3
local nAltCor
local nTop
local nLeft
local nWidth
local nHeight
local nBottom
local nRight
local aCon := Hash()
local aVar := Hash()
HSetCaseMatch( aCon, .F. )
HSetCaseMatch( aVar, .F. )
aVar['cCodice'] := space(2)
DEFINE FONT aCon['oFont1'] NAME "VERDANA" SIZE 0, -11
DEFINE FONT aCon['oFont2'] NAME "VERDANA" SIZE 0, -11 BOLD
nAltCor := GETSYSMETRICS( 4 )
nTop := 0
nLeft := 0
nWidth := 1000
nHeight := 700
nBottom := nTop + nHeight + nAltCor
nRight := nLeft + nWidth
DEFINE DIALOG aCon['oDlg'] ;
FROM nTop , nLeft TO nBottom, nRight ;
PIXEL TRUEPIXEL RESIZABLE;
FONT aCon['oFont1'] ;
TITLE "Resize Dialog"
@ 30 , 20 SAY aCon['oSay1'] ;
PROMPT "Codice" ;
OF aCon['oDlg'] ;
SIZE 60,24 ;
PIXEL ;
FONT aCon['oFont2'] ;
BORDER
@ 30 , 110 GET aCon['oGet1'] ;
VAR aVar['cCodice'] ;
OF aCon['oDlg'] ;
SIZE 80,24 ;
PIXEL ;
FONT aCon['oFont1'] ;
ACTION Msginfo("ok")
@ 94 , 4 FOLDEREX aCon['oFol1'] ;
SIZE aCon['oDlg']:nWidth - 8 , 250 ;
OF aCon['oDlg'] ;
PIXEL ;
PROMPTS "Vendite",;
"Spedizione",;
"Note",;
"Allegati , Black List",;
"Appoggi bancari"
aCon['oFol1']:SetFont( aCon['oFont1'] )
@ 354, 120 BUTTON aCon['oBtn1'] ;
Prompt "Exit" ;
OF aCon['oDlg'] ;
SIZE 90,30 ;
PIXEL ;
FONT aCon['oFont1'] ;
ACTION aCon['oDlg']:End()
@ 394, 4 XBROWSE aCon['oBrw1'] ;
OF aCon['oDlg'] ;
SIZE aCon['oDlg']:nWidth - 8, 200 ;
PIXEL ;
AUTOCOLS ;
ALIAS {{"aaa", "1111"}, {"BBB", "22222"}, {"CCC", "33333"}} ;
FONT aCon['oFont1'] ;
NOBORDER
aCon['oBrw1']:nMarqueeStyle := MARQSTYLE_HIGHLWIN7
aCon['oBrw1']:CreateFromCode()
aCon['oDlg']:bInit := { || InitDialog( aCon['oDlg'], aCon ) }
aCon['oDlg']:bResized := { || ResizeDialog( aCon['oDlg'], aCon ) }
ACTIVATE DIALOG aCon['oDlg'] CENTERED
RELEASE FONT aCon['oFont1']
RELEASE FONT aCon['oFont2']
return nil
*---------------------------------------------------------------------
function InitDialog( oDlg, aCon )
*---------------------------------------------------------------------
local oRect := oDlg:GetCliRect()
local nI1
local oCon
for nI1 := 1 TO len(oDlg:aControls)
oCon := oDlg:aControls[nI1]
oCon:Cargo := hash()
oCon:Cargo['%ROW'] := oCon:nTop * 100 / oRect:nHeight
oCon:Cargo['%COL'] := oCon:nLeft * 100 / oRect:nWidth
oCon:Cargo['%ALT'] := oCon:nHeight * 100 / oRect:nHeight
oCon:Cargo['%LAR'] := oCon:nWidth * 100 / oRect:nWidth
oCon:Cargo['%FON'] := oCon:oFont:nHeight * 100 / oRect:nHeight
next
Eval( oDlg:bResized )
return NIL
*---------------------------------------------------------------------
function ResizeDialog( oDlg, aCon )
*---------------------------------------------------------------------
local oRect := oDlg:GetCliRect()
local nI1
local oCon
local cFaceName
local oFontTmp
local lBold
for nI1 := 1 TO len(oDlg:aControls)
oCon := oDlg:aControls[nI1]
cFaceName := oCon:GetFont():cFaceName
lBold := oCon:GetFont():lBold
IF lBold
DEFINE FONT oFontTmp NAME cFaceName SIZE 0, -PERC(oRect:nHeight , oCon:Cargo['%FON']) BOLD
ELSE
DEFINE FONT oFontTmp NAME cFaceName SIZE 0, -PERC(oRect:nHeight , oCon:Cargo['%FON'])
ENDIF
oCon:nTop := oRect:nTop + PERC(oRect:nHeight , oCon:Cargo['%ROW'])
oCon:nLeft := oRect:nLeft + PERC(oRect:nWidth , oCon:Cargo['%COL'])
oCon:nHeight := PERC(oRect:nHeight , oCon:Cargo['%ALT'])
oCon:nWidth := PERC(oRect:nWidth , oCon:Cargo['%LAR'])
oCon:SetFont(oFontTmp)
RELEASE FONT oFontTmp
next
return NIL
*---------------------------------------------------------------------
function Perc (nVal, nPrc)
*---------------------------------------------------------------------
return( nVal * nPrc / 100)
TIA
Re: Resize dialog
Posted: Wed Oct 14, 2020 9:56 pm
by Otto
Mauri, you should check the dialog size and then set a predefined Font for the size - which looks nice. Same with buttons.
Regards,
Otto
Code: Select all
DEFINE FONT oFontTmp NAME cFaceName SIZE -PERC( oRect:nWidth , oCon:Cargo['%FON'] ), -PERC( oRect:nHeight , oCon:Cargo['%FON'] )
Re: Resize dialog
Posted: Thu Oct 15, 2020 8:44 am
by mauri.menabue
hi all,
I have to find a way to fix the position
of the button inside the get with the action.
I am attaching the latest test version of the dialog resize program.
Code: Select all
#include "FiveWin.ch"
*----------------------------------------------------------------------------
function ResDlg
*----------------------------------------------------------------------------
local oFont1
local oFont2
local oFont3
local nAltCor
local nTop
local nLeft
local nWidth
local nHeight
local nBottom
local nRight
local aCon := Hash()
local aVar := Hash()
HSetCaseMatch( aCon, .F. )
HSetCaseMatch( aVar, .F. )
aVar['cCodice'] := space(2)
aVar['nPeso'] := 0
aVar['aItem'] := {"Uno", "due", "tre", "quattro", "cinque"}
DEFINE FONT aCon['oFont1'] NAME "VERDANA" SIZE 0, -11
DEFINE FONT aCon['oFont2'] NAME "VERDANA" SIZE 0, -11 BOLD
nAltCor := GETSYSMETRICS( 4 )
nTop := 0
nLeft := 0
nWidth := 1000
nHeight := 700
nBottom := nTop + nHeight + nAltCor
nRight := nLeft + nWidth
DEFINE DIALOG aCon['oDlg'] ;
FROM nTop , nLeft TO nBottom, nRight ;
PIXEL TRUEPIXEL RESIZABLE;
FONT aCon['oFont1'] ;
TITLE "Resize Dialog"
@ 30 , 20 SAY aCon['oSay1'] ;
PROMPT "Codice" ;
OF aCon['oDlg'] ;
SIZE 60,24 ;
PIXEL ;
FONT aCon['oFont2'] ;
BORDER ;
UPDATE
@ 30 , 110 GET aCon['oGet1'] ;
VAR aVar['cCodice'] ;
OF aCon['oDlg'] ;
SIZE 80,24 ;
PIXEL ;
FONT aCon['oFont1'] ;
ACTION Msginfo("ok") ;
UPDATE
@ 94 , 4 FOLDEREX aCon['oFol1'] ;
SIZE aCon['oDlg']:nWidth - 8 , 250 ;
OF aCon['oDlg'] ;
PIXEL ;
PROMPTS "Vendite",;
"Spedizione",;
"Note",;
"Allegati , Black List",;
"Appoggi bancari"
aCon['oFol1']:SetFont( aCon['oFont1'] )
*-------------------------------------------------------------------------
*- Vendite
*-------------------------------------------------------------------------
@ 10 , 10 SAY aCon['oSay2'] ;
PROMPT "Peso" ;
OF aCon['oFol1']:aDialogs[01] ;
SIZE 30,12 ;
PIXEL ;
FONT aCon['oFont2'] ;
BORDER ;
UPDATE
@ 354, 120 BUTTON aCon['oBtn1'] ;
Prompt "Exit" ;
OF aCon['oDlg'] ;
SIZE 90,30 ;
PIXEL ;
FONT aCon['oFont1'] ;
UPDATE ;
ACTION aCon['oDlg']:End()
@ 394, 4 XBROWSE aCon['oBrw1'] ;
OF aCon['oDlg'] ;
SIZE aCon['oDlg']:nWidth - 8, 200 ;
PIXEL ;
AUTOCOLS ;
ALIAS {{"aaa", "1111"}, {"BBB", "22222"}, {"CCC", "33333"}} ;
FONT aCon['oFont1'] ;
NOBORDER;
UPDATE
aCon['oBrw1']:nMarqueeStyle := MARQSTYLE_HIGHLWIN7
aCon['oBrw1']:CreateFromCode()
aCon['oDlg']:bInit := { || InitDialog( aCon['oDlg'], aCon ) }
aCon['oDlg']:bResized := { || ResizeDialog( aCon['oDlg'], aCon ) }
ACTIVATE DIALOG aCon['oDlg'] CENTERED
RELEASE FONT aCon['oFont1']
RELEASE FONT aCon['oFont2']
return nil
*---------------------------------------------------------------------
function InitDialog( oDlg, aCon )
*---------------------------------------------------------------------
local oRect1 := oDlg:GetCliRect()
local oRect2
local nI1
local nI2
local nI3
local oCon1
local oCon2
local oPage
local oBrw
SET MESSAGE OF oDlg TO "Test resize dialog dynamic" NOINSET CENTER 2010 FONT oDlg:oFont
for nI1 := 1 TO len(oDlg:aControls)
oCon1 := oDlg:aControls[nI1]
oCon1:Cargo := hash()
oCon1:Cargo['%ROW'] := oCon1:nTop * 100 / oRect1:nHeight
oCon1:Cargo['%COL'] := oCon1:nLeft * 100 / oRect1:nWidth
oCon1:Cargo['%ALT'] := oCon1:nHeight * 100 / oRect1:nHeight
oCon1:Cargo['%LAR'] := oCon1:nWidth * 100 / oRect1:nWidth
oCon1:Cargo['%FOH'] := oCon1:oFont:nHeight * 100 / oRect1:nHeight
oCon1:Cargo['%FOW'] := oCon1:oFont:nWidth * 100 / oRect1:nWidth
if oCon1:ClassName() $ "/TXBROWSE"
ENDIF
if oCon1:ClassName() $ "/TFOLDER/TPAGES/TFOLDEREX"
If ValType( oCon1:aDialogs ) = "A"
FOR nI2 := 1 TO LEN(oCon1:aDialogs)
oPage := oCon1:aDialogs[nI2]
oRect2 := oPage:GetCliRect()
FOR nI3 := 1 TO LEN(oPage:aControls)
oCon2 := oPage:aControls[nI3]
oCon2:Cargo := hash()
oCon2:Cargo['%ROW'] := oCon2:nTop * 100 / oRect2:nHeight
oCon2:Cargo['%COL'] := oCon2:nLeft * 100 / oRect2:nWidth
oCon2:Cargo['%ALT'] := oCon2:nHeight * 100 / oRect2:nHeight
oCon2:Cargo['%LAR'] := oCon2:nWidth * 100 / oRect2:nWidth
oCon2:Cargo['%FOH'] := oCon2:oFont:nHeight * 100 / oRect2:nHeight
oCon2:Cargo['%FOW'] := oCon2:oFont:nWidth * 100 / oRect2:nWidth
NEXT
NEXT
endif
endif
next
Eval( oDlg:bResized )
return NIL
*---------------------------------------------------------------------
function ResizeDialog( oDlg, aCon )
*---------------------------------------------------------------------
local oRect1 := oDlg:GetCliRect()
local oRect2
local nI1
local nI2
local nI3
local oCon1
local oCon2
local oPage
local oBrw
local cFaceName
local oFontTmp
local oFontCon
local lBold
local lItalic
local lUnderline
local nWidthFont
local nHeightFont
for nI1 := 1 TO len(oDlg:aControls)
oCon1 := oDlg:aControls[nI1]
*------------------------------------------------------
*- Resize controls in dialog
*------------------------------------------------------
nWidthFont := ceiling(PERC( oRect1:nWidth , oCon1:Cargo['%FOW']))
nHeightFont := -ceiling(PERC( oRect1:nHeight , oCon1:Cargo['%FOH']))
oFontCon := oCon1:GetFont()
cFaceName := oFontCon:cFaceName
lBold := oFontCon:lBold
lItalic := oFontCon:lItalic
lUnderline := oFontCon:lUnderline
oFontTmp := tFont():New( cFaceName, nWidthFont, nHeightFont, , lBold, , , , lItalic, lUnderline )
oCon1:nTop := oRect1:nTop + PERC(oRect1:nHeight , oCon1:Cargo['%ROW'])
oCon1:nLeft := oRect1:nLeft + PERC(oRect1:nWidth , oCon1:Cargo['%COL'])
oCon1:nHeight := PERC(oRect1:nHeight , oCon1:Cargo['%ALT'])
oCon1:nWidth := PERC(oRect1:nWidth , oCon1:Cargo['%LAR'])
oCon1:SetFont(oFontTmp)
RELEASE FONT oFontTmp
*------------------------------------------------------
*- Resize columns in browse
*------------------------------------------------------
if oCon1:ClassName() $ "/TXBROWSE"
ENDIF
*------------------------------------------------------
*- Resize controls in page
*------------------------------------------------------
if oCon1:ClassName() $ "/TFOLDER/TPAGES/TFOLDEREX"
If ValType( oCon1:aDialogs ) = "A"
FOR nI2 := 1 TO LEN(oCon1:aDialogs)
oPage := oCon1:aDialogs[nI2]
FOR nI3 := 1 TO LEN(oPage:aControls)
oCon2 := oPage:aControls[nI3]
oRect2 := oPage:GetCliRect()
nWidthFont := ceiling(PERC( oRect2:nWidth , oCon2:Cargo['%FOW']))
nHeightFont := -ceiling(PERC( oRect2:nHeight , oCon2:Cargo['%FOH']))
oFontCon := oCon2:GetFont()
cFaceName := oFontCon:cFaceName
lBold := oFontCon:lBold
lItalic := oFontCon:lItalic
lUnderline := oFontCon:lUnderline
oFontTmp := tFont():New( cFaceName, nWidthFont, nHeightFont, , lBold, , , , lItalic, lUnderline )
oCon2:nTop := oRect2:nTop + PERC(oRect2:nHeight , oCon2:Cargo['%ROW'])
oCon2:nLeft := oRect2:nLeft + PERC(oRect2:nWidth , oCon2:Cargo['%COL'])
oCon2:nHeight := PERC(oRect2:nHeight , oCon2:Cargo['%ALT'])
oCon2:nWidth := PERC(oRect2:nWidth , oCon2:Cargo['%LAR'])
oCon2:SetFont(oFontTmp)
RELEASE FONT oFontTmp
NEXT
oPage:Refresh()
NEXT
ENDIF
ENDIF
next
return NIL
*---------------------------------------------------------------------
function Perc (nVal, nPrc)
*---------------------------------------------------------------------
return( nVal * nPrc / 100)
Thank you
Re: Resize dialog
Posted: Thu Oct 15, 2020 1:31 pm
by Otto
Hello Mauri,
try:
Code: Select all
nTmp := aCon['oGet1']:nWidth
aCon['oGet1']:oBtn:nleft := nTmp - 21
oPage:Refresh()
Best regards,
Otto
Code: Select all
#include "FiveWin.ch"
*----------------------------------------------------------------------------
function ResDlg
*----------------------------------------------------------------------------
local oFont1
local oFont2
local oFont3
local nAltCor
local nTop
local nLeft
local nWidth
local nHeight
local nBottom
local nRight
local aCon := Hash()
local aVar := Hash()
HSetCaseMatch( aCon, .F. )
HSetCaseMatch( aVar, .F. )
aVar['cCodice'] := space(2)
aVar['nPeso'] := 0
aVar['aItem'] := {"Uno", "due", "tre", "quattro", "cinque"}
DEFINE FONT aCon['oFont1'] NAME "VERDANA" SIZE 0, -11
DEFINE FONT aCon['oFont2'] NAME "VERDANA" SIZE 0, -11 BOLD
nAltCor := GETSYSMETRICS( 4 )
nTop := 0
nLeft := 0
nWidth := 1000
nHeight := 700
nBottom := nTop + nHeight + nAltCor
nRight := nLeft + nWidth
DEFINE DIALOG aCon['oDlg'] ;
FROM nTop , nLeft TO nBottom, nRight ;
PIXEL TRUEPIXEL RESIZABLE;
FONT aCon['oFont1'] ;
TITLE "Resize Dialog"
@ 30 , 20 SAY aCon['oSay1'] ;
PROMPT "Codice" ;
OF aCon['oDlg'] ;
SIZE 60,24 ;
PIXEL ;
FONT aCon['oFont2'] ;
BORDER ;
UPDATE
@ 30 , 110 GET aCon['oGet1'] ;
VAR aVar['cCodice'] ;
OF aCon['oDlg'] ;
SIZE 80,24 ;
PIXEL ;
FONT aCon['oFont1'] ;
ACTION Msginfo("ok") ;
UPDATE
@ 94 , 4 FOLDEREX aCon['oFol1'] ;
SIZE aCon['oDlg']:nWidth - 8 , 250 ;
OF aCon['oDlg'] ;
PIXEL ;
PROMPTS "Vendite",;
"Spedizione",;
"Note",;
"Allegati , Black List",;
"Appoggi bancari"
aCon['oFol1']:SetFont( aCon['oFont1'] )
*-------------------------------------------------------------------------
*- Vendite
*-------------------------------------------------------------------------
@ 10 , 10 SAY aCon['oSay2'] ;
PROMPT "Peso" ;
OF aCon['oFol1']:aDialogs[01] ;
SIZE 30,12 ;
PIXEL ;
FONT aCon['oFont2'] ;
BORDER ;
UPDATE
@ 354, 120 BUTTON aCon['oBtn1'] ;
Prompt "Exit" ;
OF aCon['oDlg'] ;
SIZE 90,30 ;
PIXEL ;
FONT aCon['oFont1'] ;
UPDATE ;
ACTION aCon['oDlg']:End()
@ 394, 4 XBROWSE aCon['oBrw1'] ;
OF aCon['oDlg'] ;
SIZE aCon['oDlg']:nWidth - 8, 200 ;
PIXEL ;
AUTOCOLS ;
ALIAS {{"aaa", "1111"}, {"BBB", "22222"}, {"CCC", "33333"}} ;
FONT aCon['oFont1'] ;
NOBORDER;
UPDATE
aCon['oBrw1']:nMarqueeStyle := MARQSTYLE_HIGHLWIN7
aCon['oBrw1']:CreateFromCode()
aCon['oDlg']:bInit := { || InitDialog( aCon['oDlg'], aCon ) }
aCon['oDlg']:bResized := { || ResizeDialog( aCon['oDlg'], aCon ) }
ACTIVATE DIALOG aCon['oDlg'] CENTERED
RELEASE FONT aCon['oFont1']
RELEASE FONT aCon['oFont2']
return nil
*---------------------------------------------------------------------
function InitDialog( oDlg, aCon )
*---------------------------------------------------------------------
local oRect1 := oDlg:GetCliRect()
local oRect2
local nI1
local nI2
local nI3
local oCon1
local oCon2
local oPage
local oBrw
SET MESSAGE OF oDlg TO "Test resize dialog dynamic" NOINSET CENTER 2010 FONT oDlg:oFont
for nI1 := 1 TO len(oDlg:aControls)
oCon1 := oDlg:aControls[nI1]
oCon1:Cargo := hash()
oCon1:Cargo['%ROW'] := oCon1:nTop * 100 / oRect1:nHeight
oCon1:Cargo['%COL'] := oCon1:nLeft * 100 / oRect1:nWidth
oCon1:Cargo['%ALT'] := oCon1:nHeight * 100 / oRect1:nHeight
oCon1:Cargo['%LAR'] := oCon1:nWidth * 100 / oRect1:nWidth
oCon1:Cargo['%FOH'] := oCon1:oFont:nHeight * 100 / oRect1:nHeight
oCon1:Cargo['%FOW'] := oCon1:oFont:nWidth * 100 / oRect1:nWidth
if oCon1:ClassName() $ "/TXBROWSE"
ENDIF
if oCon1:ClassName() $ "/TFOLDER/TPAGES/TFOLDEREX"
If ValType( oCon1:aDialogs ) = "A"
FOR nI2 := 1 TO LEN(oCon1:aDialogs)
oPage := oCon1:aDialogs[nI2]
oRect2 := oPage:GetCliRect()
FOR nI3 := 1 TO LEN(oPage:aControls)
oCon2 := oPage:aControls[nI3]
oCon2:Cargo := hash()
oCon2:Cargo['%ROW'] := oCon2:nTop * 100 / oRect2:nHeight
oCon2:Cargo['%COL'] := oCon2:nLeft * 100 / oRect2:nWidth
oCon2:Cargo['%ALT'] := oCon2:nHeight * 100 / oRect2:nHeight
oCon2:Cargo['%LAR'] := oCon2:nWidth * 100 / oRect2:nWidth
oCon2:Cargo['%FOH'] := oCon2:oFont:nHeight * 100 / oRect2:nHeight
oCon2:Cargo['%FOW'] := oCon2:oFont:nWidth * 100 / oRect2:nWidth
NEXT
NEXT
endif
endif
next
Eval( oDlg:bResized )
return NIL
*---------------------------------------------------------------------
function ResizeDialog( oDlg, aCon )
*---------------------------------------------------------------------
local oRect1 := oDlg:GetCliRect()
local oRect2
local nI1
local nI2
local nI3
local oCon1
local oCon2
local oPage
local oBrw
local cFaceName
local oFontTmp
local oFontCon
local lBold
local lItalic
local lUnderline
local nWidthFont
local nHeightFont
for nI1 := 1 TO len(oDlg:aControls)
oCon1 := oDlg:aControls[nI1]
*------------------------------------------------------
*- Resize controls in dialog
*------------------------------------------------------
nWidthFont := ceiling(PERC( oRect1:nWidth , oCon1:Cargo['%FOW']))
nHeightFont := -ceiling(PERC( oRect1:nHeight , oCon1:Cargo['%FOH']))
oFontCon := oCon1:GetFont()
cFaceName := oFontCon:cFaceName
lBold := oFontCon:lBold
lItalic := oFontCon:lItalic
lUnderline := oFontCon:lUnderline
oFontTmp := tFont():New( cFaceName, nWidthFont, nHeightFont, , lBold, , , , lItalic, lUnderline )
oCon1:nTop := oRect1:nTop + PERC(oRect1:nHeight , oCon1:Cargo['%ROW'])
oCon1:nLeft := oRect1:nLeft + PERC(oRect1:nWidth , oCon1:Cargo['%COL'])
oCon1:nHeight := PERC(oRect1:nHeight , oCon1:Cargo['%ALT'])
oCon1:nWidth := PERC(oRect1:nWidth , oCon1:Cargo['%LAR'])
oCon1:SetFont(oFontTmp)
RELEASE FONT oFontTmp
*------------------------------------------------------
*- Resize columns in browse
*------------------------------------------------------
if oCon1:ClassName() $ "/TXBROWSE"
ENDIF
*------------------------------------------------------
*- Resize controls in page
*------------------------------------------------------
if oCon1:ClassName() $ "/TFOLDER/TPAGES/TFOLDEREX"
If ValType( oCon1:aDialogs ) = "A"
FOR nI2 := 1 TO LEN(oCon1:aDialogs)
oPage := oCon1:aDialogs[nI2]
FOR nI3 := 1 TO LEN(oPage:aControls)
oCon2 := oPage:aControls[nI3]
oRect2 := oPage:GetCliRect()
nWidthFont := ceiling(PERC( oRect2:nWidth , oCon2:Cargo['%FOW']))
nHeightFont := -ceiling(PERC( oRect2:nHeight , oCon2:Cargo['%FOH']))
oFontCon := oCon2:GetFont()
cFaceName := oFontCon:cFaceName
lBold := oFontCon:lBold
lItalic := oFontCon:lItalic
lUnderline := oFontCon:lUnderline
oFontTmp := tFont():New( cFaceName, nWidthFont, nHeightFont, , lBold, , , , lItalic, lUnderline )
oCon2:nTop := oRect2:nTop + PERC(oRect2:nHeight , oCon2:Cargo['%ROW'])
oCon2:nLeft := oRect2:nLeft + PERC(oRect2:nWidth , oCon2:Cargo['%COL'])
oCon2:nHeight := PERC(oRect2:nHeight , oCon2:Cargo['%ALT'])
oCon2:nWidth := PERC(oRect2:nWidth , oCon2:Cargo['%LAR'])
oCon2:SetFont(oFontTmp)
RELEASE FONT oFontTmp
NEXT
aCon['oGet1']:oBtn:nleft := aCon['oGet1']:nWidth - 21
oPage:Refresh()
NEXT
ENDIF
ENDIF
next
return NIL
*---------------------------------------------------------------------
function Perc (nVal, nPrc)
*---------------------------------------------------------------------
return( nVal * nPrc / 100)
Re: Resize dialog
Posted: Thu Oct 15, 2020 1:37 pm
by Silvio.Falconi
but sorry but for each dialog if I want to size it .... do I have to make a poem?
look my calc, I resize all controls and fonts
Re: Resize dialog
Posted: Wed Oct 21, 2020 12:19 pm
by Otto
Hello Mauri,
What is the status of your project?
Do you plan to post some more code.
Have a look at:
https://modharbour.app/compass/
Charly explains how to design screens. Let us try to do it in FIVEWIN the same way.
Best regards,
Otto