LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

MDI in CVI applications?

Hi,

 

I'm trying to make an application using MDI in CVI.  I've run across a few old threads from people attempting to do the same thing.  It seems that the general way of doing it is to:

 

1.  Load the 'child' panel as a top level panel.

2.  Use the SetParent(...) function in the Windows API to make the top level panel a child window in my application.

3.  Call DisplayPanel(...) to show the child window.

 

At first glance, this seems to work.  Except, it doesn't really.  The main one is that CVI doesn't see these child windows as children of the top level panel.  As such, function calls like

GetPanelAttribute(parent, ATTR_FIRST_CHILD, &child)

Don't seem to work.  However, since I know what child panels I've loaded I can manually track this myself in my application so it's a bit more work but doable.

 

However, where I've really run into a problem is that I would like to have scroll bars in my parent window..  Since CVI doesn't "see" the child windows, when I drag a child window off the side of the parent, the parent window doesn't realize that something is out there and the scroll bars won't activate.  To make matters even worse, the child window is drawn on top of the scroll bars which is undesirable.  I tried a few tricks such as a transparent control that I can set at the bottom right of the parent window to make the scroll bars activate (works, but the children are still drawn on top of the scroll bars). I also tried creating a larger 'inner' CVI child panel inside the parent (also gets the scroll bars to work), and loading the child windows into it (doesn't work).  This didn't work as CVI child panels aren't real 'windows' so the trick above doesn't work on them.

 

So what I'm getting at, is there a better way of doing MDI in CVI now?  Or is there a way of getting close/maximize/minimize controls in the titlebar of native CVI child panels, which is really what I'm after?  Thanks.

 

0 Kudos
Message 1 of 6
(4,742 Views)

Hello stanley!

 

You can refer to the MDI CVI sample application which illustrates the use of MDI with CVI application.

The sample source code ships with CVI and is located at <CVI Install Directory>\samples\apps\mdiServer\

 

Best regards!

- Johannes

0 Kudos
Message 2 of 6
(4,669 Views)

Thanks for the reply, but that example isn't really what I'm trying to do.  That example just uses the built-in CVI child panels which don't have the Close/Maximize/Minimize buttons. 

0 Kudos
Message 3 of 6
(4,643 Views)

Hello again, stanley!

 

Unfortunately builtin-in CVI child panels don't have support for minimizing/maximazing.

FYI, there already is an Idea Exchange from 2011 on this topic, which you can find at: http://forums.ni.com/t5/LabWindows-CVI-Idea-Exchange/MDI-behavior-of-child-panels/idi-p/1481006

 

Best regards!

- Johannes

0 Kudos
Message 4 of 6
(4,617 Views)

I found an example that shows how to create child panels in CVI:

Creating a Child Window Inside a LabWindows/CVI Top-level Panel to Simulate Multiple Document Interface (MDI) Applications

http://www.ni.com/example/26061/en/

 

However, this functionality will depend on your version.  The example above claims that child panels lose the functionality you are looking for when they become a child.  I also found a post on the Idea Exchange that claims CVI 2010 does not have this functionality:

 

MDI behavior of child panels

http://forums.ni.com/t5/LabWindows-CVI-Idea-Exchange/MDI-behavior-of-child-panels/idi-p/1481006

 

I have tested the example with CVI 2012 and 2013 and the child window in the example shows up in both with the minimize, maximize, and close buttons.  

 

I also found a document which addresses the failure of the GetPanelAttribute() call:

Can I Get a Windows Handle (HWND) for a Child Panel in LabWindows/CVI?

http://digital.ni.com/public.nsf/allkb/987432B1A46DE25786256FF1006E16B4

 

It looks like you should have this functionality if you are using CVI later than 2010, otherwise you will likely need to upgrade to get this functionality.

 

Thanks,

0 Kudos
Message 5 of 6
(4,615 Views)

Hi Charles,

 

Thanks for the reply, but I've already tried something similar.  It seems to work, but I quickly ran into problems, pretty similar to the problems described in the Idea Exchange post that Johannes linked to in regards to scroll bars.  Which seems to boil down to the fact that "child" windows done this way aren't recognized by CVI as child panels which leads to various quirks like that.  It may be workable for a simple application, but for something more complex it looks like I'll have to figure something else out (like use tabs).  Thanks.

0 Kudos
Message 6 of 6
(4,561 Views)