December 11, 2024, 10:06:02 PM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Detecting close on console

Started by JoaoAfonso, September 07, 2011, 01:42:38 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

JoaoAfonso

Good evening.

Is there a way to detect when an EB/IW console app receives the message to close?

I pretend to run a subroutine with some instructions before the console closes. The workaround I am thinking is to use window/dialog, but what I really want is detect the console window close.

Any info and/or a little sample would be appreciated.

On a side note, I still use an EB paied version to do some small apps. What I need to do to get IW latest version? Or what IW version I can download/use considering I'm a subscribed member? I'm going to read posts in proper forum, but as this matter came into my mind right now...

Thanks in advance.

Best regards,
JoÃÆ'ƒÂÃ,£o Afonso
Viriato
-----------------
Iberia MUD
www.iberiamud.com
iberiamud.com:5900

LarryMc

Don't know exactly what you are wanting to do but this gives you something to play with.

$include "windowssdk.inc"

OPENCONSOLE
SetConsoleCtrlHandler(&cleanup,true)
PRINT "hello"

DO:UNTIL INKEY$ <> ""

CLOSECONSOLE
cleanup(-99)
END

sub cleanup(t:uint),int
/*
0 A CTRL+C signal was received, either from keyboard input or
from a signal generated by the GenerateConsoleCtrlEvent function.

1 A CTRL+BREAK signal was received, either from keyboard input
or from a signal generated by GenerateConsoleCtrlEvent.

2 A signal that the system sends to all processes attached to
a console when the user closes the console (either by clicking
Close on the console window's window menu, or by clicking
the End Task button command from Task Manager).

5 A signal that the system sends to all console processes
when a user is logging off. This signal does not indicate
which user is logging off, so no assumptions can be made.
Note that this signal is received only by services. Interactive
applications are terminated at logoff, so they are not
present when the system sends this signal.


6 A signal that the system sends to all console processes when
the system is shutting down.

*/
messagebox 0,"I'm in cleanup","info"+str$(t)
return 0
endsub


LarryMc
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

JoaoAfonso

Good morning.

That was exactly what I was after. It's like a destructor for the console.

I have a few years of IB/CB/EB/CB/... and never saw this console control :) I always forget to check windowssdk.inc previously, though...

Thank you for the information.
JoÃÆ'ƒÂÃ,£o Afonso
Viriato
-----------------
Iberia MUD
www.iberiamud.com
iberiamud.com:5900

LarryMc

OPENCONSOLE / CLOSECONSOLE has always been there and has nothing to do with windowssdk.inc

I always use Sapero's windowssdk.inc because it keeps me from having to look up the declarations for API functions I might use.

Glad it helped you.

LarryMc
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library