alukindo Posted June 3, 2008 Report Share Posted June 3, 2008 Hello: Component Works control, namely the 3-D plot control, is infact an ActiveX control. Yet, its LabVIEW property node does not expose an hWnd property. Does anyone know why? I need this to use a third party reporting tool to render the image of the object on a report page. . . . I know that this can be done using LabVIEW's getImage method but I want to use the hWnd approach because it gives cleaner report print-outs. Thanks Anthony Quote Link to comment
Francois Normandin Posted June 3, 2008 Report Share Posted June 3, 2008 There is a VI in Vision toolkit that gets the hWnd located in "..\vi.lib\Vision\Extlibsp.llb\IMAQ Get Window Handle.vi" However, I'm not sure it's possible to get the hWnd this way because it needs a "window number" which I think has to be a window previously opened by LabVIEW Vision. You might need to use Windows APIs for that. Quote Link to comment
crelf Posted June 3, 2008 Report Share Posted June 3, 2008 QUOTE (normandinf @ Jun 2 2008, 02:10 PM) You might need to use Windows APIs for that. Here's the call you want (it returns the hWnd from the window's title): There's more info here. Quote Link to comment
LAVA 1.0 Content Posted June 3, 2008 Report Share Posted June 3, 2008 QUOTE (crelf @ Jun 2 2008, 03:52 PM) Here's the call you want (it returns the hWnd from the window's title): http://lavag.org/old_files/monthly_06_2008/post-181-1212436303.png' target="_blank"> What is the Window Title for the 3d-graph container for use with that function? I can't even venture a guess. Ben Quote Link to comment
crelf Posted June 3, 2008 Report Share Posted June 3, 2008 QUOTE (neB @ Jun 2 2008, 02:54 PM) What is the Window Title for the 3d-graph container for use with that function? I can't even venture a guess. Ohhh - that's a really good point - I hadn't thought of that. Is there anyone from NI here with the inside knowledge to this? Does it even have a window title? Quote Link to comment
Francois Normandin Posted June 3, 2008 Report Share Posted June 3, 2008 Wouldn't there be an API for a list of all windows currently opened? Quote Link to comment
Chris Davis Posted June 3, 2008 Report Share Posted June 3, 2008 When I have a need to find information about a window I us a tool that ships with AutoIt (AutoIt Window Info). Consequently I made a blank VI with a 3D graph control in it and the 3D control does show up in that tool as a control, but without a seperate "window handle". It might be worth downloading AutoIt to see if it would help get you the information it needs to access the window handle for that control. Quote Link to comment
Francois Normandin Posted June 3, 2008 Report Share Posted June 3, 2008 <p style="text-align: left;"><a class="noborder" href="http://lavag.org/old_files/monthly_06_2008/post-10515-1212439546.jpg" target="_blank"></a></p> Building on crelf's input, I used the GetTopWindow() to get the child window's handle (CW Graph) of the current VI, without need of CW graph window title. Download File:post-10515-1212439407.vi (LabVIEW 8.5) Quote Link to comment
crelf Posted June 3, 2008 Report Share Posted June 3, 2008 QUOTE (normandinf @ Jun 2 2008, 03:46 PM) ...I used the GetTopWindow() to get the child window's handle (CW Graph) of the current VI, without need of CW graph window title. Nice! :thumbup: Quote Link to comment
Rolf Kalbermatter Posted June 4, 2008 Report Share Posted June 4, 2008 QUOTE (normandinf @ Jun 2 2008, 04:46 PM) Building on crelf's input, I used the GetTopWindow() to get the child window's handle (CW Graph) of the current VI, without need of CW graph window title. Download File:post-10515-1212439407.vi (LabVIEW 8.5) Works nice! But only as long as there is one single ActiveX/.Net control on the panel. Rolf Kalbermatter Quote Link to comment
Francois Normandin Posted June 4, 2008 Report Share Posted June 4, 2008 QUOTE (rolfk @ Jun 3 2008, 02:31 AM) Works nice! But only as long as there is one single ActiveX/.Net control on the panel.Rolf Kalbermatter You're quite right... I'm not very good at using APIs really... but the definition of "EnumWindow" seems to imply that we could get a list of windows with their Z-order, hence order of creation... Specifying which windows are child windows (ActiveX instance) of a certain parent (VI), I think it would be the way to go to identify all of them. Then, there remains the problem of association with the correct window. Seems to me like crelf's suggestion is pertinent: QUOTE (crelf @ Jun 2 2008, 03:59 PM) Is there anyone from NI here with the inside knowledge to this? Does it even have a window title? QUOTE (neB @ Jun 2 2008, 03:54 PM) What is the Window Title for the 3d-graph container for use with that function? I can't even venture a guess. Ben Could it be as simple as Label Name??? EDIT: NOPE! It isn't... Quote Link to comment
Rolf Kalbermatter Posted June 4, 2008 Report Share Posted June 4, 2008 QUOTE (crelf @ Jun 2 2008, 03:59 PM) Ohhh - that's a really good point - I hadn't thought of that. Is there anyone from NI here with the inside knowledge to this? Does it even have a window title? Nope that window does not have any title. Rolf Kalbermatter Quote Link to comment
alukindo Posted June 4, 2008 Author Report Share Posted June 4, 2008 Hello: Thanks for the activity on this question. My VI has one Active X control window so I may be able to use this technique. I need to test to see if the handle will render the 3-D control on the document. Will soon provide feed-back. Anthony Quote Link to comment
dadreamer Posted October 31, 2020 Report Share Posted October 31, 2020 On 6/4/2008 at 1:52 PM, Rolf Kalbermatter said: Works nice! But only as long as there is one single ActiveX/.Net control on the panel. When I found a way to obtain the object's pointer given its refnum, I remembered my old and currently declined idea on NI Forums - Ability To Get .NET/ActiveX Window Handle By Its Automation Refnum. The solution proposed there is not good for many reasons, so I decided to see, whether I could pull out a HWND of NI Container Clipping Window from LabVIEW's internals using the object's pointer only. After some experiments I have succeded! So, now it's clear that LabVIEW retains that HWND in the memory to be able to do some manipulations with the window (like resizing / moving etc.). Okay, here's my VI for getting a HWND from ActiveX or .NET Refnum. It requires Find BCJ for ObjRef.vi and Extract ObjRef Pointer.vi from this thread. ActiveX_NET_Refnum_to_HWND.rar Tested this on every LabVIEW version from 2009 to 2020 (both 32- and 64-bit and both IDE and RTE). There are some constant offsets hardcoded on the diagram, therefore it's not guaranteed to work in the upcoming LabVIEW releases. But on practice only the one offset could change and it's easy to find it out with Heap Peek. To do this (if needed): Place ActiveX or .NET object onto the panel and launch Heap Peek. Choose FPHP and find ActiveX Container in the objects list on the right (use F button to see the object). In the object's data space find streamData pointer (marked red on the picture below). You need the address right before this pointer (marked green). The offset, you want, is written on the left of the dump (marked blue). Just use this offset with your LV version and you're done. Quote Link to comment
Rolf Kalbermatter Posted October 31, 2020 Report Share Posted October 31, 2020 (edited) Well of course does LabVIEW have to retain the HWND of the container where it places the ActiveX Window. And this is simply a specfically allocated window handle for the container since an ActiveX control requires a parent window when being instantiated and LabVIEW for obvious reasons does not want to hand the full front panel HWND as that would give the ActiveX Control every possibility to mess with the LabVIEW owner drawn front panel (as you know LabVIEW controls, except the ActiveX and .Net Container are not implemented using window controls with their own HWND as with other standard Windows applications, but are fully owner drawn by LabVIEW itself). I still think that the approach with peeking into the object pointer to retrieve information, while being fun to do if you love this low level stuff, is an absolute and big NO-NO for anything that is supposed to leave your mancave. Edited October 31, 2020 by Rolf Kalbermatter Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.