[futurebasic] Re: [FB] Date Format Set and Get

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : March 2011 : Group Archive : Group : All Groups

From: Brian S <fblistserve@...>
Date: Wed, 16 Mar 2011 14:15:58 -0700
On Mar 16, 2011, at 12:56 PM, Peter wrote:

> Heres what I've got so far, SetControlClockDate doesn't work, what needs to be added?
> 

This is Q&D but should work.

'--------------

local fn GetControlClockDate ( c as ControlRef, outDate as ^LongDateRec )
'~'1
dim as SInt32           buf
dim as LongDateRec      controlLongDate
dim as OSStatus         err

long if fn GetControlDataSize( c, _kControlEditTextPart, _kControlClockLongDateTag, buf ) == _noErr
err = fn GetControlData( c, _kControlEditTextPart, _kControlClockLongDateTag, sizeof(LongDateRec), @controlLongDate, buf )
if ( err == _noErr ) then BlockMoveData( @controlLongDate, outDate, sizeof(LongDateRec) ) // send data back to caller
end if
end fn

local fn SetControlClockDateDay ( c as ControlRef, d as ^LongDateRec )
'~'1
dim as OSStatus           err
dim as LongDateRec        cDate

fn GetControlClockDate ( c, @cDate )
cDate.ld.day       = d.ld.day  
cDate.ld.month     = d.ld.month
cDate.ld.year      = d.ld.year 
err = fn SetControlData( c, _kControlEntireControl, _kControlClockLongDateTag, SizeOf( LongDateRec ), @cDate )
Draw1Control( c )// force update of date field

end fn

dim as Rect               r
dim as LongDateRec        cDate

appearance window -1,"Show Date Control"

SetRect( r, 208, 146, 320, 166 )
appearance button 1,, _kControlClockNoFlags,,,, @r, _kControlClockDateProc

window 1

fn GetControlClockDate ( button&( 1 ), @cDate )
print "month = ";cDate.ld.month 
print "day = ";cDate.ld.day
print "Year = ";cDate.ld.year

cDate.ld.day       = 5  
cDate.ld.month     = 11
cDate.ld.year      = 1993 


fn SetControlClockDateDay ( button&( 1 ),@cDate )

RunApplicationEventLoop()
'--------------

Brian S