Inventor Add-In - How To Display a Form?

Inventor Add-In - How To Display a Form?

Anonymous
Not applicable
4,213 Views
18 Replies
Message 1 of 19

Inventor Add-In - How To Display a Form?

Anonymous
Not applicable
Hello everyone,

I am sure this is very simple, but I can't seem to grasp it. I have created a new Add-In using the Inventor 2008 Wizard with Visual Studio 2005. The resulting Project comprises 2 Classes (Assemblyinfo.vb and StandardAddInServer.vb). I built the project and Inventor loads it fine. Of course there is nothing to see yet!

Like many developers I now want to develop a User Interface. Should I add a Windows Form or a User Control and how do I get it to display once I have added it?

Thank you.

Chris
0 Likes
4,214 Views
18 Replies
Replies (18)
Message 2 of 19

Anonymous
Not applicable
In VB?

Public Sub Main()
Form1.Show
End Sub

also, make it [Main Sub] your startup in VB.

bob


wrote in message news:[email protected]...
Hello everyone,

I am sure this is very simple, but I can't seem to grasp it. I have created
a new Add-In using the Inventor 2008 Wizard with Visual Studio 2005. The
resulting Project comprises 2 Classes (Assemblyinfo.vb and
StandardAddInServer.vb). I built the project and Inventor loads it fine. Of
course there is nothing to see yet!

Like many developers I now want to develop a User Interface. Should I add a
Windows Form or a User Control and how do I get it to display once I have
added it?

Thank you.

Chris
0 Likes
Message 3 of 19

Anonymous
Not applicable
Thanks Bob, that was quick!

I tried this and it worked:
In the StandardAddInServer Class I wrote

Dim MyForm As New Form1

Then within the Public Sub Activate I added a call to this subroutine:

Public Sub DisplayForm()
MyForm.Show()
MyForm.TopMost = True
End Sub

It worked and I assume is similar to your suggestion. Should I be concerned about if it is Modal or Modeless?

Regards

Chris
0 Likes
Message 4 of 19

Anonymous
Not applicable
VB(A) usually you want modeless. Not sure if VB.Net needs
or even supports that.

Bob S (not Bob)

Chris Molland wrote:
Should I be concerned about if it is Modal or Modeless?
>
> Regards
>
> Chris
0 Likes
Message 5 of 19

Anonymous
Not applicable
Hello Bob S

I have read that I should use the following:

MyForm.Show vbModeless

However when I do this Visual Studio automatically puts brackets around the vbModeless and then Errors "Name vbModeless is not declared". Any views?

Thanks
0 Likes
Message 6 of 19

Anonymous
Not applicable
It looks like in VB.Net the following has changed:

MyForm.Show acts like a vbModeless call
and
MyForm.ShowDialog acts like a vbModal call

Also, from another post found elsewhere:

One thing to remember in .net that Forms are just classes like any other
object - you have to create an instance before you can use it. VB6
automatically created the instance for you - .net doesn't.

Bob S.

Chris Molland wrote:
> Hello Bob S
>
> I have read that I should use the following:
>
> MyForm.Show vbModeless
>
> However when I do this Visual Studio automatically puts brackets around the vbModeless and then Errors "Name vbModeless is not declared". Any views?
>
> Thanks
0 Likes
Message 7 of 19

Anonymous
Not applicable
Thank you Bob S

That seems to make sense. I can give the user something to do now!

Regards

Chris
0 Likes
Message 8 of 19

Anonymous
Not applicable
Should we be allowed to discuss IV 2008 here yet?
Thx, Chris

--
CVAengineering At Gmail Dot com (Replace At with @, Dot with .)

IV11 Pro. sp2
Window XP Pro sp2
Pentium 3.2 Ghz, 3.0 GB of RAM
NVIDIA FX 3400 84.26
SpacePilot V 1.1.2
wrote in message news:[email protected]...
Hello everyone,

I am sure this is very simple, but I can't seem to grasp it. I have created
a new Add-In using the Inventor 2008 Wizard with Visual Studio 2005. The
resulting Project comprises 2 Classes (Assemblyinfo.vb and
StandardAddInServer.vb). I built the project and Inventor loads it fine. Of
course there is nothing to see yet!

Like many developers I now want to develop a User Interface. Should I add a
Windows Form or a User Control and how do I get it to display once I have
added it?

Thank you.

Chris
0 Likes
Message 9 of 19

Anonymous
Not applicable
I personally don't see a problem since we are not really delving
into any real aspects of IV2008, the real discussion in my eyes
is regarding differences between VB6 and VB.Net

CVAengineering wrote:
> Should we be allowed to discuss IV 2008 here yet?
> Thx, Chris
>
0 Likes
Message 10 of 19

Anonymous
Not applicable
I'm with you Bob S.
0 Likes
Message 11 of 19

Anonymous
Not applicable

I can't get this to work. 

I've made a form in another project and now I try to open my form in a new Addin Template. 

I Tried many suggestions, but I over look something.

 

Can someone help me on this please ? 

 

Public Class ButtonActions

    Public Shared Sub Button1_Execute()

        'TODO: add code below for the button click callback.
        'MessageBox.Show("Hello!")
        Form1.Show()

    End Sub
End Class

 

 

 

 

0 Likes
Message 12 of 19

Peterjan.Schakel
Explorer
Explorer

Hai Kubuz,

 

You need to declare the form before you can run the form for the first time. 

Public Class ButtonActions

    Public Shared Sub Button1_Execute()

        'TODO: add code below for the button click callback.
        'MessageBox.Show("Hello!")
         Dim Test1 as New Form1
        Test1.Show()

    End Sub
End Class

 

0 Likes
Message 13 of 19

JelteDeJong
Mentor
Mentor

i use the following code in my ButtonAction:

MyForm pf = new MyForm ();
var helper = new WindowInteropHelper(pf);
helper.Owner = new IntPtr(AddInSite.Application.MainFrameHWND);
pf.Show();

this is c# code but in vb.net you should be able to do the same (just in other syntax).

i have a "WPF" forum, im not sure if this also works for "winforms"

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

Message 14 of 19

Maxim-CADman77
Advisor
Advisor

@JelteDeJong 

Can you, please, clarify what meaning have "helper" an "IntPtr"?

 

Please vote for Inventor-Idea Text Search within Option Names

0 Likes
Message 15 of 19

JelteDeJong
Mentor
Mentor

This is a bit of an old thread. If you are trying to create a form I would suggest that you have a look at my tutorial "Creating an Inventor Addin. " and then especially at the part "Adding a form to your addin".

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

0 Likes
Message 16 of 19

Maxim-CADman77
Advisor
Advisor

@JelteDeJong 

Sorry for have necro-posted.
It was unintended - the thread was the first in search results by word "owner" * (and is not marked as solved). Should I create a separate thread for discussing some niceties of using forms?

 

I have no problem showing standard form by means of my Add-In. But I have some special requirements to it - I'd like my form behave more-or-less like a widget. I mean it should always be shown over Inventor window yet not block access to it's UI.

 

In order to keep access to UI I show my form as non-Modal, but it can easily get lost under Inventor window.
Losing widget under Inventor window can be workarounded by setting TopMost Property value to True ... but this seems like overkill (my widget will cover application showed over Inventor, if any).

 

I believe that my needs can be achieved by proper usage of owner, but I don't understand how to use it ...


*
I don't see word "Owner"  in neither of two articles you've mentioned.

 

UPDATE:
Let's discuss it here - https://forums.autodesk.com/t5/inventor-ilogic-and-vb-net-forum/create-custom-widget-in-a-graphical-...

Please vote for Inventor-Idea Text Search within Option Names

0 Likes
Message 17 of 19

dgreatice
Collaborator
Collaborator

Hi, try this.

dgreatice_5-1677122964541.png

 

 

dgreatice_4-1677122888269.png

 

 

dgreatice_2-1677122706812.png

 

base on this default hWnd Wrapper Class

dgreatice_3-1677122828478.png

 

 

 

Please use the ACCEPT AS SOLUTION or KUDOS button if my Idea helped you to solve the problem.

Autodesk Inventor Professional Certified 2014
0 Likes
Message 18 of 19

Maxim-CADman77
Advisor
Advisor

@dgreatice 

But how SetParent Method looks like?

Please vote for Inventor-Idea Text Search within Option Names

0 Likes
Message 19 of 19

dgreatice
Collaborator
Collaborator

dgreatice_0-1677136125974.png

 

Please use the ACCEPT AS SOLUTION or KUDOS button if my Idea helped you to solve the problem.

Autodesk Inventor Professional Certified 2014
0 Likes