Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
One down - all dead (NetWork) VFP 3.0
Message
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00231634
Message ID:
00250251
Views:
20
Hi Edgar,

>I think I would like to enhance with " Single Instance ".
>>>The Single Instance (MUTEX Class from November '98 FoxPro Advisor) process
>
Keep it simple, starting from the beginning,

The easiest way for me to explain what's going on is to first do it very broad, general terms, and then get into the specifics.

How it works

A mutex is an object on the Windows level and therefore can be recognized by any Windows application. You might want to think of it as a global Windows object. A mutex, like VFP objects, has a name. The term comes from the words mutually exclusive. While any application can access it, it can only be owned by the application that created it.

Simply put, what happens is that when an application starts, it tries to create a mutex with a specific name. In my article, I used a modified version of the caption of the main form (_SCREEN if MDI, or the main SDI form's). If another instance of that mutex exists, a Windows error is generated(183 - ERROR_ALREADY_EXISTS).

The mutex class, as available on the Advisor web site, contains the necessary code to create this class. Your first step is to create a custom class from that code. It can be a prg or vcx, whichever you're more comfortable with. The base class, of course, should be custom. All you have to do is instatiate the object, passing the necessary parameters to the Init event, at the beginning of the code of your main program. After the object is created, all you have to do is check the nMutexError property. If its value isn't 183, then your program should continue as normal. If it is 183, the class contains a method to display the other instance of the application which should be called. The duplicate should then terminate.

The article on the site also contains some generic code that can be implemented into an existing application fairly easily. The only problem with the code there is that the indentation structure doesn't display. So it's simply a matter of copying the code from the site, and properly placing it in your program.

What's the first step(s) in preparing an application for being recognized as already active?

Depending on how you implement it, either SET PROCEDURE TO... or SET CLASSLIB TO..., then create the object. Next, check the object nMutexError property to see if it's 183.

Will I be required to load any special programs?

No.

WorkStations are : Win95, Win98, and WinNT.

This should work with any Win32 based OS.

Network Application contains 7 tables + 2 Linked Tables largest 31K records.

Shouldn't be a factor.

hth,

George

>Application Hiearchy follows:
>Main.PRG calls MAIN FORM SET
>MAIN FORM SET can call 7 other ENTRY Forms or Ten Reports or Report Builder
>Closing any report or ENTRY Form returns the user to the MAIN FORM SET
>Exiting the MAIN FORM SET returns to Main.PRG and runs Clean-UP code and Quits!
>
>HISTORY:
>The code @ 'Creating the MUTEX class' was originally placed in my Main.PRG but Did Not seem to work ---
>I then tried to create a Form Class named MUTEX, to contain the code in the init
> --- still nada
>ran out of time.
>I'm back, Let's find a place for the PROCEDURE Init code.
George

Ubi caritas et amor, deus ibi est
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform