Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

Measurement Studio Visual C++ 6.0 Multithreads

I want to use the dialog editor to add NI controls to a dialog (or CFormView) and want to set CNiInterface to SingleThreaded. How do I do this. I do not want to create the controls dynamically because I do not want to deal with license strings. I get an error if I close the dialog box when a control is added with the dialog editor. Is this because the controls by default are created as multithreaded with caching? I get by this by calling destroy window on the control. Is this the proper way? Will I have to do this if I use singlethreaded?

Next the documentation says I need to initialize COM. Is this true. Is it not enough to call
AfxEnableControlContainer() in OnInitInstance of my application.

By the way
National Instruments, Your documentation leaves quit a bit to be desired!! Good grief.
0 Kudos
Message 1 of 3
(2,711 Views)
The default thread access for the Measurement Studio C++ controls is CNiInterface::MultipleThreadsWithCaching. You do not have to dynamically create the control if you want to create the control with CNiInterface::SingleThread - just specify it in the dialog class constructor's member initialization list. For example, if you had a dialog class called CTestDialog and you had a member variable for the graph in the dialog class called m_graph:

CTestDialog::CTestDialog(CWnd* pParent /*=NULL*/)
: CDialog(CTestDialog::IDD, pParent), m_graph(CNiInterface::SingleThread)
{
}

Also, you should not need to initialize COM to use the controls in a dialog. The call to AfxEnableControlContainer in your InitInstance method should be sufficient.


- Elton
Message 2 of 3
(2,711 Views)
Hello,
The constructors for CNi classes are overloaded, and by default, the parameter for CNiInterface::ThreadAccess is set to CNiInterface::MultipleThreadsWithCaching.
You can also pass other constant for CNiInterface::ThreadAccess in the constructor. In this case, you should pass CNiInterface::SingleThread to CNi constructors. Please refer to Measurement Studio Reference for more information. You can do so after dropping the control and creating a member varialbe for your control. If you do not want to drop it on the form, then you'd have to get the licnese information at run time. You do not have to explicitely destroy the controls if you created them using the wizard.

You have to call CoInitialize(or CoInitializeEx), as well as AfxEnableControlContainer() i
n your application.
0 Kudos
Message 3 of 3
(2,711 Views)