VisualHint
Thu May 31 16:17:46 CDT 2007
In the DropDown event handler:
hMonthCalendar = (IntPtr)SendMessage(dateTimePicker.Handle, 0x1008 /
*DTM_GETMONTHCAL*/, 0, 0);
You will find on CodeProject several articles about hooks. Here is
one:
http://www.codeproject.com/csharp/globalhook.asp (don't know if
it's the best).
Best regards,
Nicolas Cadilhac @ VisualHint (
http://www.visualhint.com)
Home of Smart FieldPackEditor.Net / DateTimePicker replacement
Home of Smart PropertyGrid for .Net and MFC
Microsoft PropertyGrid Resource List -
http://www.propertygridresourcelist.com
On May 31, 4:32 pm, mahesh.nimbal...@gmail.com wrote:
> Al right. Can you please post some code sample how to hook key pressed
> event for this DateTimePicker control?
>
> On May 31, 4:12 pm, VisualHint <cadil...@gmail.com> wrote:
>
> > What you want to do is not so easy and maybe you should rethink the
> > way you do it (showing the datetimepicker opened initially is not very
> > intuitive and consistent with the OS after all). In Smart PropertyGrid
> > I was using the MS DateTimePicker and I gave up because I was not able
> > to achieve the same level of quality and usability than the other
> > editors. At the end, I had reached a point where I had some message,
> > keyboard and mouse hooks on the calendar popup and even then there was
> > always something not satisfying. This has been the trigger to start a
> > complete DateTimePicker replacement and I think this will be a real
> > success.
>
> > If you still want to go on this path, try to get the handle of the
> > calendar and hook various messages so that you know what happens with
> > the user interaction.
>
> > Best regards,
>
> > Nicolas Cadilhac @ VisualHint (
http://www.visualhint.com)
> > Home of Smart FieldPackEditor.Net / DateTimePicker replacement
> > Home of Smart PropertyGrid for .Net and MFC
> > Microsoft PropertyGrid Resource List -
http://www.propertygridresourcelist.com
>
> > On May 31, 3:26 pm, mahesh.nimbal...@gmail.com wrote:
>
> > > Yes it will work except one case and that is not acceptable. The case
> > > is, user can select whatever is the default date shown in the
> > > DateTimePicker control and here I will not come to know that user has
> > > actually selected a date and not pressed ESC key if I compare default
> > > date with currently selected date.
>
> > > On May 31, 2:56 pm, VisualHint <cadil...@gmail.com> wrote:
>
> > > > When showing the picker in open state, why don't you record the
> > > > initial date? When the CloseUp event occurs you would simply compare
> > > > the old date with the one returned by Value... Not enough?
>
> > > > Best regards,
>
> > > > Nicolas Cadilhac @ VisualHint (
http://www.visualhint.com)
> > > > Home of Smart FieldPackEditor.Net / DateTimePicker replacement
> > > > Home of Smart PropertyGrid for .Net and MFC
> > > > Microsoft PropertyGrid Resource List -
http://www.propertygridresourcelist.com
>
> > > > On May 31, 2:47 pm, mahesh.nimbal...@gmail.com wrote:
>
> > > > > On some event I am showing DateTimePicker control in open state. Now
> > > > > if users selected date, I would do some processing and user presses
> > > > > ESC, I would just ignore it.
>
> > > > > I main point here is that I just wanted to know whether user has
> > > > > selected any date or not. Because on that only I will be processing
> > > > > some data.
>
> > > > > I tried key press events also, but seems that if control is in open
> > > > > state, it will not fire any keyboard events.
>
> > > > > If you have any alternate solution to know if user has selected any
> > > > > date in control, please let me know. I am stuck now.
>
> > > > > Thanks!
>
> > > > > On May 31, 2:22 pm, VisualHint <cadil...@gmail.com> wrote:
>
> > > > > > Indeed youre right. I just tried it. In fact you are partially right.
> > > > > > Until I modify the displayed date, ValueChanged will be triggered even
> > > > > > if ESC is hit. After a change it's not trigerred anymore on ESC. But
> > > > > > anyway, if the user types the arrow keys to move the cue in the month
> > > > > > calendar, ValueChanged is triggered and hitting ESC after would not
> > > > > > help. At least this allows you to see how this native control is
> > > > > > illogical. I am fixing all these oddities in Smart FieldPackEditor.
>
> > > > > > Anyway, maybe you should do things differently. What is your exact
> > > > > > goal ? If you want to know that ESC has been pressed, why not try to
> > > > > > detect the fact that ESC is actually typed instead of relying on the
> > > > > > Value property which won't never be null anyway...
>
> > > > > > Best regards,
>
> > > > > > Nicolas Cadilhac @ VisualHint (
http://www.visualhint.com)
> > > > > > Home of Smart FieldPackEditor.Net / DateTimePicker replacement
> > > > > > Home of Smart PropertyGrid for .Net and MFC
> > > > > > Microsoft PropertyGrid Resource List -
http://www.propertygridresourcelist.com
>
> > > > > > On May 31, 1:24 pm, mahesh.nimbal...@gmail.com wrote:
>
> > > > > > > I already tried ValueChanged event. But the problem with that is when
> > > > > > > user opens DateTimePicker control and closes it by pressing escape,
> > > > > > > even in this case also ValueChanged event gets fired.
>
> > > > > > > On May 31, 1:20 pm, VisualHint <cadil...@gmail.com> wrote:
>
> > > > > > > > I'm not sure to understand what you mean.
> > > > > > > > As another poster added, when the user selects a date you will get a
> > > > > > > > ValueChanged event. When he hits ESC you won't. This should allow you
> > > > > > > > to discriminate both cases.
> > > > > > > > You have also the CloseUp event so that you know when the dropdown is
> > > > > > > > closed.
>
> > > > > > > > Best regards,
>
> > > > > > > > Nicolas Cadilhac @ VisualHint (
http://www.visualhint.com)
> > > > > > > > Home of Smart FieldPackEditor.Net / DateTimePicker replacement
> > > > > > > > Home of Smart PropertyGrid for .Net and MFC
> > > > > > > > Microsoft PropertyGrid Resource List -
http://www.propertygridresourcelist.com
>
> > > > > > > > On May 31, 11:21 am, mahesh.nimbal...@gmail.com wrote:
>
> > > > > > > > > Thanks for the reply.
>
> > > > > > > > > User can select what is shown in the control while displaying that
> > > > > > > > > control. So I can not come to know that whether you has selected the
> > > > > > > > > date or pressed escape key.
>
> > > > > > > > > Thanks
>
> > > > > > > > > On May 31, 10:24 am, VisualHint <cadil...@gmail.com> wrote:
>
> > > > > > > > > > Hello Mahesh,
>
> > > > > > > > > > If the user does not select a date and presses Esc, then you get the
> > > > > > > > > > current value (the one that was shown before showing the drop down
> > > > > > > > > > calendar) when you call Value. This is normal and what is expected.
>
> > > > > > > > > > Best regards,
>
> > > > > > > > > > Nicolas Cadilhac @ VisualHint (
http://www.visualhint.com)
> > > > > > > > > > Home of Smart FieldPackEditor.Net / DateTimePicker replacement
> > > > > > > > > > Home of Smart PropertyGrid for .Net and MFC
> > > > > > > > > > Microsoft PropertyGrid Resource List -
http://www.propertygridresourcelist.com
>
> > > > > > > > > > On May 31, 9:27 am, mahesh.nimbal...@gmail.com wrote:
>
> > > > > > > > > > > Hi,
>
> > > > > > > > > > > I haveDateTimePickercontrol on a winform. When user selects a date
> > > > > > > > > > > in that control, I am getting proper value usingDateTimePicker.Value.
> > > > > > > > > > > But I want to know in case user does not select any date and closesDateTimePickercontrol by pressing escape key. Here in this case also
> > > > > > > > > > > I am getting today's date even if user did not select any date in that
> > > > > > > > > > > control.
>
> > > > > > > > > > > I should get null or something else that will let me know that user
> > > > > > > > > > > did not select anything and closed theDateTimePickerby pressing
> > > > > > > > > > > escape key.
>
> > > > > > > > > > > Any idea how to do that?
>
> > > > > > > > > > > Thanks!