Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

LPDISPATCH for the CWIMAQViewer

I am trying to call GetSelectedRectangleFromViewer() using a C_CWMachineVision object. The first parameter of the function is a LPDISPATCH Viewer pointer. I can't figure out how to get an LPDISPATCH type from the viewer object, which is type CCWIMAQViewer.

How can I get an LPDISPATCH from my CCWIMAQViewer object?
0 Kudos
Message 1 of 5
(4,926 Views)
Hello,

What programming environment are you developing your code in? What version of Vision do you have installed on your system?

I have located two KnowledgeBases on NI's website that may address this issue:

How Do You Extract Data from LPDISPATCH?
http://digital.ni.com/public.nsf/websearch/862567530005F09C862566730067B94F?OpenDocument

How Do I Convert a CWIMAQ Object to a Variant in C++?
http://digital.ni.com/public.nsf/websearch/919C5A1E65A1B6C3862568EA00719E7D?OpenDocument

Between those two webpages, the conversion from and to the LPDispatch datatype are covered. Take a look at that information and let me know if you have any additional questions on this issue.

Regards,
Scott R.
Applications Engineer
National Instruments
Scott Romine
Course Development Engineer
National Instruments
0 Kudos
Message 2 of 5
(4,905 Views)

Hello,

I have the same problem : I don't know how to use GetSelectedLineFromViewer(). I think I need to create a C_CWMachineVision object before (with the cwMachineVision.Create() method) but I don't understant how to do it.

Please, can you help me ?

I'm using IMAQ Vision 6 with Visual Studio 6 (C++).

 

Message Edité par Corinne_ le 10-16-2007 05:38 AM

0 Kudos
Message 3 of 5
(4,560 Views)
Hello,

For information on how to use the GetSelectedLineFromViewer function, you can turn to the NI Vision for Visual Basic Reference Help.  You can find this Help file under C:\Program Files\National Instruments\Vision\Documentation\cwimaq.chm.  For your convenience, I am also including a copy as an attachment to this post.

Here is an example of how to use the GetSelectedLineFromViewer function from the Help file.
Private Sub Run_Click()
    'Inputs to LightMeterLine
    Dim SearchArea As New CWIMAQLine
    Dim Transformation As New CWMVCoordinateTransformation
    
    'Outputs of LightMeterLine
    Dim Report As New CWMVLightMeterLineReport
    
    'Get the line from the viewer.
    CWMachineVision1.GetSelectedLineFromViewer CWIMAQViewer1, SearchArea
    
    'Measure the intensity inside the search region
    CWMachineVision1.LightMeterLine CWIMAQViewer1.Image, SearchArea, Report, , Transformation

    'Display the mean intensity in a text box
    Text1.Text = Report.MeanIntensity
End Sub

Best Regards,
T. McCarty
0 Kudos
Message 4 of 5
(4,537 Views)
Thanks a lot for your help, but I found what I'm looking for getting a line from the viewer :
 
C_CWIMAQLine myCWLine = myCWViewer.CreateCWIMAQLine();
LPDISPATCH lpDispatch;
LPUNKNOWN lpUnknown = myCWViewer.GetControlUnknown();
lpUnknown->QueryInterface(IID_IDispatch, (LPVOID *)&lpDispatch);
myCWMachineVision.GetSelectedLineFromViewer(lpDispatch, myCWLine, indexofmyline);
 
Now, you can retrieve the end and start points of your line...
 
Best regards,
 
0 Kudos
Message 5 of 5
(4,529 Views)