LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Read value from Date Time Active X Control

Hello
 
I am using the Date Time Picker active control (MSCOMCT2.OCX) to show Date and Time. Please let me know how to read the value from this active X control.
 
Thanks and Regards
Rakesh
0 Kudos
Message 1 of 4
(4,810 Views)

Hello Rakesh,

If you are try to use the Date/Time Picker ActiveX control, you should do the following steps:

1. Get a handle to the ActiveX control.

int dateCtrl;

GetObjHandleFromActiveXCtrl (panelHandle, PANEL_CWDTPICKER, &dateCtrl);

2. Get the string value of the Date/Time Picker control and the integer value of the day, month, and year chosen.

int dayval, monthval, yearval;
char *stringval;
VARIANT dayvariant, monthvariant, yearvariant, stringvariant;

MSComCtl2_IDTPickerGet_Value (dateCtrl, NULL, &stringvariant);
MSComCtl2_IDTPickerGetDay (dateCtrl, NULL, &dayvariant);
MSComCtl2_IDTPickerGetMonth (dateCtrl, NULL, &monthvariant);  
MSComCtl2_IDTPickerGetYear (dateCtrl, NULL, &yearvariant);

3. Convert the variant into a string or integer.

stringval = malloc(15*sizeof(char));

CA_VariantConvertToType (&stringvariant, CAVT_CSTRING, &stringval);
CA_VariantConvertToType (&dayvariant, CAVT_INT, &dayval);
CA_VariantConvertToType (&monthvariant, CAVT_INT, &monthval);
CA_VariantConvertToType (&yearvariant, CAVT_INT, &yearval);

As always, since the code set for this control is provided by Microsoft, you should first refer to the MSDN website / Google when trying to programmatically use these controls.  Hope that helps.

Wendy L
LabWindows/CVI Developer Newsletter
0 Kudos
Message 2 of 4
(4,796 Views)
0 Kudos
Message 3 of 4
(4,525 Views)
I am planning to incorporate the Date Timer Picker control (MSCOMCT2) into my CVI application.  On reading about, I see issues regarding its installation, registration, and distribution.   Do you and Wendy recall the details of your installation and integration into your application?   I have never used an Active X control of this sort before.

Thanks.
0 Kudos
Message 4 of 4
(4,524 Views)