Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

Instantiating a C++ wrapped CWIMAQVision object

 
I've used the class wizard to wrap the CWIMAQVision ActiveX object and the code compiles.  When the code executes and tries to call any of the vision functions the application crashes.  Once I've wrapped the control, what do I have to do to use it's functionality?  The following code was automatically generated in the .h file.
 

CLSID const& GetClsid()
{
static CLSID const clsid
= { 0xADBF7240, 0x2B8D, 0x11D1, { 0xB5, 0xC5, 0x0, 0xA0, 0x24, 0xD6, 0x38, 0x28 } };
return clsid;
}
virtual BOOL Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle,
const RECT& rect, CWnd* pParentWnd, UINT nID,
CCreateContext* pContext = NULL)
{
return CreateControl(GetClsid(), lpszWindowName, dwStyle, rect, pParentWnd, nID);
}

BOOL Create(LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd,
UINT nID, CFile* pPersist = NULL, BOOL bStorage = FALSE,
BSTR bstrLicKey = NULL)
{
return CreateControl(GetClsid(), lpszWindowName, dwStyle, rect, pParentWnd, nID,
pPersist, bStorage, bstrLicKey);
}
0 Kudos
Message 1 of 7
(5,089 Views)
Hello mps,
 
Any particular reason why you are using wrappers around ActiveX objects to call IMAQ functions. If you are using C, NI-IMAQ does include a C API, to get started please look at C examples included with NI-IMAQ, installed under ..\National Instruments\NI-IMAQ\Sample\MSVC. I hope this helps.
 
Regards,
Nipun
0 Kudos
Message 2 of 7
(5,063 Views)
Well, I did that so that I could take some of the control out of the view without passing so many pointers and objects around.  It also allowed me to create abstract data types, wrapping the controls in an abstract class and creating child classes from that class.  Do you know of a better way, or do you know of drawbacks to doing it this way?  Here is how I do it.
 
CProcessor *m_processor;//CProcessor is an abstract wrapped vision class
 
m_processor=new CAlgorithm1Processor();//CAlgorithm1Processor is based on CProcessor

m_processor->Create(NULL,NULL,CRect(50,50,100,100),this,NULL);

m_processor->Process();

m_processor=new CAlgorithm2Processor();//CAlgorithm2Processor is based on CProcessor

m_processor->Create(NULL,NULL,CRect(50,50,100,100),this,NULL);

0 Kudos
Message 3 of 7
(5,059 Views)
How is your program crashing?
 
The attached program demonstrates creating instances of the CWIMAQVision control, both through the dialog resource and programmatically, and calling into them. I am able to run this successfully on a machine with Vision 7.1.1.
 
The project is a Visual Studio 2003 project. You should be able to use the code in a Visual C++ 6.0 project; I haven't tried it. Let me know if this works for you.
0 Kudos
Message 4 of 7
(5,038 Views)
The code doesn't crash anymore.
0 Kudos
Message 5 of 7
(5,035 Views)

Referring to the "drohacek" reply, how can I get the attachment referred to in these comments?

"The attached program demonstrates creating instances of the CWIMAQVision control, both through the dialog resource and programmatically, and calling into them. I am able to run this successfully on a machine with Vision 7.1.1."

Thanks

 

0 Kudos
Message 6 of 7
(4,759 Views)
bitsmith--

      That forum thread is over a year old. Since the prgram is no longer there, unfortunely we have no way to find it.  I'm sorry.

-John
0 Kudos
Message 7 of 7
(4,738 Views)