Preventing Multiple VO Application Instances. 
Author Message
 Preventing Multiple VO Application Instances.

Hello all,

This is a methods final version for preventing multiple instances of
the same CA-VO application.

I would like to thank:
- John Forsberg, who wrote a CA-VO version of Charles Petzolds Sysmets
(Charles Petzold wrote Programming Windows 3.1). I gave me a clue on how
to type the variables.
- Michael Radford, who wrote a very good article about C and VO:
Converting C Data Types to Visual Objects, Visual Objects Advisor,
April/May 1996, page 28. It helped me to create the GlobalFindAtom()
prototype for VO.
- Jeff Prosise, whose article Prevent Multiple Win32 Application
Instances, PC Magazine US edition, volume 15, number 15, page 319,
showed me 4 ways to accomplish this task.

I discovered that:
- There is an undocumented CA-VO internal function that returns
hPrevInstance [ _GetPrevInst() ]. It compiles but you cant find it in
the libraries. The problem is that hPrevInstance is always set to NULL.
So the standard method for Win16 SDK does not work. I think the
designers of CA-VO/Win16 did this way to easier the migration of 16 bit
source code to CA-VO/Win32. hPrevInstance is defined by Microsoft in
Win32 SDK as been always NULL.
- The first method described by Jeff Prosise ( based in the SDK function
FindWindow() ) will not work because, to my surprise, all VO 1.0c-2
applications created using the VO GUI library are of class "
CvMdiFW_GLCV32MW" (yes, with a space as the first character of the class
name) . If the user has more than one VO application you can't use the
window class information. And you can't use the application name either
because, if you change the caption of the main window (as CA-SSA example
does), it will change the name of the window and the SDK function
FindWindow() will fail to find the application.
- Jeffs second method works. You can see the source code below.

Thank you comments,

**********************THE SOURCE ***************************

_DLL FUNC GlobalFindAtom(pszC AS PSZ) AS WORD Pascal:USER.270


    STATIC szAtomName := "Controle de Cheques" AS STRING
    LOCAL  szAviso                             AS STRING
    LOCAL Atom                                 AS WORD
    LOCAL oShellWindow                         AS StandardShellWindow

        IF GlobalFindAtom(String2Psz(szAtomName)) != 0

           szAviso := "O programa para controle de cheques j "+ ;
                      "est em funcionamento. Tecle Alt+Tab "  + ;
                      "para encontr-lo."

           MessageBox( 0                                ,;
                       String2Psz(szAviso)              ,;
                       String2Psz("Programa Ativado !") ,;
                       _OR( MB_ICONINFORMATION, MB_OK)     )



           Atom := GlobalAddAtom(String2Psz(szAtomName))

           SetDeleted( TRUE )

           oShellWindow := StandardShellWindow{self}

           // Show the ShellWindow
           oShellWindow:Origin := Point{0,0}
           oShellWindow:Size := Dimension{640,480}





Mon, 01 Mar 1999 03:00:00 GMT  
 [ 1 post ] 

 Relevant Pages 

1. preventing multiple instances of a 32 bit app

2. preventing multiple instances of the same menu item

3. Prevent multiple instances

4. Prevent multiple instances of a PHAR-LAP DOS EXTENDER program

5. Windows mutex to prevent multiple instances

6. Help! Preventing multiple instances

7. Preventing multiple use of application

8. Multiple Application Instances

9. Sharing VISA Resources With Multiple Application Instances

10. Execution times running multiple instances of an application

11. multiple embedded python interpreter instances in a *single*threaded application

12. Convert single instance tcl program to multiple instances...


Powered by phpBB® Forum Software