I want to post here function, which can be an alternative for InputWindow.
I don't know, if this function will work in future version of HMG, but works OK in 3.0.20
Code: Select all
function OknoWprowadzaniaDanych
param cWindowTitle, aLabels, aInitialValues, aLengths, aInputMasks, aConvertToUpper, aJust, aResults
local nWysokosc, nSzerokosc, i
local xType , cNazwa , nMaxLength := NIL, lUpper, lLower
local lNumeric, lPassword := .f., uLostFocus := NIL, uGotFocus := NIL
local uChange := NIL, uEnter := NIL, lRight, HelpId := NIL
local lReadOnly := .f., lBold := .f., lItalic := .f., lUnderline := .f., lStrikeout := .f.
local field := NIL
local aBackColor := {255,255,255}
local aFontColor := {0,0,0}
local lInvisible := .f.
local lNotabstop := .f.
private nLiczbaPol
Private lOK := .f.
// aJust - contains values: 0 - for left align, 1 for right align
// function returns .T. when OK button is pressed, .F. when CANCEL
// return values are copied to aResults
nLiczbaPol := len(aLabels)
nSzerokosc := 300
for i:= 1 to nLiczbaPol
nSzerokosc := max(nSzerokosc, aLengths[i])
next i
nSzerokosc := min(800,nSzerokosc)
nWysokosc := 130 + 50*nLiczbaPol
nWysokosc := min(500,nWysokosc)
DEFINE WINDOW MOL_OknoWprowadzaniaDanych ;
ROW 0 ;
COL 0 ;
WIDTH min(800,nSzerokosc) ;
HEIGHT min(500,nWysokosc) ;
TITLE cWindowTitle ;
MODAL
for i:=1 to nLiczbaPol
cLbl := "Lbl_"+strzero(i,2);
@ 20+(i-1)*50 , 10 LABEL &cLbl ;
VALUE aLabels[i] ;
WIDTH 200 ;
HEIGHT 18 ;
FONT "Arial" SIZE 10 BOLD;
TRANSPARENT
xType := valtype(aInitialValues[i])
cNazwa :="T_"+strzero(i,2)
do case
case xType == "N"
nMaxLength := len(str(aInitialValues[i]))
case xType == "D"
nMaxLength := 8
otherwise
nMaxLength := len(hb_valtoExp(aInitialValues[i]))
endcase
lUpper := aConvertToUpper[i]
lLower := !lUpper
lNumeric := (xType = "N")
lPassword := .f.
uLostFocus := NIL
uGotFocus := NIL
uChange := NIL
uEnter := NIL
lright := aJust[i] == 1 // domyślnie numeryczne pola do prawej
HelpId := NIL
lReadOnly := .f.
lBold := .f.
lItalic := .f.
lUnderline := .f.
lStrikeout := .f.
field := NIL
aBackColor := {255,255,255}
aFontColor := {0,0,0}
lInvisible := .f.
lNotabstop := .f.
if len(aInputMasks[i]) > 0
if xType == "N"
_DefineMaskedTextBox ( cNazwa, "MOL_OknoWprowadzaniaDanych", 30, 38+(i-1)*50,aInputMasks[i],;
aLengths[i] , aInitialValues[i], "ARIAL CE", 12, "" ,;
uLostFocus, uGotFocus, uChange ,;
24 , uEnter , lRight ,;
helpid , "" ,lBold, lItalic, lUnderline, ;
lStrikeout , field , aBackColor , aFontColor ,;
lReadOnly, lInvisible , lNotabstop )
elseif xType == "C"
_DefineCharMaskTextBox ( cNazwa, "MOL_OknoWprowadzaniaDanych", 30, 38+(i-1)*50,aInputMasks[i],;
aLengths[i] , aInitialValues[i], "ARIAL CE", 12, "" ,;
uLostFocus, uGotFocus, uChange ,;
24 , uEnter , lRight ,;
helpid , lBold, lItalic, lUnderline, ;
lStrikeout , field , aBackColor , aFontColor ,;
.f., lReadOnly, lInvisible , lNotabstop )
endif
else
if xType == "D"
_DefineCharMaskTextBox ( cNazwa, "MOL_OknoWprowadzaniaDanych", 30, 38+(i-1)*50,"",;
aLengths[i] , aInitialValues[i], "ARIAL CE", 12, "" ,;
uLostFocus, uGotFocus, uChange ,;
24 , uEnter , lRight ,;
helpid , lBold, lItalic, lUnderline, ;
lStrikeout , field , aBackColor , aFontColor ,;
.t., lReadOnly, lInvisible , lNotabstop )
else
_DefineTextBox( cNazwa, "MOL_OknoWprowadzaniaDanych", 30, 38+(i-1)*50, aLengths[i], 24, ;
aInitialValues[i], "ARIAL CE", 12, "", nMaxLength, ;
lUpper, lLower, lNumeric, lPassword, ;
uLostFocus, uGotFocus, uChange , uEnter , lRight , ;
HelpId , lReadonly , lBold, lItalic, lUnderline, ;
lStrikeout , field , aBackColor , aFontColor , ;
lInvisible , lNotabstop )
endif
endif
next i
// PRZYCISKI
@ nWysokosc - 80, nSzerokosc/2 - 120 BUTTON P_OK ;
CAPTION "OK" ;
ACTION (AEval(aResults, { | cValue, nIndex| aResults[nIndex] := GetProperty("Mol_OknoWprowadzaniaDanych","T_"+strzero(nIndex,2),"value") } ,1, nLiczbaPol),;
lOK := .t. , MOL_OknoWprowadzaniaDanych.Release );
WIDTH 100 HEIGHT 28
@ nWysokosc - 80, nSzerokosc/2 + 20 BUTTON P_CANCEL ;
CAPTION "Anuluj" ;
ACTION {|| lOK := .f., Mol_OknoWprowadzaniaDanych.Release} ;
WIDTH 100 HEIGHT 28
END WINDOW
aResults := array(nLiczbaPol)
ON KEY ESCAPE OF MOL_OknoWprowadzaniaDanych ACTION (MOL_OknoWprowadzaniaDanych.Release , lOK := .f.)
center window MOL_OknoWprowadzaniaDanych
activate window MOL_OknoWprowadzaniaDanych
return lOK
Code: Select all
aRes := {}
lRet := OknoWprowadzaniaDanych("A little sample of new InputWindow",{"Customer Name ","Customer Address","Customer ID","any other numeric ID","Date of test"} , ;
{"name of customer for editing",space(40),space(10), 123, date() },;
{200,200,80,100,100},;
{ "","","P-999","9999",""},;
{.t.,.f.,.t.,.f.,.f.},;
{0,0,0,1,1},;
@aRes)