Community
Showing results for 
Search instead for 
Do you mean 
Reply

Open a new Form in a Plugin?

Accepted Solution Solved
Copper Super Contributor
Posts: 88
Country: USA
Accepted Solution

Open a new Form in a Plugin?

Hi!

 

First of all, THANK YOU to all who have replied to my messages. I am rapidly learning how to program Plugins and their Methods and Events.

 

I wonder if it is possible to open a new Form on top of ACT! when I click on a Button. I would like to create form using Design tools and not programatically, if possible.

 

Any suggestions? Sample code? How would I call (and release) the Form?

 

Thanks!


Accepted Solutions
Solution
Accepted by topic author kimkamp22
‎09-25-2015 03:20 AM
Copper Super Contributor
Posts: 88
Country: USA

Re: Open a new Form in a Plugin?

OK ... I got it.

 

I need to create a new Instance of an existing form, then use that Instance.

 

I have an existing Form called "Form1". I can open and use the Form in a Plugin. Here is the code:

 

                Dim aform As New Form1()
                aform.Show()

 

I plan on using this Form to create and manage settings for my Plugin.

 

Thanks - this opens up a whole new set of possibilities>

 

Kim

View solution in original post


All Replies
Employee
Posts: 1,163
Country: USA

Re: Open a new Form in a Plugin?

Yes, this is absolutely possible. How you choose to launch your form is totally up to you, you could have a menu item, a button on the toolbar or have it fire based on some event. 

 

From within the API we have a method LoadSDIView, which accepts a windows form as it's only parameter and launches it as if it were a view in Act, it should be noted however that it is not a new view so it isn't accessible in the same ways a view would be. Alternatively, via .Net we can use System.Diagnostics.Process.Start, this will start a process, you can create a seperate executable and launch it this way. 

 

There are definetly alternatives to this.

Matthew Wood
Act! SDK Support
Community Moderator
Copper Super Contributor
Posts: 88
Country: USA

Re: Open a new Form in a Plugin?

Do you have any Code to show in a Plugin how to open a Form, and how to close the Form?

 

I am familiar with running an external program to do this. What is the best way to pass Parameters using this method?

 

Thanks!

 

Kim

Employee
Posts: 1,163
Country: USA

Re: Open a new Form in a Plugin?

I used the sample plugin and added a new method that fires when the new menu item is selected:

 

private void OpenForm(string str)

{

System.Diagnostics.Process.Start(@"C:\File Locations\WindowsFormApp.exe");

}

 

I prefer this over LoadSDIView, but incase you wanted to try it:

 

Form form = new Form();

ActApplication.LoadSDIView(form);

 

As I mentioned earlier, this opens your form in the application as if it were a new view, but the view you changed from doesn't get disposed. So if I call this while on the contact detail screen, Act will continue to think I'm on the contact detail view even though my form is showing.

 

To dispose of it or move away from it, I added buttons to the form navigate to another view:

 

private void btnListView_Click(object sender, EventArgs e)

{

ActApp.UIContactManager.ShowListView();

}

Matthew Wood
Act! SDK Support
Community Moderator
Bronze Super Contributor
Posts: 1,231
Country: USA

Re: Open a new Form in a Plugin?

If you are just looking to open a form on top of ACT as a dialog then you can always:

 

Form form = new Form();

form.ShowDialog();

 

-- Jim

Copper Super Contributor
Posts: 88
Country: USA

Re: Open a new Form in a Plugin?

Thanks, Jim, for the reply.

 

OK...I can open a new form using your code:

 

   Form form = new Form();

   form.ShowDialog();

 

 

Is it possible to design a Form in vb.Net that can be opened in the Plugin?

 

 

// I have a form designed in vb.NET named FormTest

   Form formA = new Form() formtest;

   formA.ShowDialog();

I don't know if this is possible - thanks for any suggestions.

 

Kim

 

Employee
Posts: 1,163
Country: USA

Re: Open a new Form in a Plugin?

Absolutely, there are a lot of options for how, were you wanting to open the form from a menu item/toolbar icon? Or based on some event?

Matthew Wood
Act! SDK Support
Community Moderator
Copper Super Contributor
Posts: 88
Country: USA

Re: Open a new Form in a Plugin?

[ Edited ]

I'd like to open a form using a Button.

 

Once I understand how to open a Form, I can code the event to a Field.

 

My Form is called FormTest.

My UserControl (TabPage) is called UserControlTest.

I am running the UserControl in a TabPage Plugin in ACT 2011.

 

I would love to see code (either VB or C#) that would open a Form from a UserControl, and then close the Form and give the focus back to the UserControl.

 

Thanks!

 

Kim

Bronze Super Contributor
Posts: 1,231
Country: USA

Re: Open a new Form in a Plugin?

[ Edited ]

Kim,

I posted an example VB VS 2008 example plugin which adds a tab to the Contact Details view. This tba holds a user control. On the user control there is a button named Button1.

 

http://community.act.com/t5/Sage-ACT-Developer-s-Forum/Sample-Plugin-to-add-a-Tab/m-p/150248/highlig...

 

In the code change  the Button1_Click event

FROM:

MessageBox.Show("Thank You")

TO:

Dim MyForm as new MyForm()

MyForm.ShowDialog

 

Hope this helps.

-- Jim Durkin

Copper Super Contributor
Posts: 88
Country: USA

Re: Open a new Form in a Plugin?

[ Edited ]

Jim:

 

Again, thanks for the reply.

 

I did look at your example to open a brand new Form within a Plugin.

 

What I'd like to do is to open a Form (with a variety of Controls) that I designed in vb.net before I compiled the DLL. That way, I can layout the Form to be opened through the designer instead of creating a new one on the fly.

 

Any suggestions/code?