forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Application is allready running...

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help
View previous topic :: View next topic  
Author Message
filip
Valued Contributor
Valued Contributor


Joined: 07 Aug 2004
Posts: 340

PostPosted: Wed Sep 14, 2005 1:00 pm    Post subject: Application is allready running... Reply with quote

How to check if application is allready running and won't be started again ?
Back to top
View user's profile Send private message Send e-mail
Tdk161
Valued Contributor
Valued Contributor


Joined: 08 Feb 2005
Posts: 399
Location: ITALY

PostPosted: Wed Sep 14, 2005 2:29 pm    Post subject: Reply with quote

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 Very Happy
Back to top
View user's profile Send private message Send e-mail
PGWARE
Web Host


Joined: 29 Dec 2001
Posts: 1565

PostPosted: Wed Sep 14, 2005 2:33 pm    Post subject: Reply with quote

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
View user's profile Send private message
filip
Valued Contributor
Valued Contributor


Joined: 07 Aug 2004
Posts: 340

PostPosted: Mon Sep 19, 2005 5:46 pm    Post subject: Reply with quote

#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
View user's profile Send private message Send e-mail
SnarlingSheep
Professional Member
Professional Member


Joined: 13 Mar 2001
Posts: 759
Location: Michigan

PostPosted: Tue Sep 20, 2005 2:38 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
filip
Valued Contributor
Valued Contributor


Joined: 07 Aug 2004
Posts: 340

PostPosted: Tue Sep 20, 2005 5:18 am    Post subject: Reply with quote

Yes, Thanks about the WINDOW ACTIVATE is just pure and simple...

I have add a title line too...
Back to top
View user's profile Send private message Send e-mail
vtol
Valued Contributor
Valued Contributor


Joined: 05 Feb 2004
Posts: 656
Location: Eastern Indiana

PostPosted: Fri Sep 23, 2005 7:36 pm    Post subject: Reply with quote

I've allways done it SnarllingSheeps way with no problems.. Cool
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group