Click to See Complete Forum and Search --> : Custom DateTimePicker control


hshliang
July 21st, 1999, 10:52 PM
****************** A PROTOTYPE OF DATETIMEPICKER MADE FROM A COMBOBOX AND MONTHCALCTRL *********************

Platform: Visual C++ 6.0
Window 98




This is a trial form of a prototype for a combobox that drops a monthCalender Control to similate a DateTimePicker control.
The aim is to make a control that behaves like a DateTimePicker, but the programmer can subclass the Edit box for changes he/she likes.
It started when I want a DateTimePicker that can have a state of "ReadOnly" to match the other controls I have, mainly CEdit and CComboBox.
For the CEdit, it is easy, I use the SetReadOnly() the comes with CEdit, with CComboBox, it is also easy. Just subclass the Edit box protion of the combobox, either using GetDlgItem(1001) or get Child Window.
Unfortunately, it seems that the DateTimePicker has not edit box portion. So I was not able to make it "ReadOnly".
The reason I want "ReadOnly" is simple, I like the Black colored Text. I have seen a lot of people asking how to make the text black, then I know that a lot of people are like me that like the text to be easier to read.

So far, I was able to replace the CMonthCalCtrl with the listbox of the Combobox.
I tried very hard to make it functionally similar to the DateTimePicker, but without success.
The best I can do is like the current one, it can drop down by cliking down button or pressing alt-Downarrow.
There are some problem with closing the MonthCalCtrl after it has focus. The dialog has to gain focus first, then we can close it by clicking the downbutton.

I do not know how to solve it, I have even subclassed the CMonthCalCtrl (as a next step anyways) to try to pass the focus and manipulate the combobox, but not successful.

This program is workable, but if any one has any suggestion to improve the behaviour, please let me know at :
hshliang@hotmail.com

Please feel free to ditribute and modify, but let me know if you find a better solution.

My next step is to subclass the CMonthCalCtrl so it will response to selection and put the selected date to the edit box.
Then I will add formatting options to the CMonthCalCtrl.

Last I will make the edit box a masked edit box for entry of date format. And then I will have a DateTimecombo with assess to the Edit portion.

Thank you.