LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I use a toolwindow or imaqBCGTransform function on the image displayed by picture box or canvas?

Solved!
Go to solution

Hi,

 

I'm using LabwindowsCVI8.5 & NI Vision. Recently, I met a problem that when I tried to apply a toolwindow on the image diaplayed by picture box or canvas, the toolwindow successfully showed but couldn't work. I knew that I can use imaqCreateImage & imaqDisplayImage functions to create the image on a new separated window, and then, both the toolwindow & imaqBCGTransform work well, but I just wanna know is there any way to use the Image processing functions with the image displaying as a part of the UIR or as a sub-panel? Coz I think it will be much conventional to see the image being processed that way.

 

Thanks a lot!

 

Kitty, eng.

URT

0 Kudos
Message 1 of 8
(5,004 Views)
Solution
Accepted by topic author yuemuping

i always wondered why there is no control to put into an UIR for displaying an image from NI Vision...

 

anyway, there is a clever hack to embed an image display window of NI Vision into a panel. it has already been discussed on this forum but i can't find the link anymore.

it goes something like this:

 

    HWND window_handle, parent_handle;

    int  image_window;
    int  left, top, width, height;

 

    // initialize CVIRTE, etc.

    // create the parent panel

    panel = LoadPanel( ... );

 

    // get a new display window handle (optional, see the documentation for imaqGetWindowHandle)

    imaqGetWindowHandle( &image_window );


    // integrate into a parent panel

    window_handle = (HWND)imaqGetSystemWindowHandle( image_window );
    GetPanelAttribute( panel, ATTR_SYSTEM_WINDOW_HANDLE, (int *)&parent_handle );
    SetWindowLong( window_handle, GWL_STYLE, WS_CHILDWINDOW );
    SetParent( window_handle, parent_handle);
    SetWindowLong( window_handle, GWL_STYLE, WS_CLIPSIBLINGS );

   

    // position the display where it should be displayed and resize it
    imaqSetWindowSize( image_window, width, height );
    imaqMoveWindow( image_window, MakePoint( left, top) );

 

i hope this helps...

Message 2 of 8
(4,996 Views)

Thanks a lot~!!!!!!!!

That's really a good way to solve the problem~!!! 

0 Kudos
Message 3 of 8
(4,982 Views)

no it is not a good way. it is still a hack and will definitely be a hack until NI comes with a better solution.

this problems appears regularly into the "Machine vision" forum as well as this forum and has never found a solution better than this hack. it has a lot of drawbacks, the most important one being the inability to embed an image into a child panel...

 

it may be the time for NI to think about implementing a better solution for CVI users...

0 Kudos
Message 4 of 8
(4,963 Views)
well, I met another problem related to this topic. When I wanted to display the hack image on a TAB control, I uesd GetPanelHandleFromTabPage (panelHandle, PANEL_TAB, PAGE_ONE, &TabPanelHandle); to get my TanPanelHandle, and then, got the parentHandle by using GetPanelAttribute (TabPanelHandle, ATTR_SYSTEM_WINDOW_HANDLE, &inthParent);   However, it doesn't work. When I set the break point to read the value of "parent_handle = (HWND)inthParent ;", it's NULL. Is there anything wrong? Or is there any other ways to display the image on a TAB control? Thanks a lot!
0 Kudos
Message 5 of 8
(4,737 Views)
the documentation for ATTR_SYSTEM_WINDOW_HANDLE clearly states that it works for top-level panels only ! there is no way to make this hack work properly for anything other than a top panel. (this is the reason why i am crying so loud to have a proper CVI control for image display)
0 Kudos
Message 6 of 8
(4,717 Views)

Hi, dummy_decoy~Are you still working in this field? Could you please tell me that did NI have any development in their new edition on this question after almost one year? Thanks a lot & best wishes~!

0 Kudos
Message 7 of 8
(4,354 Views)

i did not see many changes in CVI 9.0: there is still no image control to put on an UIR.

 

however, there has been a big step forward in NI Vision 8.6.4: now, when you apply a transform on an image (scale, rotate, etc...) you can apply the transform on the overlay too. so now, there is nothing preventing us from coding our own image control, although this might be quite a lot of work.

0 Kudos
Message 8 of 8
(4,336 Views)