4 Replies Latest reply on May 8, 2014 10:09 AM by Marcin Pilat

    Embed/Display modelview inside a control tab

    Marcin Pilat

      We have the following situation. We create a new control tab using the DisplayWindowFromHandle functionality. This API method "displays a .net control in this model view". One of the parameters to the method is whether to split the window. Giving false will create our control to span the whole view area. The question is, how can we embed/display the current model view inside that view area? Any suggestions are much appreciated. Embedding would be best since it would be good to preserve the same look and feel of the model view tab in our control tab (with additional things drawn on top for example). New Window functionality is not acceptable since that will create a new window, not a new tab. If this is not possible using the DisplayWindowFromHandle method, can can something like this be done? The functionality we want is best represented using the Simulation Addin's study tabs.

        • Re: Embed/Display modelview inside a control tab
          Artem Taturevych

          You may try to play with model window handles (ModelWindow::HWnd/ModelView::GetViewHWnd and corresponding x64 version methods) to change the parent of the model window to be your control rather SolidWorks but this will break the message queue between SolidWorks and child window so you have to handle this somehow on your own risk. I personally wouldn't suggest to do this. It is better to split the view having your control panel at the bottom of the view and the native model view on top. You then can use OpenGl, GDI+ graphics to draw on top of model view. I believe this is how Simulation add-in works. It doesn't look like the model view is a child of an ActiveX control.

          ______________________________________________

          Regards, Artem Taturevych | Snr. Developer | IC3D ANZ

           

          IC3DSteel – New Steel Solution for SolidWorks

          translationXpert – SolidWorks files language translator

          LinkedIn - SolidWorks API Group

            • Re: Embed/Display modelview inside a control tab
              Marcin Pilat

              Thank you for your reply. Setting the control to a parent crashes the application and without knowing what the message queue is doing exactly underneath the hood, it's risky to do it like you say.

               

              Our first idea was to use the split view functionality but we haven't found a way to modify the size of the split window programatically. Will have to try again to hack something with the win32 api calls but there doesn't seem to be an API for that. Ideally, we'd like it to look just like the Simulation addin (as described in a previous post).

                • Re: Embed/Display modelview inside a control tab
                  Artem Taturevych

                  Hi Marcin,

                   

                  Ok, so you are talking about the tab in the Feature Manager Tree (as shown on your first picture from previous post) not the model view tab at the bottom

                   

                  In order to do what you want you need to use the ModelViewManager::CreateFeatureMgrControl3 to add the control to Design Tree. You need to specify bottom pane in the parameter. Then just call the ModelDoc2::FeatureManagerSplitterPosition with value 0.5 to put the splitter in the middle.

                   

                  Please read the remarks section here: http://help.solidworks.com/2013/English/api/sldworksapi/solidworks.interop.sldworks~solidworks.interop.sldworks.imodelviewmanager~createfeaturemgrcontrol3.html

                  ______________________________________________

                  Regards, Artem Taturevych | Snr. Developer | IC3D ANZ

                   

                  IC3DSteel – New Steel Solution for SolidWorks

                  translationXpert – SolidWorks files language translator

                  LinkedIn - SolidWorks API Group

                    • Re: Embed/Display modelview inside a control tab
                      Marcin Pilat

                      Thanks for the suggestion Artem. It's a bit more complicated than that. We already have a feature manager tab working for a slightly different purpose so the question is indeed about the model view tab at the bottom.

                       

                      After a lot of testing and trying various things there doesn't seem to be any API to do what the Simulation addin is doing. When you add a control using one of the API fuctions of the feature manager, it will be created either at the bottom or top pane as specified with the parameter as you describe. The splitter can be used to control the sizing of those two panes. However, with the Simulation addin, the simulation properties tree is created using a different method. You can try this yourself by creating a simple Simulation study and then you can change the position of the feature manager splitter with the mouse ending up with 3 different sections: the top pane, the bottom pane, and the simulation properties tree at the bottom of them all. Also, when a new study is created, a model view tab is added for that study so the functionality is very similar to that of adding a control to the model view tab although the control window somehow gets inserted on the left hand side instead of on the bottom.

                       

                      Similar situation occurs with the motion study tab. when activated, you see a control in the bottom (very similar to adding a control to the model view at the bottom). But when you click the little arrow in the top right corner of the control, it shrinks the control down to a small line at the bottom and the rest of the functionality is located under the feature manager panes (just like with the simulation study properties).

                       

                      The API concerned with the model view tabs is as follows (based on our findings - IModelViewManager class):

                      DisplayWindowFromHandle/x64 - creates the tab from .Net control asigning a name to it

                      AddControl.. - for ActiveX so never used it but similar to DisplayWindowFromHandle

                      ActivateControlTab - activates a tab given its name

                      ActivateModelTab - activate the model tab

                      DeleteControlTab - deletes a tab given its name

                      GetControl - doesn't work for .Net - maybe only for ActiveX?

                       

                      This is a very limited set of API. It would be nice to have access to more.