DateTimePicker wierdness

G

Guest

I'm trying to use the OpenNETCF DateTimePicker in NETCF 1, but it appears
that the underlying SysDateTimePick32 control is doing some strange stuff
with the focus.

When the SysDateTimePick32 has focus, and you press the left/right hardware
buttons, focus moves between the M/D/Y fields. Up/down adjust the field
values. The control won't relinquish the focus.

This differs from the behavior of SysDateTimePick32 in the PoomManager SDK
sample, which is C++/Win32 code. In that sample, when focus in on the
first/last field, the left/right buttons gives focus to the previous/next
control. PoomManager doesn't appear to do anything special.

I realize that in OpenNETCF the SysDateTimePick32 control is a child of a
message window, so I tried creating a couple of sibling Edit controls. I used
spy to make sure they were before/after SysDateTimePick32 in the z-order and
all the style bits were identical to the PoomManager controls, but
SysDateTimePick32 continues to hog the focus.

As an experiment, I also tried calling Win32Window.SetParent to make the
SysDateTimePick32 control a child of my NETCF form. It still behaved the same
way.

My app runs on SmartPhone devices as well as PocketPC, so this behavior
makes the DateTimePicker unusable. Any clues would be greatly appreciated.
 
P

Peter Foot [MVP]

There are a lot of limitations due to the way the control is hosted and that
you can't override the WndProc in .NETCF v1.0 to capture the up and down
keys to pass on focus. It makes the control next to useless on a smartphone
particularly, on Pocket PC it is less of an issue because you can tap on
other controls to change the focus.

Peter
 
G

Guest

I was afraid of that, but thanks for the hint!

I ended up subclassing the native control (in native code) and intercepting
up/down as you suggested, then calling GetNextDlgTabItem/SetFocus. I've lost
the ability to scroll the date, but it's better than nothing.

I just noticed another problem with this: when the native control has focus,
the back button causes strange result. It either selects the first control on
the form, dismisses the form completely, or activates the Home screen
(pressing Back again returns to my form).

I overrode all the OnKey methods in my form and in DateTimePicker. Neither
sees the back button. In my SysDateTimePick32 subclass, a WM_KEYUP is
received with VK_ESCAPE, but eating it doesn't stop the form form acting up.

Is there some trick to intercepting/handling the Back button?

Thanks!
--
David


Peter Foot said:
There are a lot of limitations due to the way the control is hosted and that
you can't override the WndProc in .NETCF v1.0 to capture the up and down
keys to pass on focus. It makes the control next to useless on a smartphone
particularly, on Pocket PC it is less of an issue because you can tap on
other controls to change the focus.

Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top