Read my post under thread184-67376
Those explanations can be used to limit the number of instances.
In a desktop, however, a different approach can be taken. Open a DBF or any file for that matter when the application starts and leave it open till the aapplication quits .. or.. an accidental closure will auto release it.
If when you start an application, if this file is read only, you can safely assume that the application is already running and warn the user.. and quit.
Your Main.PRG. shall start with the following line...
=myInstance("A name for your Application"
Then uust copy the following code and add it at the end of your main.prg.
******************************************
PROCEDURE myInstance
PARAMETERS myApp
=ddesetoption("SAFETY",.F.)
ichannel = DDEINITIATE("myapp","ZOOM"
IF ichannel =>0
=DDETERMINATE(ichannel)
QUIT
ENDIF
=DDESETSERVICE("myapp","define"
=DDESETSERVICE("myapp","execute"
=DDESETTOPIC("myapp","","ddezoom"
******************************************
PROCEDURE ddezoom
PARAMETER ichannel,saction,sitem,sdata,sformat,istatus
ZOOM WINDOW SCREEN NORM
RETURN
*****************************************
The code was provided by another tek-forum member Nigelgomm and I have just polished it with my wraping. See thread thread182-81006 My appreciation to Nigelgomm. ramani :-9
(Subramanian.G)
FoxAcc
ramani_g@yahoo.com
LET KNOW IF THIS HELPED. ENOUGH EXPERTS ARE HERE TO HELP YOU OUT! BEST OF LUCK
Hi jmcswain,
See the following:
thread184-59381
thread184-36129
Ramani,
When you performed your wrapping, shouldnt you have change all occurrences of "myapp" to myapp, so that it uses the parameter variable myapp as the published service ISO the literal "myapp"? ;-)
IOW, shouldnt your code look something like (emphasis in red):
Thanks Jon, Good you pointed out.
I have made it a FAQ and with your correction, have posted it. Thanks. ramani :-9
(Subramanian.G)
FoxAcc
ramani_g@yahoo.com
LET KNOW IF THIS HELPED. ENOUGH EXPERTS ARE HERE TO HELP YOU OUT! BEST OF LUCK
Thanks to all for the tips here and the links to other threads.
My application is unusual, however, in a couple of ways. In particular, it's a tray application that can also open up into "regular" application mode. When you "close" the app by clicking the control box, I simply hide the main form, leaving the tray icon active.
2 Questions: Will FindWindow API calls work for hidden windows? And, the big one, anybody know how to add a menu to my tray icon?
Dont quite understand why you consider that unusual. Sounds like a typical NT service to me.
To answer your questions:
Yes, FindWindow will work for you when you MyTopLevelForm.Hide or _Screen.Visible = .F.
AFA the menu, re-read the replies from the last time you asked that question: thread184-89849
Bela has added menu support for his FLL. IIRC, it also supports the mark character, similar to that of the SET MARK OF command in VFP. Although, he states in that thread that the official launch isnt until August, its been available on his site since June 7. Jon Hawkins
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.