01-29-2014 01:19 PM
I am developing an application in CVI 2012. I am using Microsoft's Calendar Control to give the user a popup calendar to select a date. It is an ActiveX control. There are two different instances of this control in the program. In the first instance, everything works as it should: the calendar pops up (i.e. is made visible), the user can select a date and the selected date is displayed in an indicator. The second instance does not work as expected. This is a list of what happens:
1. The first time the calendar is made visible, I set the date using MSACAL_ICalendarToday. When I read back the date from the calendar (using MSACAL_ICalendarGetYear, MSACAL_ICalendarGetDay, MSACAL_ICalendarGetMonth), I get the expected values but the calendar display is not updated. That is, if the calendar has a value of 1/1/2014 set while editing the UIR file, if I set the calendar value to today (1/29/2014) I will read back 1/29/2014 but the calendar will continue to display 1/1/2014.
2. If I change the date on the calendar by clicking on a day (say 1/2/2014) the appropriate day will be highlighted but when I read back the date I get the date set in item #1 (1/29/2014).
I am using exactly the same code for the first instance as the second instance except there are separate callback functions for each instance (and the variable names have been changed).
It seems like the set functionality is working to the extent that the values are being set in memory but not updated on the GUI and then the get functionality is getting the values in memory but not what the user has actually selected.
Any thoughts?
Thanks.
01-30-2014 09:19 AM
01-30-2014 09:58 AM
@friday_the_13th wrote:
Hi,A couple things we can check right away are the ActiveX references and whether or not the GUI is being updated. Are the ActiveX references being closed after they are used? Try using ProcessSystemEvents to make sure the GUI is being updated. Here is the help document for reference.
How do I close the ActiveX references? I generate a handle for the ActiveX controls using "GetObjHandleFromActiveXCtrl" and use that to reference the ActiveX control. This approach is used for both the control that works as expected and the one that does not.
Do you have a suggestion for where the "ProcessSystemEvents" function should be called? Right now I have a callback function for the ring control that is associated with the calendar. (The ring control callback makes the calendar appear and disappear.) Within the ring control callback I use "PostDeferredCall" to call a function that reads the calendar values and updates the ring control.
Thanks.
01-30-2014 10:33 AM
Here is a help document on adding and releasing references in LabWindows/CVI. Also, you might try adding the ProcessSystemEvents function between the two calendar events and after the ring control. This redundancy is just to make sure all events are being processed.
02-03-2014 03:40 PM
Thanks for the links but I still could not get the calendar to work properly. The engineer who implemented the calendar that works also had a lot of issues getting the first calendar working and said that he is not sure what trick he used to get it to start working. I think there is something we are generally misunderstanding about ActiveX and CVI. Unforunately I am mostly out of time to get it to work so I am just going to have the user enter a regular expression and check the format before proceeding.
02-04-2014 04:18 PM