[futurebasic] Re: Date buttons

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : December 2001 : Group Archive : Group : All Groups

From: SVANVOORST@...
Date: Mon, 3 Dec 2001 17:46:00 EST
Pierre:

Based on Alain's recent post, the following demo will allow the user to 
change the date and then get the results:

'------- Begin FB^3 Code --------

Include "Tlbx Appearance.Incl"

dim err
dim wndPtr as pointer
dim dateResult as LongDateRec
dim cntrlH as handle
dim @actualSize as long
end globals

local
dim j,k
dim left%,top%
dim vg%,hg%
LOCAL FN efGrid(l%,t%,w%,h%,col%,row%,id%,type%)'Any size,location
vg% = 10 : hg% = 10
FOR k = 0 TO row%-1 'Build by row
FOR j = 0 TO col%-1
left% = l%+j*(w%+vg%)
top%  = t%+k*(h%+hg%)
Text _sysFont,12,0
EDIT FIELD#id%,"",(left%,top%)-(left%+w%,top%+h%),type%,_centerJust
INC(id%)
NEXT j
next k
edit field(0)
END Fn

local
dim dataTag
local fn doUpdate
dataTag = _kControlClockLongDateTag
err = fn 
GetControlData(cntrlH,0,dataTag,sizeof(LongDateRec),dateResult,actualSize)
edit$(1) = str$(dateResult.month%)
edit$(2) = str$(dateResult.day%)
edit$(3) = str$(dateResult.year%)
edit$(4) = str$(dateResult.dayOfWeek%)
edit$(5) = str$(dateResult.dayOfYear%)
edit$(6) = str$(dateResult.weekOfYear%)
end fn

local
dim cntrlRect as rect
dim btnType%
LOCAL FN buildWnd
WINDOW#1,"Click on Date",(0,0)-(220,250),_docNoGrow
fn efGrid(110,80,60,15,1,6,1,_statFramed)
wndPtr = WINDOW(_wndPointer) : if wndPtr = _nil then exit fn
err = FN 
SetThemeWindowBackground(wndPtr,_kThemeActiveDialogBackgroundBrush,_true)
fn efGrid(30,80,60,15,1,6,10,_statNoFramed)
button#1,_activeBtn,"Update",(130,30)-(190,50),_push
call setrect(cntrlRect,30,30,120,50)
btnType% = _kControlClockDateProc
cntrlH = fn newcontrol(wndPtr,cntrlRect,"",_true,0,0,0,btnType%,0)
edit$(10) = "Month"
edit$(11) = "Day"
edit$(12) = "Year"
edit$(13) = "DayOfWk"
edit$(14) = "DayOfYr"
edit$(15) = "WkOfYr"
fn doUpdate
END FN

local
dim evnt%
dim id%
dim x
LOCAL FN doDialog
evnt% = DIALOG(0)
id% = DIALOG(evnt)
SELECT evnt%
case _wndRefresh
for x = 1 to 6
err = fn drawthemeedittextframe(#[tehandle(x)],_true)
next
case _btnClick
select id%
case 1
fn doUpdate
end select
CASE _wndClose
END
END SELECT
END FN

FN buildWnd
ON DIALOG FN doDialog
DO
HANDLEEVENTS
UNTIL 0

'------- End of Code ------

Steve Van Voorst