Is there any way to....

rcody
11-20-2000, 10:32 AM
Hi,

Is there any way to limit how many instances of a program (multiple windows) that are opened at any given time. For example, say the user has one Internet Explorer window opened, and then tries to open a second one......how can I prevent the user from opening another one, yet leave the first one alone?

I'm using VB5.

Thanks,
Ron

nwood
12-03-2000, 10:43 PM
I would search the API for a similar function as VB's "PrevInstance" property of the "APP" funtion. If you're unfamiliar with this open a program and type the following code:

If App.PrevInstance Then
MsgBox "This program is already open"
End
End if

Keep in mind though that this would only work if your VB was creating an instance of IE from within the application itself, not if you simply open IE two separate times...in which case I think there is a similar API function to PrevInstance...

Neal Wood
AxxisLogic Sytems

Ryan231
12-31-2000, 01:05 AM
how screensavers do it is put this in the form load event of your startup form

If App.PrevInstance=true then end

that way it will shut down if one is already running.<P ID="edit"><FONT SIZE=-1><EM>Edited by Ryan231 on 12/31/00 02:18 AM (server time).</EM></FONT></P>

ruti_gl
01-01-2001, 01:39 AM
By the way, it is preferrable to put the above mentioned
code not into Form1_Load(), but into
Form1_Initialize() Event, because it will be performed faster.

Best Regards!

Ruth Glushkin

amram71
01-01-2001, 05:49 PM
Guys, what rcody is asking is how to prevent multiple instances of other apps, not the one he is making...

previnstance would NOT work when trying to control other programs instances... what you would probably have to do is use a timer and use API to check how many windows are open... if more than one...then close one... this won't let the user do anything on the second Internet explorer or whatever because it'll close it right away.

lj78
01-01-2001, 07:01 PM
This is probrely COMPLETELY wrong but I'll give it a wrill. Try:

Private sub cmdOpenBrowser_Click()
If frmBrowser >=1 Then
Msgbox "Sorry browser already opened",VbExclamation,"Browser1"
frmBrowser.Unload
Else
frmBrowser.Show
End if
End sub

It's a guess but, I hope it works.

~~~~~~~

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum