×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Now do I stop more than 1 copy of exe opening?

Now do I stop more than 1 copy of exe opening?

Now do I stop more than 1 copy of exe opening?

(OP)
Now do I stop more than 1 copy of exe opening? Ie when you double click on the shortcut a second time it maximizes the window rather than open a new one?

RE: Now do I stop more than 1 copy of exe opening?

in the global includes add this:

Module('Windows API')
  FindWindow(*LPCSTR,*LPCSTR),HWND,PASCAL,RAW,NAME('FindWindowA')
End

in the data add this :

FindWindowName CSTIRNG(50)
FindWindowHandle Unsigned

in the global embed program setup add this :

FindWindowName = 'Window title'

FindWindowHandle = FindWindow(,FindWindowName)
IF FindWindowHandle
    MESSAGE('You cannot run more than one instance of ' & FindWindowName)
    return
END

RE: Now do I stop more than 1 copy of exe opening?

(OP)
Thanks for replying But I have a query
when I try to do the following

in the global includes add this:

Module('Windows API')
  FindWindow(*LPCSTR,*LPCSTR),HWND,PASCAL,RAW,NAME('FindWindowA')
End

I get the following error
illegal return type or attribute

I was not sure where to put the above line so i put it in the global map as i couldnt find  the global includes only before or after global includes.

I'm using c5.5 and its full upto date with the patches.

Any ideas?

Many thanks
JJ

RE: Now do I stop more than 1 copy of exe opening?

ooops,
sorry my fault !
you also have to declare LPCSTR LPSTR and HWND

LPSTR                   EQUATE(CSTRING)
LPCSTR                  EQUATE(CSTRING)   
HANDLE                  EQUATE(UNSIGNED)
HWND                    EQUATE(HANDLE)

put that somewhere after the global includes.

RE: Now do I stop more than 1 copy of exe opening?

(OP)
Hi
Thanks for the quick reply

Ive added those but now its giving this error
Parameter cannot be ommited
at this line
FindWindowHandle = FindWindow(,FindWindowName)

Many thanks again
JJ

RE: Now do I stop more than 1 copy of exe opening?

try this prototype for findwindow:

Module('winapi')
 FindWindow(<*cstring>,*cstring),unsigned,pascal,raw,name('FindWindowA')
End

The first parameter is the name of the class, for a clarion application it will be something like ClaWin and a lot of figures... ie Clawin8388608Class1
The second parameter is the title of the window (in the title bar.)

if you pass a NULL to the calss name then windows then this api will look through all the classes.. otherwise it will search everywhere.

If it still does not work then try this other method, it loop through all the opened windows (visible or not) until it finds a clarion program, then checks that it is the one you are interrested in.

module('winapi')
  GetClassName(UNSIGNED,*CSTRING,SIGNED),SIGNED,PASCAL,RAW,NAME('GetClassNameA')
  GetWindowText(Long,Long,SIGNED),SIGNED,PASCAL,RAW,NAME('GetWindowTextA')
End

WindowHandle USHORT
WindowTitle  CSTRING(256)
ClassName    CSTRING(256)

FindWindowName = 'The title of of the window to close'

Loop WindowHandle = 1 To 0FFFFh
    rlen# = GetWindowText(WindowHandle,Address(WindowTitle),200)
    If rlen# Then
        ret#  = GetClassName(WindowHandle,ClassName,200)
        If (Sub(ClassName,1,6) = 'ClaWin') And Clip(WindowTitle) = FindWindowName)  Then
             MESSAGE('You cannot run more than one instance of ' & FindWindowName)
             Return
         End
    End
End

RE: Now do I stop more than 1 copy of exe opening?

(OP)
Many Thanks
After playing around with your code I've got it working
Thank you for all your help
JJ

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close