| View previous topic :: View next topic |
| Author |
Message |
filip Valued Contributor


Joined: 07 Aug 2004 Posts: 340
|
Posted: Wed Sep 14, 2005 1:00 pm Post subject: Application is allready running... |
|
|
| How to check if application is allready running and won't be started again ? |
|
| Back to top |
|
 |
Tdk161 Valued Contributor


Joined: 08 Feb 2005 Posts: 399 Location: ITALY
|
Posted: Wed Sep 14, 2005 2:29 pm Post subject: |
|
|
Hi, I use this simple method
| Code: |
#Define Function,IsOpen
If @IsOpen(MyDialog)
Stop
End
Dialog Create,MyDialog,-1,0,115,606,NOMIN,SAVEPOS,SMALLCAP
...
...
....
:IsOpen
# Param %1 = DialogName To Test if running or not
If @WinExists(%1)
Exit 1
Else
Exit
End
|
I hope that this little code will help you  |
|
| Back to top |
|
 |
PGWARE Web Host

Joined: 29 Dec 2001 Posts: 1565
|
Posted: Wed Sep 14, 2005 2:33 pm Post subject: |
|
|
Tdk161 that is a very good idea, however I'd recommend using a Windows class instead.
during the DIALOG CREATE command you can add a CLASS MyWindowName
to define the window class name for your program.
You can then check if the classname #MyWindowName exists as Tdk161 pointed out and terminate so duplicates dont run. Using a window class name I think is better in case some other program may contain the same name as your program - while unlikely it may in certain situations. |
|
| Back to top |
|
 |
filip Valued Contributor


Joined: 07 Aug 2004 Posts: 340
|
Posted: Mon Sep 19, 2005 5:46 pm Post subject: |
|
|
#Define Function,IsOpen
If @IsOpen(MyDialog)
Stop
End
Dialog Create,MyDialog,-1,0,115,606,NOMIN,SAVEPOS,SMALLCAP
...
...
....
:IsOpen
# Param %1 = DialogName To Test if running or not
If @WINCLASS(%1)
Exit 1
Else
Exit
End
Is this OK
it works OK
I have one more REQUEST...
If Program name (runed and minimized)
Second run of Program name (how to show it on desktop)
If you know what i am saying... |
|
| Back to top |
|
 |
SnarlingSheep Professional Member


Joined: 13 Mar 2001 Posts: 759 Location: Michigan
|
Posted: Tue Sep 20, 2005 2:38 am Post subject: |
|
|
I think this is the best way.
Compile the code, run it once then minimize the window and run it again.
| Code: |
if @WINEXISTS(#AlreadyRunningWnd)
INFO Program is already running.. activating first window.
WINDOW ACTIVATE,@WINEXISTS(#AlreadyRunningWnd)
exit
end
Title Already Running
DIALOG CREATE,Already Running,-1,0,240,160,CLASS AlreadyRunningWnd
REM *** Modified by Dialog Designer on 9/19/2005 - 22:34 ***
DIALOG SHOW
:Evloop
wait event
goto @event()
:Close
exit
|
_________________ -Sheep
My pockets hurt... |
|
| Back to top |
|
 |
filip Valued Contributor


Joined: 07 Aug 2004 Posts: 340
|
Posted: Tue Sep 20, 2005 5:18 am Post subject: |
|
|
Yes, Thanks about the WINDOW ACTIVATE is just pure and simple...
I have add a title line too... |
|
| Back to top |
|
 |
vtol Valued Contributor


Joined: 05 Feb 2004 Posts: 656 Location: Eastern Indiana
|
Posted: Fri Sep 23, 2005 7:36 pm Post subject: |
|
|
I've allways done it SnarllingSheeps way with no problems..  |
|
| Back to top |
|
 |
|