Does anyone have a Calendar (date-picker) example?

jgress

New Member
I'm basically looking for the front end, the basic date-picker. I can't find com objects on my computer through pro tools/view com objects and just need a simple program with a calendar on it where the user can select a date to get started. I have a lot to do on the back end, but I am struggling getting this basic part set up. Thank you!
 

TomBascom

Curmudgeon
You seem to be looking for some sort of Windows GUI solution so, old character UI loving dinosaur that I am, I'm not going to be very helpful with that part.

But if this is blocking your work on the back end I would defer the lipstick portion of things and just put a plain old date field on the screen. In the short term you can just enter dates directly. That will allow you to work on the back end independently of the eye candy. When you figure out how to make it pretty just update the boring (but reliable) date field.
 

jgress

New Member
Jean, That would probably be a big help but it is written in Turkish and I don't know how to translate it.
Thank you,
Jeff
 
If I'm not mistaken this is only a matter of translating the months, i.e. replace
["Ocak","Þubat","Mart","Nisan","Mayýs","Haziran","Temmuz","Aðustos","Eylül","Ekim","Kasým","Aralýk" ]
by the months in your language, e.g. "January","February",etc.
And for the rest AFAIK Turkey has the same calendar as everyone else ;)
 

Osborne

Active Member
If you want another option there are the .NET controls although need to be on a more recent version of Progress.

A very simple solution based on this posting - Question - Label Name in the button:
Code:
DEFINE VARIABLE hWin AS HANDLE NO-UNDO.
DEFINE VARIABLE MainForm AS Progress.Windows.Form NO-UNDO.
DEFINE VARIABLE oDateTimePicker AS System.Windows.Forms.DateTimePicker NO-UNDO.
DEFINE VARIABLE oMonthCalendar AS System.Windows.Forms.MonthCalendar NO-UNDO.
DEFINE VARIABLE WinContainer AS Progress.Windows.WindowContainer NO-UNDO.

DEFINE BUTTON b1 LABEL "Dates Selected" SIZE 20 BY 1.14.
DEFINE FRAME f1 b1 AT ROW 11 COL 2 WITH SIDE-LABELS THREE-D SIZE 80 BY 20.

CREATE WINDOW hWin ASSIGN
   WIDTH = 80
   HEIGHT = 20.
FRAME f1:PARENT = hWin.

ON CHOOSE OF b1 DO:
   MESSAGE DATE(oMonthCalendar:SelectionStart) SKIP oDateTimePicker:Value
           VIEW-AS ALERT-BOX.
END.

/* Create the .NET form. */
MainForm = NEW Progress.Windows.Form( ).
MainForm:Text = ".NET Date Selection Options".
MainForm:ClientSize = NEW System.Drawing.Size(hwin:WIDTH-PIXELS, hwin:HEIGHT-PIXELS).
MainForm:FormClosed:Subscribe( "Window_FormClosed" ).
MainForm:Show( ).

/* Create the .NET calendar. */
ASSIGN oMonthCalendar = NEW System.Windows.Forms.MonthCalendar()
       oMonthCalendar:Location = NEW System.Drawing.Point(2, 10)
       oMonthCalendar:Name = "MonthCalendar".
MainForm:Controls:Add(oMonthCalendar).

/* Create the .NET time picker */
ASSIGN oDateTimePicker = NEW System.Windows.Forms.DateTimePicker()
       oDateTimePicker:Location = NEW System.Drawing.Point(10,180)
       oDateTimePicker:Format = System.Windows.Forms.DateTimePickerFormat:Custom
       oDateTimePicker:CustomFormat = "ddd dd MMM yyyy"
       oDateTimePicker:Width = 130.
MainForm:Controls:Add(oDateTimePicker).

/* Create the WindowContainer, embedding the window into it. */
WinContainer = NEW Progress.Windows.WindowContainer( ).
WinContainer:Size = NEW System.Drawing.Size( hWin:WIDTH-PIXELS, hWin:HEIGHT-PIXELS ).
WinContainer:EmbeddedWindow = hWin.
WinContainer:Parent = MainForm.
WinContainer:Show( ).

/* Now make the window visible.
It will be realized inside the WindowContainer. */
hWin:VISIBLE = YES.
ENABLE ALL WITH FRAME f1.

WAIT-FOR System.Windows.Forms.Application:Run(MainForm).

/* Delete the embedded window after the main form closes. */
PROCEDURE Window_FormClosed:
   DEFINE INPUT PARAMETER sender AS System.Object.
   DEFINE INPUT PARAMETER e AS System.EventArgs.

   DELETE WIDGET hWin.
END PROCEDURE.
 

Osborne

Active Member
JGress, you have asked follow up questions to this using the conversations option which I cannot answer as it has been closed.

I am assuming that it has been closed because questions should be asked via the standard forum which is the way to do things. This allows others to give an input.

Your questions were:
The program you sent me with the calendar and dateTimePicker was great. I'm trying to do some other stuff with it and I'm trying to figure out two things. I don't know if you can help but these controls seem to be older controls and I still don't understand them completely. What I want to do is when someone clicks on a date I want to have a procedure that gets run that determines if they can take that day off as like a vacation day. I've written the code to have them look and make sure they have the time to take off and haven't already taken the date off and I have dates bolded that are available dates, but I can't catch that click event somehow.

The other thing is when they click the next month any dates that were bolded before are not bolded now. Should be as simple as running this procedure again that does the work of figuring out which days to bold. The problem is I don't know how to tell that the user has clicked the button to go to the next month yet when I come back the other dates that were previously bolded are still bolded. Not sure if that is good or bad LOL
I suppose the controls could be classed as older controls and there are likely newer/flashier ones available such as Telerik. The advantage with these are they are the standard .NET Windows controls and should be naturally available on all computers.

All the options available for these controls can be found here:


So for the MonthCalendar you have a date changed event and maybe this is the one to use - it may not be possible to detect that they have changed the month be viewed just the date clicked:


Create an internal procedure - or if a class a void method - and subscribe to it:
Code:
oMonthCalendar:DateChanged:Subscribe("Calendar_DateChanged").

PROCEDURE Calendar_DateChanged:
   DEFINE INPUT PARAMETER sender AS System.Object NO-UNDO.
   DEFINE INPUT PARAMETER e AS System.Windows.Forms.DateRangeEventArgs NO-UNDO.

   MESSAGE "The date was changed." VIEW-AS ALERT-BOX.
END PROCEDURE.
Hopefully this points you in the right direction.
 
Top