Forced closing of all windows from the outside

This forum is for eXpress++ general support.
Post Reply
Message
Author
User avatar
Eugene Lutsenko
Posts: 1649
Joined: Sat Feb 04, 2012 2:23 am
Location: Russia, Southern federal district, city of Krasnodar
Contact:

Forced closing of all windows from the outside

#1 Post by Eugene Lutsenko »

I had such a problem. In the system of many modes , many of them use the same database. I open the database , and if the window is exclusive one mode is not closed , then launch another that accesses the same database , naturally causes a programming error because some base to which he refers , busy with other regime.

I would like to be able to forcibly close a previously opened windows and database before you run the new regime , all without even knowing what it was. Very similar to how you can close the application from the Application Manager , the software only. Otherwise you have to manually close the previous window before opening a new one. It's uncomfortable , and not all users are doing.

User avatar
rdonnay
Site Admin
Posts: 4813
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Forced closing of all windows from the outside

#2 Post by rdonnay »

You do this only if the other applications that open the databases are your own applications where you have the source code.

You need to run a thread in all the applications that look for the existence of a file.
If the file exists, the programs all shut down.

Why are you using databases in EXCLUSIVE mode?
You would not be having this problem if they were opened in SHARED mode.
The eXpress train is coming - and it has more cars.

User avatar
Eugene Lutsenko
Posts: 1649
Joined: Sat Feb 04, 2012 2:23 am
Location: Russia, Southern federal district, city of Krasnodar
Contact:

Re: Forced closing of all windows from the outside

#3 Post by Eugene Lutsenko »

Hi, Roger!

I tell you about the students and show photo on the cover on the background clipper "old sea dog".

I do not open the database in SHARED, since it requires more sophisticated programming (lock, unlock, expectations and the like), but in fact most multi-user access is not required. Just need to close the previously opened window opens when new, but doing it programmatically it when opening a new window, and not very close them manually.

Cliff Wiernik
Posts: 605
Joined: Thu Jan 28, 2010 9:11 pm
Location: Steven Point, Wisconsin USA
Contact:

Re: Forced closing of all windows from the outside

#4 Post by Cliff Wiernik »

You can get the same easy of use without opening exclusively. In your open code, just do a file lock. Then you do not need to be concerned about locking, unlocking, etc. Just don't do any locking.

Cliff

User avatar
Eugene Lutsenko
Posts: 1649
Joined: Sat Feb 04, 2012 2:23 am
Location: Russia, Southern federal district, city of Krasnodar
Contact:

Re: Forced closing of all windows from the outside

#5 Post by Eugene Lutsenko »

Hi, Cliff! How many years - how many winters! Nice to hear from you. Thank you for responding. And could not bring the piece of code? Look what I heaped: http://lc.kubagro.ru/Dima/a.doc Look yourself in the text search

Cliff Wiernik
Posts: 605
Joined: Thu Jan 28, 2010 9:11 pm
Location: Steven Point, Wisconsin USA
Contact:

Re: Forced closing of all windows from the outside

#6 Post by Cliff Wiernik »

Record number of below zero days in my area this year. Had seen the acknowledgment previously. Thanks.

User avatar
Tom
Posts: 1234
Joined: Thu Jan 28, 2010 12:59 am
Location: Berlin, Germany

Re: Forced closing of all windows from the outside

#7 Post by Tom »

Eugene -

you may take a look at the "TIMEOUT"-option of DCREAD GUI:

Code: Select all

DCREAD GUI ... TIMEOUT {n,{||AnyFunction()}}
This will evaluate "AnyFunction" every n seconds. If "AnyFunction" returns .F., nothing happens. If it returns .T., the dialog is closed - as long as nothing else happened within the "n" seconds. So, "AnyFunction" could check a Get-Set-function "ShutDown" like this:

Code: Select all

FUNCTION AnyFunction()
IF ShutDown()
  RETURN .T.
ENDIF
RETURN .F.

FUNCTION ShutDown(lShutDown)
STATIC lShutDownCreated := .F.
IF PCount()=1
  lShutDownCreated := lShutDown
ENDIF
RETURN lShutDownCreated
If you now want to close all dialogs using this, call "ShutDown(.T.)". This should close all those dialogs. Just add the statement "TIMEOUT {n,{||AnyFunction()}}" to all DCREAD GUIs, which is no work with search&replace.
Best regards,
Tom

"Did I offend you?"
"No."
"Okay, give me a second chance."

User avatar
Eugene Lutsenko
Posts: 1649
Joined: Sat Feb 04, 2012 2:23 am
Location: Russia, Southern federal district, city of Krasnodar
Contact:

Re: Forced closing of all windows from the outside

#8 Post by Eugene Lutsenko »

Thank you, Tom! This is an interesting and useful feature!

User avatar
Tom
Posts: 1234
Joined: Thu Jan 28, 2010 12:59 am
Location: Berlin, Germany

Re: Forced closing of all windows from the outside

#9 Post by Tom »

:)

My code is a little redundantly. Forget "AnyFunction" and use "ShutDown" directly instead.
Best regards,
Tom

"Did I offend you?"
"No."
"Okay, give me a second chance."

Post Reply