Code: Select all | Expand
function TabletCalc( nNumber, oControl)
Local oDialogo,lSalida
Local aBtnCalc[30]
Local oCursor :=TCursor():New(,'HAND')
Local cNumber
Local oNumber
Local nValue := 0
Local cOperacion := ""
Local n,nRow:=18,nCol:=2
Local nValueMemory:=0
Local nBtnSizeW:=30
Local nBtnSizeH:=20
Local oFontGet := TFont():New( "Segoe UI", 0, ( 18 ), .f., .t. )
Local oFontDlg := TFont():New( "Segoe UI", 0, ( 18 ), .f., .t. )
Local cTitle := "Tablet Calc"
Local nBottom := 19
Local nRight := 5
Local nWidth := Max( nRight * DLG_CHARPIX_W, 155 )
Local nHeight := nBottom * DLG_CHARPIX_H
local nMINWidth := 328
local nMINHeight := 370
local nMAXWidth := GETSYSMETRICS( 0 ) //risoluzione orizzontale
local nMAXHeight := GETSYSMETRICS( 1 ) //risoluzione verticale
local cPastMsg := fwstring("&Copia") //"&Paste"
local cAbortMsg := fwstring("&Annulla") //"&Cancel"
CurrentHeight := 0 //not modify
FV := 1 //not modify
lSalida := FALSE
DEFAULT nNumber := 0
cNumber := Ltrim( Str( nNumber, 20 ) )
DEFINE DIALOG oDialogo SIZE nWidth, nHeight;
TRANSPARENT PIXEL;
TITLE cTitle FONT oFontDlg
oDialogo:nStyle := nOr( WS_OVERLAPPED,WS_THICKFRAME,WS_SYSMENU,WS_MAXIMIZEBOX, 0 )
@ nRow,nCol BTNBMP aBtnCalc[26] PROMPT "MC" SIZE nBtnSizeW,nBtnSizeH OF oDialogo PIXEL ACTION (KeyCal("MC", @cNumber, oNumber, @cOperacion, @nValue,@nValueMemory )) NOBORDER
nCol+=nBtnSizeW+1
@ nRow,nCol BTNBMP aBtnCalc[27] PROMPT "MR" SIZE nBtnSizeW,nBtnSizeH OF oDialogo PIXEL ACTION (KeyCal("MR", @cNumber, oNumber, @cOperacion, @nValue,@nValueMemory )) NOBORDER
nCol+=nBtnSizeW+1
@ nRow,nCol BTNBMP aBtnCalc[28] PROMPT "MS" SIZE nBtnSizeW,nBtnSizeH OF oDialogo PIXEL ACTION (KeyCal("MS", @cNumber, oNumber, @cOperacion, @nValue,@nValueMemory )) NOBORDER
nCol+=nBtnSizeW+1
@ nRow,nCol BTNBMP aBtnCalc[29] PROMPT "M+" SIZE nBtnSizeW,nBtnSizeH OF oDialogo PIXEL ACTION (KeyCal("M+", @cNumber, oNumber, @cOperacion, @nValue,@nValueMemory )) NOBORDER
nCol+=nBtnSizeW+1
@ nRow,nCol BTNBMP aBtnCalc[30] PROMPT "M-" SIZE nBtnSizeW,nBtnSizeH OF oDialogo PIXEL ACTION (KeyCal("M-", @cNumber, oNumber, @cOperacion, @nValue,@nValueMemory )) NOBORDER
nRow+=nBtnSizeH+1
nCol:=2
@ nRow,nCol BTNBMP aBtnCalc[1] PROMPT "Back" SIZE nBtnSizeW,nBtnSizeH OF oDialogo PIXEL ACTION (KeyCal("<", @cNumber, oNumber, @cOperacion, @nValue,@nValueMemory )) NOBORDER
nCol+=nBtnSizeW+1
@ nRow,nCol BTNBMP aBtnCalc[2] PROMPT "CE" SIZE nBtnSizeW,nBtnSizeH OF oDialogo PIXEL ACTION (KeyCal("CE", @cNumber, oNumber, @cOperacion, @nValue,@nValueMemory )) NOBORDER
nCol+=nBtnSizeW+1
@ nRow,nCol BTNBMP aBtnCalc[3] PROMPT "C" SIZE nBtnSizeW,nBtnSizeH OF oDialogo PIXEL ACTION (KeyCal("C", @cNumber, oNumber, @cOperacion, @nValue,@nValueMemory )) NOBORDER
nCol+=nBtnSizeW+1
@ nRow,nCol BTNBMP aBtnCalc[4] PROMPT "+/-" SIZE nBtnSizeW,nBtnSizeH OF oDialogo PIXEL ACTION (KeyCal("S", @cNumber, oNumber, @cOperacion, @nValue,@nValueMemory )) NOBORDER
nCol+=nBtnSizeW+1
@ nRow,nCol BTNBMP aBtnCalc[5] PROMPT "Sqrt" SIZE nBtnSizeW,nBtnSizeH OF oDialogo PIXEL ACTION (KeyCal("R", @cNumber, oNumber, @cOperacion, @nValue,@nValueMemory )) NOBORDER
nRow+=nBtnSizeH+1
nCol:=2
@ nRow,nCol BTNBMP aBtnCalc[6] PROMPT "7" SIZE nBtnSizeW,nBtnSizeH OF oDialogo PIXEL ACTION (KeyCal("7", @cNumber, oNumber, @cOperacion, @nValue,@nValueMemory )) NOBORDER
nCol+=nBtnSizeW+1
@ nRow,nCol BTNBMP aBtnCalc[7] PROMPT "8" SIZE nBtnSizeW,nBtnSizeH OF oDialogo PIXEL ACTION (KeyCal("8", @cNumber, oNumber, @cOperacion, @nValue,@nValueMemory )) NOBORDER
nCol+=nBtnSizeW+1
@ nRow,nCol BTNBMP aBtnCalc[8] PROMPT "9" SIZE nBtnSizeW,nBtnSizeH OF oDialogo PIXEL ACTION (KeyCal("9", @cNumber, oNumber, @cOperacion, @nValue,@nValueMemory )) NOBORDER
nCol+=nBtnSizeW+1
@ nRow,nCol BTNBMP aBtnCalc[9] PROMPT "/" SIZE nBtnSizeW,nBtnSizeH OF oDialogo PIXEL ACTION KeyCal("/", @cNumber, oNumber, @cOperacion, @nValue,@nValueMemory ) NOBORDER
nCol+=nBtnSizeW+1
@ nRow,nCol BTNBMP aBtnCalc[10] PROMPT "%" SIZE nBtnSizeW,nBtnSizeH OF oDialogo PIXEL ACTION KeyCal("%", @cNumber, oNumber, @cOperacion, @nValue,@nValueMemory ) NOBORDER
nRow+=nBtnSizeH+1
nCol:=2
@ nRow,nCol BTNBMP aBtnCalc[11] PROMPT "4" SIZE nBtnSizeW,nBtnSizeH OF oDialogo PIXEL ACTION (KeyCal("4", @cNumber, oNumber, @cOperacion, @nValue,@nValueMemory )) NOBORDER
nCol+=nBtnSizeW+1
@ nRow,nCol BTNBMP aBtnCalc[12] PROMPT "5" SIZE nBtnSizeW,nBtnSizeH OF oDialogo PIXEL ACTION (KeyCal("5", @cNumber, oNumber, @cOperacion, @nValue,@nValueMemory )) NOBORDER
nCol+=nBtnSizeW+1
@ nRow,nCol BTNBMP aBtnCalc[13] PROMPT "6" SIZE nBtnSizeW,nBtnSizeH OF oDialogo PIXEL ACTION (KeyCal("6", @cNumber, oNumber, @cOperacion, @nValue,@nValueMemory )) NOBORDER
nCol+=nBtnSizeW+1
@ nRow,nCol BTNBMP aBtnCalc[14] PROMPT "*" SIZE nBtnSizeW,nBtnSizeH OF oDialogo PIXEL ACTION KeyCal("*", @cNumber, oNumber, @cOperacion, @nValue,@nValueMemory ) NOBORDER
nCol+=nBtnSizeW+1
@ nRow,nCol BTNBMP aBtnCalc[15] PROMPT "1/x" SIZE nBtnSizeW,nBtnSizeH OF oDialogo PIXEL ACTION KeyCal("X", @cNumber, oNumber, @cOperacion, @nValue,@nValueMemory ) NOBORDER
nRow+=nBtnSizeH+1
nCol:=2
@ nRow,nCol BTNBMP aBtnCalc[16] PROMPT "1" SIZE nBtnSizeW,nBtnSizeH OF oDialogo PIXEL ACTION (KeyCal("1", @cNumber, oNumber, @cOperacion, @nValue,@nValueMemory )) NOBORDER
nCol+=nBtnSizeW+1
@ nRow,nCol BTNBMP aBtnCalc[17] PROMPT "2" SIZE nBtnSizeW,nBtnSizeH OF oDialogo PIXEL ACTION (KeyCal("2", @cNumber, oNumber, @cOperacion, @nValue,@nValueMemory )) NOBORDER
nCol+=nBtnSizeW+1
@ nRow,nCol BTNBMP aBtnCalc[18] PROMPT "3" SIZE nBtnSizeW,nBtnSizeH OF oDialogo PIXEL ACTION (KeyCal("3", @cNumber, oNumber, @cOperacion, @nValue,@nValueMemory )) NOBORDER
nCol+=nBtnSizeW+1
@ nRow,nCol BTNBMP aBtnCalc[19] PROMPT "-" SIZE nBtnSizeW,nBtnSizeH OF oDialogo PIXEL ACTION (KeyCal("-", @cNumber, oNumber, @cOperacion, @nValue,@nValueMemory )) NOBORDER
nCol+=nBtnSizeW+1
@ nRow,nCol BTNBMP aBtnCalc[20] PROMPT "=" SIZE nBtnSizeW,nBtnSizeH+nBtnSizeH+1 OF oDialogo PIXEL ACTION (KeyCal("=", @cNumber, oNumber, @cOperacion, @nValue,@nValueMemory )) NOBORDER
nRow+=nBtnSizeH+1
nCol:=2
@ nRow,nCol BTNBMP aBtnCalc[21] PROMPT "0" SIZE nBtnSizeW+nBtnSizeW+1,nBtnSizeH OF oDialogo PIXEL ACTION (KeyCal("0", @cNumber, oNumber, @cOperacion,@nValue,@nValueMemory )) NOBORDER
nCol+=nBtnSizeW+nBtnSizeW+2
@ nRow,nCol BTNBMP aBtnCalc[22] PROMPT "," SIZE nBtnSizeW,nBtnSizeH OF oDialogo PIXEL ACTION (KeyCal(".", @cNumber, oNumber, @cOperacion, @nValue,@nValueMemory )) NOBORDER
nCol+=nBtnSizeW+1
@ nRow,nCol BTNBMP aBtnCalc[23] PROMPT "+" SIZE nBtnSizeW,nBtnSizeH OF oDialogo PIXEL ACTION (KeyCal("+", @cNumber, oNumber, @cOperacion, @nValue,@nValueMemory)) NOBORDER
nRow+=nBtnSizeH+1
nCol:=2
@ nRow,nCol BTNBMP aBtnCalc[24] PROMPT cPastMsg SIZE (nBtnSizeW+nBtnSizeW+nBtnSizeW-16),nBtnSizeH OF oDialogo PIXEL ACTION (lSalida:=TRUE,oDialogo:End(IDOK)) NOBORDER
nCol+=nBtnSizeW+nBtnSizeW+nBtnSizeW-10
@ nRow,nCol BTNBMP aBtnCalc[25] PROMPT cAbortMsg SIZE (nBtnSizeW+nBtnSizeW+nBtnSizeW-16),nBtnSizeH OF oDialogo PIXEL ACTION (lSalida:=TRUE,oDialogo:End(IDCANCEL )) NOBORDER
@ 0.4,0 GET oNumber VAR cNumber SIZE oDialogo:nWidth-30,15 PIXEL OF oDialogo FONT oFontGet RIGHT
@ 2.5,oNumber:nWidth+10 SAY oSayMemory PROMPT space(6) SIZE 50,15 PIXEL OF oDialogo FONT oFontGet COLOR CLR_HBLUE
oDialogo:aMinMaxInfo = { GETSYSMETRICS( 0 ), GETSYSMETRICS( 1 ),; // xMaxSize, yMaxSize
0, 0,; // xMaxPosition, yMaxPosition
nMINWidth, nMINHeight,; // xMinTrackSize, yMinTrackSize
nMAXWidth, nMAXHeight }
oDialogo:bKeydown := { | nKey | KeyCal( nKey, @cNumber, oNumber, @cOperacion, @nValue,@nValueMemory ) }
* Rgb(219,225,32)
AEVAL( aBtnCalc, {| oBtn |oBtn:nClrText:= CLR_WHITE } )
AEVAL( aBtnCalc, {| oBtn |oBtn:nClrPane:=CLR_HGRAY } )
AEVAL( aBtnCalc, {| oBtn |oBtn:nLayOut:= 0 } )
AEVAL( aBtnCalc, {| oBtn |oBtn:oCursor:= oCursor } )
aBtnCalc[2]:nClrPane:= CLR_HRED
aBtnCalc[3]:nClrPane:= CLR_HRED
aBtnCalc[24]:nClrPane:= CLR_HGREEN
oDialogo:lHelpIcon:= .F.
oDialogo:bResized := {|| ( ResizeControlsKey(oDialogo , @aCoordinates ,;
@FV , @StartWidth , @StartHeight , @CurrentHeight), ;
AEVAL( aBtnCalc, {| oBtn | oBtn:refresh() } ) )}
ACTIVATE DIALOG oDialogo CENTERED ;
ON PAINT oNumber:SetFocus() ;
ON INIT (oNumber:SelectAll(), ;
ResizeControlsKey(oDialogo , @aCoordinates ,;
@FV , @StartWidth , @StartHeight , @CurrentHeight), ;
AEVAL( aBtnCalc, {| oBtn | oBtn:refresh() } ) ) ;
VALID lSalida
IF lSalida
IF oDialogo:nresult == IDOK
IF oControl:CLASSNAME()="TGET"
TIPVAR:=oControl:VarGet()
IF VALTYPE(TIPVAR)="N"
oControl:VarPut(Val( cNumber ) )
ELSEIF ValType(TIPVAR)="C"
oControl:VarPut( str(Val( cNumber),10,2) )
ENDIF
oControl:Refresh()
ENDIF
ELSE
ENDIF
AEVAL( aBtnCalc, {| oBtn | oBtn:End() } )
aBtnCalc:= NIL
oCursor:End()
RELEASE oFontDlg
RELEASE oFontGet
ENDIF
RETURN NIL
//--------------------------------------------------------------------------------------------------------------//
FUNCTION KeyCal( cKey, cNumber, oNumber, cOperacion, nValue,nValueMemory )
RETURN NIL
//--------------------------------------------------------------------------------------------------------------//
Code: Select all | Expand
STATIC FUNCTION ResizeControlsKey(oWnd , aCoordinates ,FV , StartWidth , StartHeight , CurrentHeight)
/*# ifndef TEST
STATIC aCoordinates := {} , FV
STATIC StartWidth , StartHeight
STATIC CurrentHeight
# endif
*/
LOCAL i , aHlp[5] , F := Hash()
LOCAL oCtl
LOCAL NewFontH , oFont , cFaceName , lNewFont := .F.
*# ifndef TEST
IF EMPTY( aCoordinates )
FOR EACH oCtl IN oWnd:aControls
AADD(aCoordinates , Array(5))
i := Hb_EnumIndex()
aCoordinates[i,1] := oCtl:nTop
aCoordinates[i,2] := oCtl:nLeft
aCoordinates[i,3] := oCtl:nWidth()
aCoordinates[i,4] := oCtl:nHeight()
aCoordinates[i,5] := oCtl:oFont:nHeight
NEXT
StartWidth :=oWnd:nWidth()
StartHeight := oWnd:nHeight()
FV := 1
lFont := .F.
CurrentHeight := 0
ENDIF
*# else
*IF aCoordinates == nil
* SetValues(@aCoordinates , @StartWidth , @StartHeight , oWnd)
*END
*# endif
F["H"] := oWnd:nWidth()/StartWidth // horizontal
F["V"] := oWnd:nHeight()/StartHeight // vertical
IF F["V"] <> FV
IF ABS(ROUND(( F["V"] - 1 )*100 ,2 ) - CurrentHeight) > 5// 10
lNewFont := .T.
IF F["V"] > FV
CurrentHeight += 5//10
ELSEIF F["V"] < FV
CurrentHeight -= 5//10
END
ENDIF
ENDIF
FOR EACH oCtl IN oWnd:aControls
i := Hb_EnumIndex()
aHlp[1] := aCoordinates[i,1]*F["V"] // nTop
aHlp[2] := aCoordinates[i,2]*F["H"] // nLeft
aHlp[3] := aCoordinates[i,3]*F["H"] // nWidth
aHlp[4] := aCoordinates[i,4]*F["V"] // nHeight
oCtl:Move( aHlp[1] , aHlp[2] , aHlp[3] , aHlp[4] , .T. )
IF lNewFont
NewFontH := ROUND(aCoordinates[i,5]*F["V"],0)
oFont := oCtl:oFont
cFaceName := oFont:cFaceName
oFont:end()
oFont := TFont():New( cFaceName, 0, ( -NewFontH ), .f., .t. )
oCtl:SetFont(ofont)
oCtl:refresh()
END
NEXT
FV := F["V"]
RETURN
//------------------------------------------------------------------------------------------------------------------//
PROC SetValues(aCoordinates , StartWidth , StartHeight , oWnd)
//------------------------------------------------------------------------------------------------------------------//
LOCAL oCtl , i
aCoordinates := {}
? "setval"
FOR EACH oCtl IN oWnd:aControls
AADD(aCoordinates , Array(5))
i := Hb_EnumIndex()
aCoordinates[i,1] := oCtl:nTop
aCoordinates[i,2] := oCtl:nLeft
aCoordinates[i,3] := oCtl:nWidth()
aCoordinates[i,4] := oCtl:nHeight()
aCoordinates[i,5] := oCtl:oFont:nHeight
NEXT
StartWidth := oWnd:nWidth()
StartHeight := oWnd:nHeight()
RETURN
I hace calculator, keyboard and other function ( utility) on my application use these function of Demont it resize all controls and also the text into, now it's no possible why ?