First of all, allow me to congratulate you on getting this to work. This could be a useful feature and I will think about whether or not I should use it myself for certain things. The main reason this isn't working for you second window is that FindWindow will no longer help you since it doesn't find child windows, so it can't get the handle to the child window. You have 2 options. You can use FindWindow and build the chain from the bottom (if possible). This means you turn a window into a child, then you turn the parent into a child and so on. This has the disadvantage of only allowing you to add new child windows to the top level parent window. The second option is to use FindWindowEx which does find child windows. Its structure is slightly different (you can find it in MSDN, use U32 for the handles), but it should work if you give it the right names. You will have to write some logic for when to use FindWindow and when to use FindWindowEx and you will have to modify LabUseful's VI or create a copy of it for this to work. One last thing you should watch out for is the window names. The names change according to the VI state - If it's running, just the name. If not, there is also "Front Panel". There could also be an asterix. If you give it a unique name, it could also change. This will probably not matter in runtime, but it could be an issue during development. Last thing, please don't post the same question to multiple threads. The most this can do is annoy people who see they wrote a long response (like this one) and then see that someone already gave a response in another thread. Also, have patience. These things take time. Hope this helped.
FindWindowEx has 2 additional parameters which are hWnds (U32). The first is for the top level window and the second can be null. I suggest you write another VI (Create Child N3?), which will accept both inputs for the VI names and either a third input or the hWnd from the previous call and will use the code which is in CC N2 to get a handle for the window that's about to become a child and FindWindowEx to get the hWnd for the window which is about to be the parent. Maybe you should change CC N2 to accept hWnds instead of VI names. I don't have time to think about this at the moment, but maybe I will tomorrow. In the meantime I suggest you try to implement this and I promise not to forget.
OK. Here's a quick version I created. It's very messy and it may have bugs, but it worked for me. Clean it up and test it to see that it works fine. I added another VI which uses findwindowex and which needs the name of 3 VIs. As a first step, use Embed 2 to embed one window into another. Then, use Embed 3 to embed a window into a child window. If you clean it up, post your results, so other people can use this.
I am testing your vis. I have 3 windows: test.vi (yours), myVI_MOD.vi and mySubVI_MOD.vi. I want to embed myVI_MOD.vi inside test.vi when I press button embed 3windows2 I created in test.vi. Then when myVI_MOD.vi opens, I want to embed mySubVI_MOD.vi inside myVI_MOD.vi when I press the button call my Subvi. Then myVI_MOD.vi is child of the parent test.vi and mySubVI_MOD.vi is child of myVI_MOD.vi (in this case myVI_MOD.vi would be parent of mySubVI_MOD.vi) but it doesn't work. What's happen?
I attach you my example. I have done it in LV7 express.
I only had a quick look at your modifications, but I believe at least one problem is that the window name is "Main VI [myVI_MOD.vi] Front Panel" and that's not what you're giving the DLL. To find this, I opened the create child VI and let the code run once. That way, the values were entered into the controls. Then, I placed probes on the windows handles and on the windows titles and immediately saw that the handle was 0. There may be more of these problems. In general, this example was just something I put together very quickly and it came out very messy. If you want to keep using it, I suggest you clean it up and maybe place some documentation on the code. Also, you may want to give some thought to the possible windows names. As you can see, the few cases I covered in my code are clearly not enough. If you manage to improve this code, post your results - I'm sure other people would like to have this as well.
Not without modifying my VI. This has to be a 2 stage step, because once you embed one window into another, you have to use findwindowex, because the window handle is different. You can modify the code to do this like this:
1. If All inputs are wired, use findwindow and setparent on the relevant window and then use findwindowex to find the new handle and use setparent again. 2. If only 2 of the input are connected, perform only the first step.
This way, the VI will handle both cases. Like I said previously, this VI is only something I wrote as a quick demo. It's very messy and it doesn't handle all cases. You really should clean it up and document and test it if you plan on using it.