PDA

Click to See Complete Forum and Search --> : I could really use some help forcing only one instance.....


Daniel_Christie
May 6th, 2000, 04:00 AM
I need to force only one instance of my Program. I have a proggie that on Form_Load it loads up another form which is placed into the Systray as an icon. I can't seem to force only one instance of my program without messing up my Icon in the systray. Currently the form that loads into the systray gets knocked out of the systray and soaks up massive system resources while is repeatedly flickers. How can a Force of "one instance", be correctly and cleanly accomplished?

(Preferablly with the least amount of coding....The proggie is starting to get seriously cluttered with code.)

I appreciate any time or efforts spent,
Daniel christie

Sam Finch
May 6th, 2000, 04:52 AM
ok, you need a standard module, set the projects startup object to Sub Main and


Sub Main()

If App.PrevInstance Then 'If App is already ruunning

MsgBox "Program is already Running"

Else

Load Form1 'I'm assuming Form1 is the startup object

End If

End Sub



Hope this helps.

Sam Finch
May 8th, 2000, 12:07 AM
actually one of the more general rules of programming is to try to do what you need to do with as little code as possible.