How can I set DateGadget to 19.11.1967 and let it editable

Just starting out? Need help? Post your questions and find answers here.
guruk
User
User
Posts: 50
Joined: Thu Aug 18, 2005 2:05 pm

How can I set DateGadget to 19.11.1967 and let it editable

Post by guruk »

Really, I do not understand this DateGadget... only from 1971.. but inside I can scroll through much deeper. So I only like to set a Date.
for eg. 19.11.1967 Save it as String to my database and then fill the Gadget again later... but so that I can still update it only the Way the DateGadget is for.

When I tried with SetGadgetText.. it putted the Text, but was not more editable.. and when I do with SetGadgetState.. than no year under 1970 possible?!?!

Please help
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post by Sparkie »

The native PB date library can only handle dates from 1970 to 2034. For Windows apps, you can use the API to accomplish your task.

Code: Select all

#DTM_GETSYSTEMTIME = $1001 
#DTM_SETSYSTEMTIME = $1002 
#GDT_VALID = 0

Procedure.l SetDate(gadget, year, month, day, hour, minute, second) 
  sTime.SYSTEMTIME\wYear = year 
  sTime\wMonth = month 
  sTime\wDay = day 
  sTime\wHour = hour 
  sTime\wMinute = minute 
  sTime\wSecond = second 
  SystemTimeToFileTime_(sTime, @fTime.FILETIME) 
  FileTimeToSystemTime_(fTime, @sTime) 
  SendMessage_(GadgetID(gadget), #DTM_SETSYSTEMTIME, #GDT_VALID, sTime)
EndProcedure 

If OpenWindow(0, 0, 0, 220, 200, #PB_Window_SystemMenu | #PB_Window_ScreenCentered,"DateGadget < 1970") And CreateGadgetList(WindowID()) 
  DateGadget(0, 10, 10, 200, 20, "%dd.%mm.%yyyy",Date())
  ; --> Use SetDate procedure for setting dates < 1970
  SetDate(0, 1967, 11, 17, 0, 0, 0) 
  MessageRequester("Date as string is:", GetGadgetText(0))
  Repeat 
    event = WaitWindowEvent() 
  Until event = #PB_Event_CloseWindow 
EndIf 
End
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Post by DoubleDutch »

Here is the compliment to that (very handy) routine...

Code: Select all

Procedure GetDate(gadget,part=#PB_Date_Year)
	sTime.SYSTEMTIME
	SendMessage_(GadgetID(gadget),#DTM_GETSYSTEMTIME,#GDT_VALID,sTime)
	SystemTimeToFileTime_(sTime,@fTime.FILETIME) 
	FileTimeToSystemTime_(fTime,@sTime)
	Select part
		Case	#PB_Date_Day
			result=sTime\wDay
		Case	#PB_Date_Month
			result=sTime\wMonth
		Default
			result=sTime\wYear
	EndSelect
	ProcedureReturn result
EndProcedure
:)
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
Post Reply