I have written a macro in SW VSTA and would like to make the form modeless so that parts can be selected in the SW window while the program is running. In the main module I am using Form1.ShowDialog() to show the form but I can not select anything in SW. Using the VB6 Form1.Show 0 does not work nor does Application.Run(Form1).

How does a person make the form modeless?
Dan Miel
SW 2009
SolidworksApi macros
Form1.ShowDialog() will stop the code untill the form is close this is for a dialog type window
use Form1.Show() this is show the form but then continue in the code
Jacob
When I try to use Form1.show the form will flicker on for a moment then disappear. I believe that this as caused because the form is declared as form 1 in the module, then when the form shows it loses the declaration.
In this example the form flickers on and off
Dim Form1 as New Form1
Form1.show()In this example the program errors
Dim Form1 as New Form1
Form1.show(0) DanDim Form1 As Form1
Set Form1 = New Form1
Form1.Show (0)
Dan
look at http://tinyurl.com/ykvhxwj
The Form1(Me) starts a form modeless if there is a form activated already and a form is started from the first form. In SW VSTA I can not find an option to start the program from a form like you can in .Net. It looks like I need to start it from the module.
I can not figure out how to start a modeless form from a module. I have attached a sample program that creates forms but the first form “Form0” is model not modeless, the rest of the forms are modeless.
Thanks for your input.Dan Miel
Howdy,
I was just looking for the same thing. I discovered the following:
Required in the General Declarations:
Imports System.Windows.Forms.Form
Then either of the following should work in the main() or starting sub:
' show form
frm_FstDrw.ShowDialog() 'show nonmodal
frm_FstDrw.Show() 'show modal
Hope this helps
I found that on my machines, using Form1.Show() will not show my form when I debug the program. After I build the program and connect a button to run the dll file the form shows and I can select parts in the SW window.
When I tried using Application.Run(Form1) it gave me an error me the error "The name Application is not declared" until I imported System.Windows.Forms then in debug the form will show but I can not select parts in SW. After doing a build and using the dll file the form will show and I can select parts.
Is anyone finding similar behavior or am I still missing something?
Tobin. Thanks for the hint on Import Forms.
Dan Miel
Howdy,
I've attached a new copy of the SWFormMacro.zip with a few changes.
On my machine it alows me to select SW objects while the form is showing in Debug mode.
Hope this helps
This macro does the same thing that my tries have done. When I debug the form flashes on the screen and disappears. If I build it and then run the dll the form stays and I can select parts in SW as expected. I guess I'll be looking at my machines to see what is goofy.
Thanks
Dan
SW 2009
This is discussed extensively and the solution is:
http://forum.angelsix.com/viewtopic.php?f=5&t=85
http://forum.angelsix.com/viewtopic.php?f=30&t=53
Those links are broken
Dear Dan Miel,
I have got stuck in the same problem for such a long long time. However, I recently get the good new from the senior programmer about resolution. Please do this things
-First, we have to get the 'SolidWorksMacroStartup.cs' open by right click the partial class name 'SolidWorksMacro' shown below\
-Choose 'Find All References', we will get the reference list and, in the list choose the file shown below
-When the 'SolidWorksMacroStartup.cs' open goto the line shown below and comment it out
-Compile and get the form shown modeless!
Credit: P' Nin songsak@z-byte.com
'btnOK : first Create a Button in your form and set its name to btnOK
Dim frm As Form1 = New Form1
frm.Show()
While frm.btnOK.Disposing
':-)
End While
use this :
Imports System.IO'#######
Imports SolidWorks.Interop.swconst
swApp.SetUserPreferenceToggle(swUserPreferenceToggle_e.swStopDebuggingVstaOnExit, False)
Dim f As Form1 = New Form1()
f.Show()
'System.Windows.Forms.Application.Run(f)