Page 1 of 1

Posted: Sat Jan 04, 2003 12:57 pm
by BackupUser
Restored from previous forum. Originally posted by Manolo.

If OpenWindow(0,100,150,450,200,#PB_Window_SystemMenu,"Test of Dates")
CreateGadgetList(WindowID())

hwnd1=StringGadget(1,125,8,80,24,"")
ButtonGadget(2,200,100,50,25,"Acept")
SendMessage_(hwnd1,197,10,0) ; 10 characters limit
ActivateGadget(1)

Repeat
event=WaitWindowEvent()

Select EventGadgetID()

Case 1
ActivateGadget(1)
Date$=GetGadgetText(1) ; Date for test
If Date$=""
Date$=FormatDate("%dd-%mm-%yyyy", Date())
SetGadgetText(1,Date$)
Else
If ParseDate("%dd-%mm-%yyyy", Date$)=-1
MessageRequester("Error","Invalid Date: "+Date$,0)
ActivateGadget(2)
EndIf
EndIf
Case 2
ActivateGadget(1)

EndSelect

Until event = #PB_EventCloseWindow
EndIf



Manolo

Posted: Sun Jan 05, 2003 10:12 pm
by BackupUser
Restored from previous forum. Originally posted by PB.

You may prefer to pick valid dates with something like this:

Code: Select all

; ------- Calendar Setup ------
#MCM_GETCURSEL=$1001
Structure INITCOMMONCONTROLSEX 
  dwSize.l
  dwICC.l
EndStructure
MyCal.INITCOMMONCONTROLSEX
MyCal\dwSize=8
MyCal\dwICC=$100
InitCommonControlsEx_(@MyCal)
; -----------------------------
;
OpenWindow(0,100,200,400,200,#PB_Window_SystemMenu|#PB_Window_SizeGadget,"Date Pick Example")
;
datepick=CreateWindowEx_(0,"SysDateTimePick32","DateTime",#WS_CHILD|#WS_VISIBLE|4,10,10,200,25,WindowID(),0,GetModuleHandle_(0),0)
;
Repeat 
  EventID=WaitWindowEvent()
  newdate$=Space(255) : GetWindowText_(datepick,newdate$,255)
  If newdate$prevdate$
    prevdate$=newdate$
    Debug "" : Debug "String = "+newdate$
    SendMessage_([url]mailto:datepick,#MCM_GETCURSEL,0,@time.SYSTEMTIME[/url])
    CalD=time\wDay : CalM=time\wMonth : CalY=time\wYear
    Debug "D, M, Y = "+Str(CalD)+", "+Str(CalM)+", "+Str(CalY)
  EndIf
Until EventID=#PB_EventCloseWindow

Posted: Sun Jan 05, 2003 11:09 pm
by BackupUser
Restored from previous forum. Originally posted by Andre.

Cool example, PB :)

Regards
André

*** German PureBasic Support ***

Posted: Sun Jan 05, 2003 11:12 pm
by BackupUser
Restored from previous forum. Originally posted by PB.

> Cool example, PB

Not all my code... I can't take all the credit. I basically took an
example from elsewhere here and modified it a bit to make extracting
the date string and days an easy task.