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