|
Is it possible to make the datetimepicker the humbers bigger
|
|
|
|
|
hi,
i have placed the CDateTimeCtrl on the Dialog. I want to change the back color of the cdateTime Control as it displaying on the dialog. As i can change only the MothCalc Control Back color and text Color, I can not change the back colour of the CDateTimeCtrl.
How can I ?
Can you help me for the sample code as well ?
Hasmukh M. Ginoya
Sr.Software Developer
Gandhinagar,
Gujarat,India
|
|
|
|
|
When using Classic Theme in Vista and you click twice on the dropdown button while visual studio debugs the app you'll get a heap corruption message.
|
|
|
|
|
Hi Paul,
Great control & easy to use, exactly what I was looking for...
Just thought I'd feedback something I've noticed regarding the Windows Classic Theme on Vista and Server 2008 (no problem when using this theme for Windows XP).
Under these specific conditions, the text in the combo box overwrites the left border of the control and the associated button is too large.
I can provide screenshots, if you like, but I can't find a way to attach them to this message.
Many Thanks,
Rich Holliday
|
|
|
|
|
I like your control and I am planning to use it.
In OnInitDialog the control does not set valid chars (m_btnValidCharsOnly.SetCheck(TRUE) and OnBtnValidCharsOnly() are called).
Maybe should change to something like:
CDateTimeEditCtrl::CDateTimeEditCtrl()<br />
{<br />
m_pEdit = new CDateTimeEditCtrlEditCtrl;<br />
if (!s_xpstyle.IsAppXPStyled() || !IsVistaOrLater())<br />
m_pBtn = new CDateTimeEditCtrlButton;<br />
...<br />
}<br />
<br />
int CDateTimeEditCtrl::OnCreate(LPCREATESTRUCT lpCreateStruct) <br />
{<br />
...<br />
if (NULL == m_pEdit)<br />
m_pEdit = new CDateTimeEditCtrlEditCtrl;<br />
if (! s_xpstyle.IsAppXPStyled() || ! IsVistaOrLater())<br />
if (NULL == m_pBtn)<br />
m_pBtn = new CDateTimeEditCtrlButton;<br />
...<br />
}<br />
...Plug & Pray...
|
|
|
|
|
Hi Paul,
I found this date picker to be extremely useful. Is there any chance that you could write a C# .NET version of this editable date time picker?
Thanks.
|
|
|
|
|
I'm glad you found this control useful.
As for a C# version, I am hoping to produce C# versions of some of my controls soon, but I'm currently very busy, and haven't been able to complete my many overdue updates to my stuff on here.
Watch this space (but don't hold your breath...)!
"The way of a fool seems right to him, but a wise man listens to advice" - Proverbs 12:15 (NIV)
|
|
|
|
|
Hi,
I uses Compuware Devpartner BoundsChecker Suite, and this tool has detected a resource leak in the control. The problem is linked to that line :
static CDateTimeEditCtrl::CDateTimeEditXPStyle s_xpstyle;
When the project is loaded, that static member is loaded too. So the line that follows is executed :
m_hThemeDLL = LoadLibrary(_T("uxtheme.dll"));
But when the program ends, the resource uxtheme.dll isn't freed.
I think we can add a static method to free that resource, and call that method when the program is ending, but maybe there is a better solution...
|
|
|
|
|
The DLL is freed when the program ends - just not cleanly, so leak detectors will complain. I'm usually a bit lazy about such things, and only bother freeing if I really don't something again during that program's execution, or I want to re-load/allocate something.
The simplest thing would be to just add a destructor to the CDateTimeEditXPStyle class to free the library when the static variable dies, which it automatically does at the termination of the program.
"The way of a fool seems right to him, but a wise man listens to advice" - Proverbs 12:15 (NIV)
|
|
|
|
|
You have a function called
CEdit* GetEditControl() const { return m_pEdit; }
for manipulating the edit control.
But why is it const? If it is const, then doesn't that mean you are not allowed to modify any member variables of the edit control?
|
|
|
|
|
Sorry I've not replied to this before now.
Looking at it now, it is a bit inconsistent, as the function is const, but the variable returned isn't (explicitly) const. It would probably be better to either remove the const, or to have two functions:
const CEdit* GetEditControl() const { return m_pEdit; }
CEdit* GetEditControl() { return m_pEdit; }
although it could then be argued that the const version is superfluous, as the non-const can always be assigned to a const variable if required. Having said that, if the method is called on a const date picker pointer/reference, the non-const one would then fail to compile.
"The way of a fool seems right to him, but a wise man listens to advice" - Proverbs 12:15 (NIV)
|
|
|
|
|
I have a KillFocus event on my form which is assigned to the date time picker. During this kill focus, I want to set a new date into the date time picker, but when I do this, this will result in a crash when the code gets to the line:
CEdit::OnKillFocus(pNewWnd);
void CDateTimeEditCtrlEditCtrl::OnKillFocus(CWnd* pNewWnd)
{
CDateTimeEditCtrl* pDateTimeEditCtrl = DYNAMIC_DOWNCAST(CDateTimeEditCtrl, GetParent());
if (pDateTimeEditCtrl != NULL)
{
// send notification to parent of date time ctrl
CWnd* pParent = pDateTimeEditCtrl->GetParent();
if (pParent != NULL)
{
NMHDR nmhdr;
nmhdr.hwndFrom = pDateTimeEditCtrl->m_hWnd;
nmhdr.idFrom = pDateTimeEditCtrl->GetDlgCtrlID();
nmhdr.code = NM_KILLFOCUS;
pParent->SendMessage(WM_NOTIFY, (WPARAM)nmhdr.idFrom, (LPARAM)&nmhdr);
}
}
CEdit::OnKillFocus(pNewWnd); //Will crash here
}
Why is it crashing?
Thanks
|
|
|
|
|
I have submitted an updated version (3.6.1) of this control, which addresses the following:
- fixed missing and incorrect NM_KILLFOCUS notifications
- changed to compile correctly in VC7 (VS2003) and VC8 (VS2005)
- added fix to control being shown if hidden in initialising of parent
It should appear here soon!
Paul.
"The way of a fool seems right to him, but a wise man listens to advice" - Proverbs 12:15 (NIV)
|
|
|
|
|
Thank you for this wonderful control! I have always been so frustrated with the standard datetime control.
I am having a problem with getting the control to hide when calling ShowWindow(SW_HIDE). I want to hide the date control until they select some radio button for example. When I use the following code I can't get the control to hide. I am calling this function before the window is shown if that makes any difference.
void CMyDialog::FieldHide(int control, BOOL hide)<br />
{<br />
CWnd *slot;<br />
<br />
slot=GetDlgItem(control);<br />
slot->ShowWindow(hide ? SW_HIDE : SW_SHOW); <br />
}
When I use this the control still shows up. I have had success by simply calling this function twice passing in the same parameters. The normal MS control works fine when using this code so I think the problem might be in how you are recreating the controls. Thanks for your help!
|
|
|
|
|
Yes, you're right, it is due to the re-creating. The re-creation is triggered by the first message that hits the window, if the message loop has not already picked it up. However, if the first message is WM_SHOWWINDOW, then its visiblity state is wrong when picking up the existing style in the re-creation function. I'll be publishing a new version in the next few days (to work correctly in VC7/8) which will include a fix, but in the meantime you can add the following code in the CDateTimeEditCtrl::WindowProc function, just after the call to DispatchMessage:
if (message == WM_SHOWWINDOW)
ShowWindow(wParam ? SW_SHOW : SW_HIDE);
This will ensure that if it is the WM_SHOWWINDOW message that triggers the re-creation, it retains the correct visibilty state.
"The way of a fool seems right to him, but a wise man listens to advice" - Proverbs 12:15 (NIV)
|
|
|
|
|
Hi,
Just wanting to know if you have managed to create a VS 2005 Compilable version of the editable date time picker?
Thanks,
|
|
|
|
|
I have a VS2005 (and VS2003) compilable version, which also includes a couple of other fixes. I am hoping to post an update in the next few days.
"The way of a fool seems right to him, but a wise man listens to advice" - Proverbs 12:15 (NIV)
|
|
|
|
|
Hello, I also search a version which is compilable with VS2005.
When do you think that you can upload these files?
Thanks in advance!
|
|
|
|
|
How to change the background color of the combo like think in the date picker control iam managed to change th efont and color of the cDatetime ctrl but not of the combo box in which it resides
|
|
|
|
|
Hi,
I would like to use the KillFocus message, but it doesn't react as I want. It only occurs when I click on the calendar button, but not when the focus leaves the CDateTimeEditCtrl control.
Your help would be very welcome...
Thanks
|
|
|
|
|
This is because the date/time control doesn't really have the focus, as the overlying edit control has it. To remedy this, you can add code to the edit control to pass the NM_KILLFOCUS notification on to the date/time control's parent when the edit control loses focus. You'll need to add this manually, as the Class wizard doesn't work properly with nested classes. Add the following to the message map of the CDateTimeEditCtrlEditCtrl:
ON_WM_KILLFOCUS()
then add the following to the CDateTimeEditCtrlEditCtrl message map declarations in the header file:
afx_msg void OnKillFocus(CWnd* pNewWnd);
and finally, add the following function to the cpp file:
void CDateTimeEditCtrlEditCtrl::OnKillFocus(CWnd* pNewWnd)
{
CDateTimeEditCtrl* pDateTimeEditCtrl = DYNAMIC_DOWNCAST(CDateTimeEditCtrl, GetParent());
if (pDateTimeEditCtrl != NULL)
{
CWnd* pParent = pDateTimeEditCtrl->GetParent();
if (pParent != NULL)
{
NMHDR nmhdr;
nmhdr.hwndFrom = pDateTimeEditCtrl->m_hWnd;
nmhdr.idFrom = pDateTimeEditCtrl->GetDlgCtrlID();
nmhdr.code = NM_KILLFOCUS;
pParent->SendMessage(WM_NOTIFY, (WPARAM)nmhdr.idFrom, (LPARAM)&nmhdr);
}
}
CEdit::OnKillFocus(pNewWnd);
} What you will find though is that the parent gets a NM_KILLFOCUS when passing the focus to the control, as the control immediately passes the focus onto the edit control. To stop this, add a handler for the NM_KILLFOCUS to the CDateTimeEditCtrl, modify it to return BOOL, modify the message map entry to use ON_NOTIFY_REFLECT_EX , and add the following code to it:
BOOL CDateTimeEditCtrl::OnKillfocus(NMHDR* pNMHDR, LRESULT* pResult)
{
*pResult = 0;
if (CWnd::GetFocus() == m_pEdit)
return TRUE;
return FALSE;
} This should make the notifications work as per the standard date control.
I'll add this to my list of pending updates, and post it as soon as I get some time.
"The way of a fool seems right to him, but a wise man listens to advice" - Proverbs 12:15 (NIV)
|
|
|
|
|
Thanks for your help. I think I understand.
But I still have a problem with the OnKillfocus method : the mapping with ON_NOTIFY_REFLECT_EX doesn't accept it because of its BOOL return value (it expects a void method)...
|
|
|
|
|
Yes, it works !
In fact the problem was the name of the method : I've changed CDateTimeEditCtrl::OnKillfocus in CDateTimeEditCtrl::OnNMKillfocus and it works very well.
Thank you very much !
This KillFocus message will be useful to read the new COleDateTime only after the user has finished to write or choose it.
|
|
|
|
|
Hi, I'm not a CPP expert, but tried to add it to our solution as a separate project. It didn't compile. Do you have a compilable version under Visual Studio 2003 ?
Thx,
noy
|
|
|
|
|
Hello,
I also had an error during compilation. I have solved it this way, in the CDateTimeEditCtrlEditCtrl::OnKeyDown method :
CString sSeps(s_chDateSep);
I hope that will help you...
|
|
|
|