The last test made is the following,
try it and give me an opinion thanks.
- Code: Select all Expand view
#include "FiveWin.ch"
*----------------------------------------------------------------------------
function ResDlg
*----------------------------------------------------------------------------
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['cNumeri'] := space(10)
aVar['lFlag'] := .T.
aVar['nVelocita'] := 0
aVar['cNota'] := ""
DEFINE FONT aCon['oFont1'] NAME "VERDANA" SIZE 0, -11
DEFINE FONT aCon['oFont2'] NAME "VERDANA" SIZE 0, -11 BOLD
DEFINE FONT aCon['oFont3'] NAME "VERDANA" SIZE 0, -12 ITALIC
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'] ;
VAR "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
@ 58, 20 SAY aCon['oSay3'] ;
VAR "Numeri" ;
OF aCon['oDlg'] ;
SIZE 80,22 ;
PIXEL ;
FONT aCon['oFont2'] ;
BORDER
@ 58, 110 COMBOBOX aCon['oCmb1'] ;
VAR aVar['cNumeri'];
PROMPTS {"Uno",;
"due",;
"tre",;
"quattro",;
"cinque"} ;
OF aCon['oDlg'] ;
SIZE 120, 20*5 ;
PIXEL ;
FONT aCon['oFont1']
@ 58, 250 CHECKBOX aCon['oChk1'] ;
VAR aVar['lFlag'] ;
PROMPT "Attiva" ;
OF aCon['oDlg'] ;
SIZE 80,22 ;
PIXEL ;
FONT aCon['oFont1']
@ 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 Pag. 1
*-------------------------------------------------------------------------
@ 10 , 10 SAY aCon['oSay2'] ;
PROMPT "Peso" ;
OF aCon['oFol1']:aDialogs[01];
SIZE 30,12 ;
PIXEL ;
FONT aCon['oFont2'] ;
BORDER ;
UPDATE
@ 10 , 45 GET aCon['oGet2'] ;
VAR aVar['nPeso'] ;
OF aCon['oFol1']:aDialogs[01];
SIZE 40,12 ;
PIXEL ;
FONT aCon['oFont1'] ;
RIGHT ;
PICTURE "@E 999,999.99" ;
UPDATE
*-------------------------------------------------------------------------
*- Spedizione Pag. 2
*-------------------------------------------------------------------------
@ 10 , 10 SAY aCon['oSay3'] ;
PROMPT "Velocità" ;
OF aCon['oFol1']:aDialogs[02];
SIZE 30,12 ;
PIXEL ;
FONT aCon['oFont2'] ;
BORDER ;
UPDATE
@ 10 , 45 GET aCon['oGet3'] ;
VAR aVar['nVelocita'] ;
OF aCon['oFol1']:aDialogs[02];
SIZE 40,12 ;
PIXEL ;
FONT aCon['oFont1'] ;
RIGHT ;
PICTURE "@E 999,999.99" ;
UPDATE
@ 354, 120 BUTTON aCon['oBtn1'] ;
PROMPT "Exit" ;
OF aCon['oDlg'] ;
SIZE 90,30 ;
PIXEL ;
FONT aCon['oFont1'];
UPDATE ;
ACTION aCon['oDlg']:End()
@ 354, 220 BUTTON aCon['oBtn2'] ;
PROMPT "Zoom +" ;
OF aCon['oDlg'] ;
SIZE 90,30 ;
PIXEL ;
FONT aCon['oFont1'];
UPDATE ;
ACTION Zoom( "+", aCon['oDlg'], 5)
@ 354, 320 BUTTON aCon['oBtn3'] ;
PROMPT "Zoom -" ;
OF aCon['oDlg'] ;
SIZE 90,30 ;
PIXEL ;
FONT aCon['oFont1'];
UPDATE ;
ACTION Zoom( "-", aCon['oDlg'], 5)
@ 354, 420 BUTTON aCon['oBtn4'] ;
PROMPT "Zoom Max" ;
OF aCon['oDlg'] ;
SIZE 90,30 ;
PIXEL ;
FONT aCon['oFont1'];
UPDATE ;
ACTION Zoom( "+", aCon['oDlg'], 9999)
@ 354, 520 BUTTON aCon['oBtn5'] ;
PROMPT "Zoom Min" ;
OF aCon['oDlg'] ;
SIZE 90,30 ;
PIXEL ;
FONT aCon['oFont1'];
UPDATE ;
ACTION Zoom( "-", aCon['oDlg'], 9999)
*-------------------------------------------------------------------------
*- Note Pag. 3
*-------------------------------------------------------------------------
@ 2 , 2 GET aCon['oGet4'] ;
VAR aVar['cNota'] ;
OF aCon['oFol1']:aDialogs[03];
SIZE (aCon['oFol1']:aDialogs[03]:nWidth / 2 ) - 6 ,;
(aCon['oFol1']:aDialogs[03]:nHeight / 2 ) - 20 ;
PIXEL ;
FONT aCon['oFont3'] ;
MEMO ;
UPDATE
*-------------------------------------------------------------------------
*- Browse
*-------------------------------------------------------------------------
@ 394, 4 XBROWSE aCon['oBrw1'] ;
OF aCon['oDlg'] ;
SIZE aCon['oDlg']:nWidth - 8, 220 ;
PIXEL ;
AUTOCOLS ;
ALIAS {{"AAAA", "1111"}, {"BBBB", "2222"}, {"CCCC", "3333"}} ;
FONT aCon['oFont1'] ;
NOBORDER;
UPDATE
aCon['oBrw1']:nMarqueeStyle := MARQSTYLE_HIGHLWIN7
aCon['oBrw1']:CreateFromCode()
aCon['oDlg']:bInit := { || InitDialog( aCon['oDlg'] ) }
aCon['oDlg']:bResized := { || ResizeDialog( aCon['oDlg'] ) }
ACTIVATE DIALOG aCon['oDlg'] CENTERED
RELEASE FONT aCon['oFont1']
RELEASE FONT aCon['oFont2']
return NIL
*---------------------------------------------------------------------
function InitDialog( oDlg )
*---------------------------------------------------------------------
local oRect1 := oDlg:GetCliRect()
local oRect2
local nI1
local nI2
local nI3
local oCon1
local oCon2
local oPage
local oBrw
local oCol
local oBtn
SET MESSAGE OF oDlg TO "Test resize dialog dynamic" NOINSET CENTER 2010 FONT oDlg:oFont
for nI1 := 1 TO len(oDlg:aControls)
*---------------------------------------------------------
*- Store control dimension and position in perc. of Dialog
*---------------------------------------------------------
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
*---------------------------------------------------------
*- Store botton dimension and position in perc. inside Get
*---------------------------------------------------------
if oCon1:ClassName() $ "/TGET" .and. valtype(oCon1:oBtn) = "O"
oRect2 := oCon1:GetCliRect()
oBtn := oCon1:oBtn
oBtn:Cargo := hash()
oBtn:Cargo['%BTT'] := oBtn:nTop * 100 / oRect2:nTop
oBtn:Cargo['%BTL'] := oBtn:nLeft * 100 / oRect2:nRight
oBtn:Cargo['%BTW'] := oBtn:nWidth * 100 / oRect2:nWidth
oBtn:Cargo['%BTH'] := oBtn:nHeight * 100 / oRect2:nHeight
ENDIF
*------------------------------------------------------
*- Store columns dimension in perc. of Browse
*------------------------------------------------------
if oCon1:ClassName() $ "/TXBROWSE"
oBrw := oCon1
oRect2 := oBrw:GetCliRect()
FOR nI2 := 1 TO LEN(oBrw:aCols)
oCol := oBrw:aCols[nI2]
oCol:Cargo := hash()
oCol:Cargo['%CLW'] := oCol:nWidth * 100 / oRect2:nWidth
oCol:Cargo['%CLH'] := oCol:nCellHeight * 100 / oRect2:nHeight
NEXT
ENDIF
*---------------------------------------------------------
*- Store control dimension and position in perc. of folder
*---------------------------------------------------------
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 )
*---------------------------------------------------------------------
local oRect1 := oDlg:GetCliRect()
local oRect2
local oRect3
local nI1
local nI2
local nI3
local oCon1
local oCon2
local oPage
local oBrw
local oCol
local cFaceName
local oFontTmp
local oFontCon
local lBold
local lItalic
local lUnderline
local nWidthFont
local nHeightFont
local oBtn
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 botton dimension and position inside Get
*---------------------------------------------------------
if oCon1:ClassName() $ "/TGET" .and. valtype(oCon1:oBtn) = "O"
oRect2 := oCon1:GetCliRect()
oBtn := oCon1:oBtn
oRect3 := oBtn:GetCliRect()
oBtn:nTop := oRect2:nTop + PERC(oRect2:nHeight , oBtn:Cargo['%BTT'])
oBtn:nLeft := oRect2:nLeft + PERC(oRect2:nWidth, oBtn:Cargo['%BTL'])
oBtn:nHeight := PERC(oRect2:nHeight , oBtn:Cargo['%BTH'])
oBtn:nWidth := PERC(oRect2:nWidth , oBtn:Cargo['%BTW'])
ENDIF
*------------------------------------------------------
*- Resize columns in browse
*------------------------------------------------------
if oCon1:ClassName() $ "/TXBROWSE"
oBrw := oCon1
oRect2 := oBrw:GetCliRect()
FOR nI2 := 1 TO LEN(oBrw:aCols)
oCol := oBrw:aCols[nI2]
oCol:nWidth := PERC(oRect2:nWidth , oCol:Cargo['%CLW'])
oCol:nCellHeight := PERC(oRect2:nHeight , oCol:Cargo['%CLH'])
NEXT
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]
oRect2 := oPage:GetCliRect()
FOR nI3 := 1 TO LEN(oPage:aControls)
oCon2 := oPage:aControls[nI3]
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 Zoom (cAzi, oDlg, nIncr)
*---------------------------------------------------------------------
local nNewWidth
local nNewHeight
local nMaxWidth := GETSYSMETRICS(0)
local nMaxHeight := GETSYSMETRICS(1) - GETSYSMETRICS( 4 ) - 20
local nMinWidth := 800
local nMinHeight := 600
local nNewTop
local nNewLeft
DEFAULT nIncr := 2
DEFAULT cAzi := "+"
IF cAzi = "+"
nNewWidth := oDlg:nWidth + PERC(oDlg:nWidth , nIncr)
nNewHeight := oDlg:nHeight + PERC(oDlg:nHeight , nIncr)
IF nNewWidth > nMaxWidth
nNewWidth := nMaxWidth
nNewHeight := nMaxHeight
ENDIF
IF nNewHeight > nMaxHeight
nNewWidth := nMaxWidth
nNewHeight := nMaxHeight
ENDIF
ELSE
nNewWidth := oDlg:nWidth - PERC(oDlg:nWidth , nIncr)
nNewHeight := oDlg:nHeight - PERC(oDlg:nHeight , nIncr)
IF nNewWidth < nMinWidth
nNewWidth := nMinWidth
nNewHeight := nMinHeight
ENDIF
IF nNewHeight < nMinHeight
nNewWidth := nMinWidth
nNewHeight := nMinHeight
ENDIF
ENDIF
oDlg:nWidth := nNewWidth
oDlg:nHeight := nNewHeight
IF oDlg:lCentered
nNewLeft := (GETSYSMETRICS(0) - oDlg:nWidth) / 2
nNewTop := (GETSYSMETRICS(1) - oDlg:nHeight) / 2
oDlg:Move(nNewTop, nNewLeft, oDlg:nWidth, oDlg:nHeight, .F.)
ENDIF
return NIL
*---------------------------------------------------------------------
function Perc (nVal, nPrc)
*---------------------------------------------------------------------
return( nVal * nPrc / 100 )
TIA