el_rooky
asked on
Date Time Picker control
I have a DateTimePicker control with a checkbox ("Show None" property selected). I can check the ckeckbox with the following command:
CWnd* hWndCtrl = GetDlgItem(IDC_MYDATE);
hWndCtrl->SendMessage(DTM_ SETSYSTEMT IME ,GDT_VALID, 0);
How do I check if the checkedbox is checked?
CWnd* hWndCtrl = GetDlgItem(IDC_MYDATE);
hWndCtrl->SendMessage(DTM_
How do I check if the checkedbox is checked?
what compiler are you using???
ASKER
I am using VC++ 6
Did you try:
hWndCtrl->SendMessage(DTM_ SETSYSTEMT IME ,GDT_NONE, 0);
The documentation says that that will set the the control into its "no date" mode and it will cleaar the checkbox.
It also says that this will only work if the control has the DTS_SHOWNONE style.
-- Dan
hWndCtrl->SendMessage(DTM_
The documentation says that that will set the the control into its "no date" mode and it will cleaar the checkbox.
It also says that this will only work if the control has the DTS_SHOWNONE style.
-- Dan
ASKER
Yes, I've tried that:
hWndCtrl->SendMessage(DTM_ SETSYSTEMT IME ,GDT_NONE, 0) always returns 1
hWndCtrl->SendMessage(DTM_ SETSYSTEMT IME ,GDT_VALID, 0) always returns 0
The 'show none' style is selected in the control.
hWndCtrl->SendMessage(DTM_
hWndCtrl->SendMessage(DTM_
The 'show none' style is selected in the control.
ASKER
oops, I should be using DTM_GETSYSTEMTIME instead.
But now I get an access viloation error
hWndCtrl->SendMessage(DTM_ GETSYSTEMT IME ,GDT_NONE, 0)
any idea why?
But now I get an access viloation error
hWndCtrl->SendMessage(DTM_
any idea why?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
>>But now I get an access viloation error
You are getting an access violation becasue the LPARAM in the SendMessage call needs to point to a variable that will receive the return value:
SYSTEMTIME rST;
int nRet= hWndCtrl->SendMessage(DTM_ SETSYSTEMT IME ,GDT_VALID, (LPARAM)&rST );
if ( nRet == GDT_NONE ) {
// checkbox is unchecked
}
-- Dan
You are getting an access violation becasue the LPARAM in the SendMessage call needs to point to a variable that will receive the return value:
SYSTEMTIME rST;
int nRet= hWndCtrl->SendMessage(DTM_
if ( nRet == GDT_NONE ) {
// checkbox is unchecked
}
-- Dan
Oops, I meant:
SYSTEMTIME rST;
int nRet= hWndCtrl->SendMessage(DTM_ GETSYSTEMT IME ,GDT_VALID, (LPARAM)&rST );
SYSTEMTIME rST;
int nRet= hWndCtrl->SendMessage(DTM_
ASKER
Dan and Slordak,
Thanks. Both sugestions worked fine. I find this method of casting the control much easier to use, though.
Thanks. Both sugestions worked fine. I find this method of casting the control much easier to use, though.