For instance, if you need to use it to assign a date to a job, and then assign a completed date, that is
finished on the same day. You can't, unless you first select another date first, and then that date.
The following code shows this problem. Click on Assigned and select any date. then click on Accept Date
and then click on Completed, and try clicking on the 'same' date on the CalendarGadget. It won't work!
Code: Select all
Enumeration
#Main_Window
EndEnumeration
Enumeration
#AssignedDateString
#CompletedDateString
#AssignedButton
#CompletedButton
#AcceptButton
#CloseButton
#WorkCalendar
#DateResultsString
#InfoText
EndEnumeration
Procedure OpenWindow_Main_Window()
If OpenWindow(#Main_Window, 1212, 96, 837, 322, Space(30)+"Attached Calendar Window Test",#PB_Window_SystemMenu|#PB_Window_TitleBar|#PB_Window_ScreenCentered)
CalendarGadget(#WorkCalendar , 640,20, 180, 155)
StringGadget(#AssignedDateString, 670, 190, 60, 20, "",#PB_String_ReadOnly)
StringGadget(#CompletedDateString, 750, 190, 60, 20, "",#PB_String_ReadOnly)
ButtonGadget(#AssignedButton, 668, 215, 65, 20, "Assigned")
ButtonGadget(#CompletedButton, 749, 215, 65, 20, "Completed")
ButtonGadget(#AcceptButton, 705, 241, 65, 30, "Accept Date", #PB_Button_MultiLine)
StringGadget(#DateResultsString, 670, 280, 145, 20, "Date Result:",#PB_String_ReadOnly)
ButtonGadget(#CloseButton, 368, 215, 65, 20, "Close")
TextGadget(#InfoText, 510, 217, 120, 100, "Click on either Button --> and then select date. Then Click on the Accept Button to Accept that dates input.")
EndIf
EndProcedure
OpenWindow_Main_Window()
ac=0 ;default
Repeat
Select WaitWindowEvent()
Case #PB_Event_Gadget
Select EventGadget()
Case #WorkCalendar
seldate=GetGadgetState(#WorkCalendar)
seldate$ = FormatDate("%mm/%dd/%yy", seldate)
If ac=1
SetGadgetText(#AssignedDateString,seldate$)
ElseIf ac=2
SetGadgetText(#CompletedDateString,seldate$)
EndIf
Case #AssignedButton
ac=1
DisableGadget(#AssignedButton, 1)
DisableGadget(#CompletedButton, 0)
SetGadgetText(#AssignedDateString,"")
SetGadgetColor(#AssignedDateString,#PB_Gadget_BackColor,$90FF90)
Case #CompletedButton
ac=2
DisableGadget(#CompletedButton, 1)
DisableGadget(#AssignedButton, 0)
SetGadgetText(#CompletedDateString,"")
SetGadgetColor(#CompletedDateString,#PB_Gadget_BackColor,$90FF90)
Case #AcceptButton
If ac=1
SetGadgetText(#DateResultsString,"Assigned Date = "+seldate$)
ElseIf ac=2
SetGadgetText(#DateResultsString,"Completed Date = "+seldate$)
EndIf
ac=0
DisableGadget(#AssignedButton, 0)
DisableGadget(#CompletedButton, 0)
SetGadgetColor(#AssignedDateString,#PB_Gadget_BackColor,-1)
SetGadgetColor(#CompletedDateString,#PB_Gadget_BackColor,-1)
Case #CloseButton
End
EndSelect
Case #PB_Event_CloseWindow
Select EventWindow()
Case #Main_Window
CloseWindow(#Main_Window)
Break
EndSelect
EndSelect
ForEver
re-open when ever I accept the date. This way the CalendarGadget gets reset each time, and I can select
the same date. I tried a method using StickyWindow(), and using a window coordinate approach to keep
the calendar window in it's place that worked well, except that the calendar window would always be on
top of any window placed over it. It didn't look good. The following method uses an unusual approach
using WindowChild and SetParent_ and ResizeWindow to do this with out the StickyWindow() problem.
The only complaint that I wish could be solved is that the main windows title bar flickers a little when ever
you use this method. I also could have just used the Accept and Completed buttons to do the job with out
the Accept button, but prefered using a visual Accept button in order to verify the date first before accepting
it. Explanation is in the code.
If you know a way to improve it -- Please -- add and post it here. That's how we learn.
Code: Select all
Enumeration
#Main_Window
#CalendarWin
EndEnumeration
Enumeration
#AssignedDateString
#CompletedDateString
#AssignedButton
#CompletedButton
#AcceptButton
#CloseButton
#WorkCalendar
#DateResultsString
#InfoText
EndEnumeration
Global WindowChild
Procedure OpenWindow_CalendarWin(calx,caly)
If OpenWindow(#CalendarWin, calx, caly, 180, 160, "", #PB_Window_BorderLess)
CalendarGadget(#WorkCalendar , 0, 5, 180, 155)
EndIf
EndProcedure
Procedure OpenWindow_Main_Window()
If OpenWindow(#Main_Window, 1212, 96, 837, 322, Space(30)+"Attached Calendar Window Test",#PB_Window_SystemMenu|#PB_Window_TitleBar|#PB_Window_ScreenCentered)
StringGadget(#AssignedDateString, 670, 190, 60, 20, "",#PB_String_ReadOnly)
StringGadget(#CompletedDateString, 750, 190, 60, 20, "",#PB_String_ReadOnly)
ButtonGadget(#AssignedButton, 668, 215, 65, 20, "Assigned")
ButtonGadget(#CompletedButton, 749, 215, 65, 20, "Completed")
ButtonGadget(#AcceptButton, 705, 241, 65, 30, "Accept Date", #PB_Button_MultiLine)
StringGadget(#DateResultsString, 670, 280, 145, 20, "Date Result:",#PB_String_ReadOnly)
ButtonGadget(#CloseButton, 368, 215, 65, 20, "Close")
TextGadget(#InfoText, 510, 217, 120, 100, "Click on either Button --> and then select date. Then Click on the Accept Button to Accept that dates input.")
EndIf
EndProcedure
OpenWindow_Main_Window()
OpenWindow_CalendarWin(-180,20);create off screen
WindowChild = WindowID(#CalendarWin)
SetParent_(WindowID(#CalendarWin), WindowID(#Main_Window));put on Main Window
ResizeWindow(#CalendarWin, 640, 20, #PB_Ignore , #PB_Ignore );resize to the place you want it.
ac=0 ;default
Repeat
Select WaitWindowEvent()
Case #PB_Event_Gadget
Select EventGadget()
Case #WorkCalendar
seldate=GetGadgetState(#WorkCalendar)
seldate$ = FormatDate("%mm/%dd/%yy", seldate)
If ac=1
SetGadgetText(#AssignedDateString,seldate$)
ElseIf ac=2
SetGadgetText(#CompletedDateString,seldate$)
EndIf
Case #AssignedButton
ac=1
DisableGadget(#AssignedButton, 1)
DisableGadget(#CompletedButton, 0)
SetGadgetText(#AssignedDateString,"")
SetGadgetColor(#AssignedDateString,#PB_Gadget_BackColor,$90FF90)
Case #CompletedButton
ac=2
DisableGadget(#CompletedButton, 1)
DisableGadget(#AssignedButton, 0)
SetGadgetText(#CompletedDateString,"")
SetGadgetColor(#CompletedDateString,#PB_Gadget_BackColor,$90FF90)
Case #AcceptButton
If ac=1
SetGadgetText(#DateResultsString,"Assigned Date = "+seldate$)
ElseIf ac=2
SetGadgetText(#DateResultsString,"Completed Date = "+seldate$)
EndIf
ac=0
DisableGadget(#AssignedButton, 0)
DisableGadget(#CompletedButton, 0)
SetGadgetColor(#AssignedDateString,#PB_Gadget_BackColor,-1)
SetGadgetColor(#CompletedDateString,#PB_Gadget_BackColor,-1)
If IsWindow(#CalendarWin)
CloseWindow(#CalendarWin);Reset the CalendarGadget by closing and re-openning the window.
EndIf
OpenWindow_CalendarWin(-180,20);create off screen
SetParent_(WindowID(#CalendarWin), WindowID(#Main_Window));put on Main Window
ResizeWindow(#CalendarWin, 640, 20, #PB_Ignore , #PB_Ignore );resize to the place you want it.
Case #CloseButton
End
EndSelect
Case #PB_Event_CloseWindow
Select EventWindow()
Case #Main_Window
CloseWindow(#Main_Window)
Break
EndSelect
EndSelect
ForEver