|
ah, i see
well, i want to use the control in a project, where Stingray's Objective Grid is
already heavily used.
I have to show the Date-Text in the picker in another color and i have to draw the background of the picker in another color too.(not the calender, that would be too easy )
The Problem is, i cant replace the CDateTimeCtrl class (removed #include afxdtctl.h and replaced it with my "CDateTimeCtrl.h"), i get Linker Errors (NAFXCWD.LIB->WINCTRL5.CPP) like hell in VC6
So your way of handling that problem seemed the most effective to gain control over that ...grmbl#* DatePicker Great work, by the way!!!
The DTS_SHOWNONE style is used with Objective Grid, and the customer wants to see that control in exactly that way, it is displayed in the grids.....
|
|
|
|
|
Not sure why the standard one causes you problems, but my class simply uses a standard DateTime picker, and super-imposes an edit control. If my class works for you, then I would have thought you should be able to create you own override of CDateTimeCtrl, which just does nothing.
Alternatively, although I don't intend to fully implement DTS_SHOWNONE in the way that the standard control does (i.e. with the check box etc), you could remove the ASSERTs which fire when trying to use the style in my class.
"The way of a fool seems right to him, but a wise man listens to advice" - Proverbs 12:15 (NIV)
|
|
|
|
|
well, the standard one won't let me change the colors, thats just it
I tried to overwrite the CDateTimeCtrl of course, but that wont help, because i cant use it together with that "Objective Grid"... Plus, even if in a Testproject without the Grid, i cant change the
Textcolor in the Picker.
The checkbox is just wanted from the customerside, i for sure would not care, if i see that dumb checkbox hahaha I removed the asserts for DTS_SHOWNONE, but that did not help. And time is running out, so many other stuff todo...
But thanks for your patience man! :->
|
|
|
|
|
Thank for the great work. I need to catch the SETFOUS message, when tha edit is focused. Can you tell me how ?
Tank You.
Raffaele Eugenelo
|
|
|
|
|
To catch the control getting the focus, you can add a handler for NM_SETFOCUS to the control's parent.
(I noticed when trying this that while tabbing to the control generates this notification, clicking in the control does not. However, the behaviour in my control is exactly the same as in the standard control. If you want to catch a focus change caused by the mouse clicking in the edit control, you could try adding a WindowProc or DefWindowProc override to the CDateTimeEditCtrlEditCtrl class, and sending the WM_SETFOCUS to the parent.)
Paul.
"The way of a fool seems right to him, but a wise man listens to advice" - Proverbs 12:15 (NIV)
|
|
|
|
|
Thanks for an insightful article with great code!
Has anyone expanded on the DateTimePicker idea to include the editing of the time of day ?
Thanks, Fred
|
|
|
|
|
Thanks - it's good to know that people find it useful.
I have often thought that there should be a better way of editing time. What kind of support did you have in mind for that?
"The way of a fool seems right to him, but a wise man listens to advice" - Proverbs 12:15 (NIV)
|
|
|
|
|
Hi Paul,
I have seen various edit control projects that allow input according to a given format. The format "HH:MM" might show a CEdit with a fixed colon (':') sign at the 3rd char position and allows the input of two numbers before and after the colon.
Additionally features like cursor-up/down rotates numbers in the ranges 00 -> 23 or 00 -> 59 respectively. The caret jumps from the 2nd char to the 4th, thereby skipping the fixed colon sign.
Other format suggestions could be "hh/MM/SS", where hh means a 12 hour clock (as opposed to the big letter HH for a 24 hour clock), the fixed seperator chars are / for this format and seconds (00 -> 59) can also be entered.
I think classes for pattern input using a customized CEdit already exist. It would be cool to integrate such a control for time input.
Thanks,
Fred
|
|
|
|
|
Hello! If I try to type in something like that: 09.31 then an error appears.
|
|
|
|
|
Thanks for this great control.
Any plan to implement DTM_SETFORMAT for this control ?
We are waiting for that..!
Anand
|
|
|
|
|
I wasn't planning to implement DTM_SETFORMAT at all for my control, as I didn't think it would be necessary. I will have a look at the work involved, and perhaps implement it in a future update, though it probably won't be very soon.
"The way of a fool seems right to him, but a wise man listens to advice" - Proverbs 12:15 (NIV)
|
|
|
|
|
Great control!
To make the visual feedback clearer if the ontrol is disabled, I changed CDateTimeEditCtrlEditCtrl::CtlColor :
HBRUSH CDateTimeEditCtrlEditCtrl::CtlColor
(CDC* pDC, UINT nCtlColor)
{
if (m_bNonEditable && IsWindowEnabled())
{
pDC->SetBkColor(GetSysColor(COLOR_WINDOW));
return GetSysColorBrush(COLOR_WINDOW);
}
return NULL;
}
|
|
|
|
|
Thanks for this idea. I have added it to my latest update which I have posted and should appear here soon.
"The way of a fool seems right to him, but a wise man listens to advice" - Proverbs 12:15 (NIV)
|
|
|
|
|
I had to change any HTASK I found to a DWORD to get it to compile in Visual Studio .NET 2003
|
|
|
|
|
Thanks for letting me know about this. I'm only just about moving to VS.NET so I've not yet found these things. I have added #if _MFC_VER >= 0x0700 tests to my code so that my future updates will compile with all versions of VS/MFC.
"The way of a fool seems right to him, but a wise man listens to advice" - Proverbs 12:15 (NIV)
|
|
|
|
|
Hi friends
Great control. Thanks.
Did anyone tried to put this or similar control in a cell of MFC Grid (of Chris Maunder) ?
If yes, please give some guideline/code/help.
Thanks
Ana
Ana_v123
|
|
|
|
|
Does anyone know how the color ( the white space) of a CDateTimeCtrl is changed. I have tried to handle WM_CTLCOLOR , but it seems this control does not send such a message.
|
|
|
|
|
WM_CLTCOLOR is not sent for CDateTimeCtrl. So I think you may override OnPaint() and do the paiting by yourself.
Anand
|
|
|
|
|
add the follow codes at the end of the funcion "WindowProc" of class CDateTimeEditCtrlMonthCalCtrl
else if ( message == WM_MENUSELECT)
{
if(lParam == NULL)
SetCapture();
}
then It works ,but i don't konw whether it is absolutely right.
thanks ,paul, i thought out it with your hints.
excellent control and idea!
|
|
|
|
|
OK, this restores capture to the calendar control, but also dismisses the calendar, which is not the desired behaviour. The full fix has the same code as yours, but adds a flag to make sure that the next mouse down message does not dismiss the calendar if the menu was dismissed by the mouse. I will email you the new code directly, though it should appear on the site within the next few days.
"The way of a fool seems right to him, but a wise man listens to advice" - Proverbs 12:15 (NIV)
|
|
|
|
|
When you click the month selected area at the top of the calendar, the month selected menu will popup. After the menu disappears, you click the outside of calendar,but the calendar will not disappear.
|
|
|
|
|
This is to do with the menu taking capture from the calendar, so it then doesn't know that the user has clicked outside of it. I have added a fix for it, and posted an update.
"The way of a fool seems right to him, but a wise man listens to advice" - Proverbs 12:15 (NIV)
|
|
|
|
|
I could not find your update.
I found In WindowProc(..) function of CDateTimeEditCtrlMonthCalCtrl
if (message == WM_LBUTTONDOWN ||
message == WM_MBUTTONDOWN ||
message == WM_RBUTTONDOWN)
{
// Is mouse within control
CPoint point(lParam);
CRect rcClient;
GetClientRect(rcClient);
if (! rcClient.PtInRect(point))
{
ReleaseCapture();
GetOwner()->PostMessage(DTCEM_DESTROY_CALENDAR);
}
else
SetCapture();
}
else if (message == WM_LBUTTONUP ||
message == WM_MBUTTONUP ||
message == WM_RBUTTONUP)
{
CMonthCalCtrl::WindowProc(message, wParam, lParam);
// we seem to lose capture on Xbuttonup, which stops us catching
// out-of-rect messages after changing, for instance, the month
// so we need to re-capture messages. However, if the Xbuttondown
// was out-of-rect, then we won't exist by this point, so test validity
if (::IsWindow(m_hWnd))
SetCapture();
return 0;
}
else if (message == WM_PARENTNOTIFY)
{
if (LOWORD(wParam) == WM_DESTROY)
// just destroyed the 'year' edit/updown, but this makes us lose capture
SetCapture();
}
you have not deal with the case of the month select. how to set the capture of the calendar back afer the pop menu disappeared.
|
|
|
|
|
winkle wrote:
I could not find your update
That's because it takes a while for updates email to the webmaster to appear on the site. It'll appear in a few days.
You are correct: it is due to the WM_MENUSELECT, and the fact that this needs to be used to restore the capture.
"The way of a fool seems right to him, but a wise man listens to advice" - Proverbs 12:15 (NIV)
|
|
|
|
|
Hi,
One shouldn't include the decimal symbol as a valid date separator. If the decimal symbol is ',', it's accepted, if the Default characters are used or even if it's not specified in the "Specified:" field.
And I don't know whether it's a feature or a bug but if I enter only the year and the month, it's declared as a valid date string.
But never mind, the standard CDateTimeCtrl is good enough for me.
|
|
|
|