|
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.
|
|
|
|
|
Hi,
I have a much simpler requirement than your great control but I didn't manage to size it down to my needs..
I simply want to make the client-edge of the standard CDateTimeCtrl disappear as all ctrls in my app have none.
Can you give me a hint on this?
Thanks a lot,
Simon
|
|
|
|
|
Hi, this is Jino.
I have a problem with CDateTimeCtrl
and I think it's very serious and weird.
The symptom is very very simple.
1. Make new dialog-based MFC application.
2. Place a DateTimePicker(CDateTimeCtrl) and a button.
3. generate button click event handler
4. copy example code from MSDN about CDateTimeCtrl::GetTime(CTime & time)
-> refer to the code below.
5. Compile and run
6. Click and Boom! Access violation occured.
below is the example code from MSDN:
---------------------------------------------------------------------
CDateTimeCtrl* pCtrl = (CDateTimeCtrl*) GetDlgItem(IDC_DATETIMEPICKER1);
ASSERT(pCtrl != NULL);
// get as a CTime
CTime timeTime;
DWORD dwResult = pCtrl->GetTime(timeTime);
if (dwResult == GDT_VALID)
{
// the user checked the box and specified data
CString str;
// is it a time-only control, or a date-only control?
if ((pCtrl->GetStyle() & DTS_TIMEFORMAT) == DTS_TIMEFORMAT)//Boom!
str = timeTime.Format(_T("%X"));
else
str = timeTime.Format(_T("%x"));
AfxMessageBox(str);
}
else
{
// the user unmarked the "none" box
AfxMessageBox(_T("Time not set!"));
}
-------------------------------------------------------------------------
When I tested exactly same code at another machine, it worked
just fine. what is happening to me?
the message told me that "unhandled exception in XXX.exe(MFC42d.dll)
:0xC0000005 : access violation"
I compared the timestamp of mscomct2.ocx file on both computer
but couldn't find any difference.
If you have anythig in mind plz don't hesitate to
give me an advice. I'm all ears.
|
|
|
|
|
Hi,
I have looked into this, and can't reproduce your error. I can't see why it would fail on one machine, and not another. I would try just calling GetStyle() on the control somewhere else, and see what it returns, as it is probably that call that is making it fall over. Also, does it work correctly when not using my control?
Let me know what you find out,
Paul.
"The way of a fool seems right to him, but a wise man listens to advice" - Proverbs 12:15 (NIV)
|
|
|
|
|
I have to compile my app on the Windows platform for which it is going to be used, with no code changes, when I use the CDateTimeCtrl. In other words, I have to compile on a Windows 98 machine to use the executable on W98, then compile the same code on W2000 for use on W2K, then compile on XP for use on XP. Otherwise I get an abend like above. This is with the MS control, not yours. This is a real pain.
|
|
|
|
|
Hi,
Could you please tell me if it support right to left or not?
and also as i use persian/jalali/hijri shamsi calendar may i convert the date table to the persian calendar and display it to users and be able to select the converted date and return a sting to the calling environment to save it as a text on a database?
Best Regards
Saeed
|
|
|
|
|
Hi,
I don't know whether it supports RTL, and I don't have any way of properly finding out. The best thing is to try it. If it doesn't work, then let me know what isn't working, and I may be able to address it.
Same for other calendars.
Paul.
"The way of a fool seems right to him, but a wise man listens to advice" - Proverbs 12:15 (NIV)
|
|
|
|
|
Hi again,
A dimme problem occurs in a dialog containing two DateTimeEditCtrl controls. Only the last EnableWindow is OK, any idea ?
|
|
|
|