0

I have created a empty SolidWorks macro, using VSTA 3.0 C# projet.

I tried that very simple example. It "works" but the process continue. I want to show a form. And wait for user to hit button to do tasks or quit.

    public void Main()
    {
        var frm = new Form1();
        frm.Show();

        return;
    }

    // The SldWorks swApp variable is pre-assigned for you.
    public SldWorks swApp;
DanB
  • 2,022
  • 1
  • 12
  • 24

2 Answers2

1

try this:

        myForm.ShowDialog();

        bool frmResult = (bool)myForm.DialogResult;

        if (frmResult == true)
        {
               //do your thing
        }
        else
        {
            //do nothing
            // MessageBox.Show("Canceled, nothing to do");
            return;
        }

Eddy

Eddy Alleman
  • 1,096
  • 2
  • 10
  • 21
0

One way to do this is simply to add Application.Run() :

public void Main()
{
    var frm = new Form1();
    frm.Show();
    Application.Run(frm);

    return;
}

// The SldWorks swApp variable is pre-assigned for you.
public SldWorks swApp;
DanB
  • 2,022
  • 1
  • 12
  • 24