LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Set Parent window using User32 at lv7.1

Hello all,

I am using User32.dll to make a parent-child relationship between two VIs. I use SetParent function, and pass the handle of parent VI and child VI to this function. Now, after this relationship has been established, the child window postion is not fixed when refresh, attachment is my source code , Can anyone help me on this?

 

Thanks in advance!

0 Kudos
Message 1 of 11
(6,028 Views)

Did you see the two coercion dots on the Add Child VI? They are caused because the Get Window HAndle returns a U16 integer but the Add Child VI expects a 32 bit handle. And Handles in Windows 32 Bit are ... yes indeed 32 Bit wide. So you pass a truncated handle to Add Child, and since they are not a valid handle the function will simply return an error, that you dutifully don't even have wired up so it gets lost.

Rolf Kalbermatter
My Blog
0 Kudos
Message 2 of 11
(6,019 Views)

Rolf,

 

This bug will cause SetParent fail,  but not jump around when child refresh ?

 

I haven't try this VI yet.  Don't have LV7.1 on my laptop.

 

 

George Zou
0 Kudos
Message 3 of 11
(6,007 Views)

This has been an issue with LabVIEW from the beginning I believe.  It appears that LabVIEW doesn't look at the parent window when drawing its window, but the desktop.  If the window is a parent, the parent is the desktop, so if LabVIEW always looked at the parent, it would draw the window in the correct location.  So everytime the window is drawn at its location, it will jump by the distance between the front panel top left corner and the desktop origin.  If you take your VI and move it away from the top right corner of the desktop, you'll see the jump is even worse.

 

Now, in earlier versions of LabVIEW, it appears that it is redrawing every time it runs.  I tested your code in 2011, and it stays still while the main VI runs, every time I stop and restart main, the VI jumps.

 

The only thing I could ever come up with was to have the window reposition itself constantly.  NI could fix the issue by having LabVIEW look at the parent window instead of the desktop for its position.  But, since they don't really support child windows, I'm not holding my breath.

0 Kudos
Message 4 of 11
(6,003 Views)

I just tested VIs with LabVIEW 7.1

 

The problem is the design.  You call the child in a loop.  launch / close the child constantly.  That's the problem.

 

If you change the time delay from 1000 ms to 5000 ms.  You will see the jump whenever child gives called, not because refresh.

 

If the child don't have a loop, it can't stay open, then you shouldn't even use child/parent design.

 

One jump when set parent is understandable.  Any window does that, nothing wrong with LabVIEW.  It's the coordinate reference changed, from screen coordinate to parent coordinate.

 

I used SetParent since LabVIEW 5.  Works fine for me.

 

George Zou
0 Kudos
Message 5 of 11
(5,995 Views)

George,

 

Even if you don't keep running the VI over and over, the child window doesn't properly work in LV.  If you minmize the parent or child and restore the window, you will see the child jump by the offset of the parent's front panel to the desktop origin.  That is not normal behavior.  In 7.1, it appears LV is doing some update to the window causing it jump everytime the VI is run.  As  I mentioned in my earlier post, this problem doesn't exist in 2011.

 

Once the window is made a child of the parent, the window shouldn't jump around unless instructed to do so.  It shouldn't matter if he runs the VI over and over.  He can certainly get around the immediate problem by having the VI run once and pass the information into the subVI in another manner, but he will still see jumping issues if the user starts minimizing and restoring windows.

0 Kudos
Message 6 of 11
(5,989 Views)

I think there are actually several not necessarily related issues here. First of all when I tested this program in LabVIEW 8.6 (not having had an older version handy at that moment) the first thing I noticed, was that the VI never got parented at all. The reason was simply the data type mismatch in the handle between what Get Window Handle returns and what Add Child uses. Once I fixed that it worked like a charm with no jumping whatsoever.

 

So I did a test in LabVIEW 7.1 just now and indeed it does jump there. But, I wouldn't exclude that LabVIEW 7 migh have done it correctly for the OS (W2K) that was current at that time it came out. But there are really at least two solutions: Upgrade to a newer LabVIEW version, at least 8.6 works fine (8.2.1 didn't I just checked) or don't call the VI continously but let it run as an independant "process" and pass data by other means than through the connector pane (personally I would point out that globals are a bad way for this Smiley Wink)

 

And by the way, almost all Windows handles are actually pointer sized entities so if you happen to use such window managment VIs in LabVIEw 8.6 or higher it is advisable to not configure them as U32 but as pointer sized (unsigned) integer instead

Rolf Kalbermatter
My Blog
0 Kudos
Message 7 of 11
(5,979 Views)

LabVIEW doesn't support child / parent design.  It's SDI.

 

You can use SetParent to set up the child / parent relation.   You also have to take care the jump issue.

 

Rolf,

 

If you minimize the parent, and restore it, you will see the jump.

 

 

George Zou
0 Kudos
Message 8 of 11
(5,977 Views)

The better solution is to upgrade and use SubPanels. They do not jump at all, minimizing or not! With SubPanels you can do MDI, SDI, XDI or Super Duper DI or anything else you might want to do. I personally find MDI almost always the wrong solution, but that is me.

Rolf Kalbermatter
My Blog
0 Kudos
Message 9 of 11
(5,971 Views)

Thanks for all of you !

Just like Matthew Kelton mentioned ,maybe this issue is designed with labview . Lv8.6 above version have already solved this problem .

but i want used this with lv7.1 , just show data to user in child window . luckly , i find a way to meet my request in attachment .

0 Kudos
Message 10 of 11
(5,945 Views)