comp.lang.ada
 help / color / mirror / Atom feed
* How to lock keys.
@ 2000-12-15 18:24 Freelancer
  2000-12-15 19:26 ` Larry Kilgallen
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Freelancer @ 2000-12-15 18:24 UTC (permalink / raw)


I'm using ObjectAda and programming console programs in win98. I was
wondering if someone could tell me how to lock out any keys that I don't
want in my program.


For example : I would like to lock out CTRL+C so that it doesn't terminate
the program.

Thanks for your help! :)





^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: How to lock keys.
  2000-12-15 18:24 How to lock keys Freelancer
@ 2000-12-15 19:26 ` Larry Kilgallen
  2000-12-15 20:40   ` Freelancer
  2000-12-16  3:45   ` DuckE
  2000-12-15 23:56 ` Alexander Antonenko
  2000-12-16  3:36 ` DuckE
  2 siblings, 2 replies; 13+ messages in thread
From: Larry Kilgallen @ 2000-12-15 19:26 UTC (permalink / raw)


In article <Mlt_5.8850$0U2.334755@news20.bellglobal.com>, "Freelancer" <freelancer_2001@hotmail.com> writes:
> I'm using ObjectAda and programming console programs in win98. I was
> wondering if someone could tell me how to lock out any keys that I don't
> want in my program.
> 
> 
> For example : I would like to lock out CTRL+C so that it doesn't terminate
> the program.

You are asking how to disable an operating system function,
and that is specific to the operating system you choose.

Check your Microsoft documentation, as this is not an Ada question.



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: How to lock keys.
  2000-12-15 19:26 ` Larry Kilgallen
@ 2000-12-15 20:40   ` Freelancer
  2000-12-15 22:18     ` Ted Dennison
                       ` (2 more replies)
  2000-12-16  3:45   ` DuckE
  1 sibling, 3 replies; 13+ messages in thread
From: Freelancer @ 2000-12-15 20:40 UTC (permalink / raw)


If it's not an ada question then how is it that other software may disable
the use of the key.

How come CTRL+C does a copy selection in the dos Edit program, and how come
it stops the execution of my program?

Somewhere I have to program something in Ada to change or disable the
function of a specific scan code.


Larry Kilgallen <Kilgallen@eisner.decus.org.nospam> wrote in message
news:+9MtPNUtSdgw@eisner.decus.org...
> In article <Mlt_5.8850$0U2.334755@news20.bellglobal.com>, "Freelancer"
<freelancer_2001@hotmail.com> writes:
> > I'm using ObjectAda and programming console programs in win98. I was
> > wondering if someone could tell me how to lock out any keys that I don't
> > want in my program.
> >
> >
> > For example : I would like to lock out CTRL+C so that it doesn't
terminate
> > the program.
>
> You are asking how to disable an operating system function,
> and that is specific to the operating system you choose.
>
> Check your Microsoft documentation, as this is not an Ada question.





^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: How to lock keys.
  2000-12-15 20:40   ` Freelancer
@ 2000-12-15 22:18     ` Ted Dennison
  2000-12-15 22:32     ` Mike Silva
  2000-12-15 23:54     ` Gautier
  2 siblings, 0 replies; 13+ messages in thread
From: Ted Dennison @ 2000-12-15 22:18 UTC (permalink / raw)


In article <Ikv_5.8875$0U2.342784@news20.bellglobal.com>,
  "Freelancer" <freelancer_2001@hotmail.com> wrote:
> If it's not an ada question then how is it that other software may
> disable the use of the key.

Exactly! :-)

There's nothing special about Ada here, so what you need to do is figure
out "how is it that other software may disable the use of the key", and
then do that in your code. There might be some people here who just
happen to know how Windows programs do this, but this isn't a Windows
newsgroup. You'd probably have much better luck consulting a Windows
programming group, or trying your luck with the Windows development
documentation.

Now if you get the answer to how Windows programs do it, but you still
don't know how to do the same thing in Ada, *that's* where we come in.

p.s. From my limited Windows experience, I'd say that making your
program a GUI program instead of a console program would probably do the
trick. Every Windows compiler I've used (C or Ada) has some compiler
option to choose which type of application to build at link time. You'll
have to ask an ObjectAda expert (or read the OA docs) to find out how
that compiler does it. But if you actually *want* a console and no GUI,
that's a whole different kettle of fish...

--
T.E.D.

http://www.telepath.com/~dennison/Ted/TED.html


Sent via Deja.com
http://www.deja.com/



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: How to lock keys.
  2000-12-15 20:40   ` Freelancer
  2000-12-15 22:18     ` Ted Dennison
@ 2000-12-15 22:32     ` Mike Silva
  2000-12-15 23:54     ` Gautier
  2 siblings, 0 replies; 13+ messages in thread
From: Mike Silva @ 2000-12-15 22:32 UTC (permalink / raw)


In article <Ikv_5.8875$0U2.342784@news20.bellglobal.com>,
  "Freelancer" <freelancer_2001@hotmail.com> wrote:
> If it's not an ada question then how is it that other software may
disable
> the use of the key.

They twiddle the OS properly.
>
> How come CTRL+C does a copy selection in the dos Edit program, and
how come
> it stops the execution of my program?
>
> Somewhere I have to program something in Ada to change or disable the
> function of a specific scan code.

This may help (part of the MSDOS programming FAQ):

http://x64.deja.com/[ST_rn=fs]/getdoc.xp?
AN=698643997&CONTEXT=976919230.1450180706&hitnum=19

Mike


Sent via Deja.com
http://www.deja.com/



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: How to lock keys.
  2000-12-15 20:40   ` Freelancer
  2000-12-15 22:18     ` Ted Dennison
  2000-12-15 22:32     ` Mike Silva
@ 2000-12-15 23:54     ` Gautier
  2 siblings, 0 replies; 13+ messages in thread
From: Gautier @ 2000-12-15 23:54 UTC (permalink / raw)


Freelancer:

> How come CTRL+C does a copy selection in the dos Edit program, and how come
> it stops the execution of my program?

The DOS Edit program is a DOS program (yes!), it has tricks to disable
Ctrl-Break. Ctrl-C is even not affected since the program doesn't use the
standard output. Of course you can reprogram everything in keyboard
behaviour. I have a GNAT/DOS multi-key keyboard interrupt that replaces
the DOS
one and disables even Ctrl-Alt-Del under a windowed DOS box in Win9x... 
With ObjectAda, you surely produce Win32 applications. Sort out which
kind you make / and want : GUI, console ?...

______________________________________________________
Gautier  --  http://members.nbci.com/gdemont/gsoft.htm



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: How to lock keys.
  2000-12-15 18:24 How to lock keys Freelancer
  2000-12-15 19:26 ` Larry Kilgallen
@ 2000-12-15 23:56 ` Alexander Antonenko
  2000-12-16  3:36 ` DuckE
  2 siblings, 0 replies; 13+ messages in thread
From: Alexander Antonenko @ 2000-12-15 23:56 UTC (permalink / raw)


>>>>> "F" == Freelancer  writes:

F> I'm using ObjectAda and programming console programs in win98. I was
F> wondering if someone could tell me how to lock out any keys that I don't
F> want in my program.


F> For example : I would like to lock out CTRL+C so that it doesn't
F> terminate the program.

You can try something like this:

System.Interrupts.Block_Interrupt(
  System.Interrupts.Interrupt_Id(Ada.Interrupts.Names.SIGINT));

I don't know will this work in windows and with compilers other than
GNAT. In any case see packages Ada.Interrupts & System.Interrupts.

F> Thanks for your help! :)

-- 
Alexander Antonenko
mailto:alexa@i.com.ua
mailto:aga@mix.meow.kiev.ua

I suppose you think I think I know it all
		-- Ozzy



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: How to lock keys.
  2000-12-15 18:24 How to lock keys Freelancer
  2000-12-15 19:26 ` Larry Kilgallen
  2000-12-15 23:56 ` Alexander Antonenko
@ 2000-12-16  3:36 ` DuckE
  2000-12-16 14:15   ` Marin David Condic
  2 siblings, 1 reply; 13+ messages in thread
From: DuckE @ 2000-12-16  3:36 UTC (permalink / raw)


Under Windows NT (the doc's indicate this should work under 98) there is a
function called "SetConsoleCtrlHandler" that permits you to add a handler
callback that is invoked when Ctrl+C is typed.  The action that is taken
depends on the return from this function.

I don't have any sample code on the machine I'm working on right now, or I'd
send you an example.  If you can't figure it out send me an email at
steved94@home.com and I'll send you some example source in a couple of days.

SteveD


"Freelancer" <freelancer_2001@hotmail.com> wrote in message
news:Mlt_5.8850$0U2.334755@news20.bellglobal.com...
> I'm using ObjectAda and programming console programs in win98. I was
> wondering if someone could tell me how to lock out any keys that I don't
> want in my program.
>
>
> For example : I would like to lock out CTRL+C so that it doesn't terminate
> the program.
>
> Thanks for your help! :)
>
>





^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: How to lock keys.
  2000-12-15 19:26 ` Larry Kilgallen
  2000-12-15 20:40   ` Freelancer
@ 2000-12-16  3:45   ` DuckE
  2000-12-16 14:07     ` Marin David Condic
  1 sibling, 1 reply; 13+ messages in thread
From: DuckE @ 2000-12-16  3:45 UTC (permalink / raw)


> >
> > For example : I would like to lock out CTRL+C so that it doesn't
terminate
> > the program.
>
> You are asking how to disable an operating system function,
> and that is specific to the operating system you choose.
>
> Check your Microsoft documentation, as this is not an Ada question.

Personally I'd love to see this newsgroup flooded with questions about how
to do things in Ada, even if they are operating system specific.  Perhaps
eventually there would be comp.lang.ada.nt, comp.lang.ada.linux, etc.

These are symptoms of increased use of the language.

SteveD






^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: How to lock keys.
  2000-12-16  3:45   ` DuckE
@ 2000-12-16 14:07     ` Marin David Condic
  0 siblings, 0 replies; 13+ messages in thread
From: Marin David Condic @ 2000-12-16 14:07 UTC (permalink / raw)


Good point. It would probably help to explain that the issue is not
specifically an Ada question because many programmers - especially those with
less experience - often confuse what a language does and what an operating
system does. They're used to working with some specific language environment
where they can look up some environment provided OS call and kind of assume it
is just part of the programming language.

The original question is not entirely unfair as a C.L.A. question. Given the
specific OS and development environment, does there exist some sort of OS call
or option setting in Object Ada that disables ctrl-C? Maybe it is more
appropriate for some Object Ada specific forum, but we've answered similar
questions around here for GNAT specific problems.

Clearly, more info is required to properly answer the question. Some have
suggested making the app a Windows based app rather than a console based app.
That would work unless the app is required to be console based. If that is the
case, I'm afraid I wouldn't know off the top of my head how to do that. A
quick look at "Win32 System Services" by Marshall Brain suggests that the
SetConsoleCtrlHandler OS routine would be a good place to start looking. There
should be an equivalent call in the Win32Ada binding. If that looks like it
might work, then certainly any questions about how to connect to and use this
routine would be proper grist for C.L.A.

MDC

DuckE wrote:

> Personally I'd love to see this newsgroup flooded with questions about how
> to do things in Ada, even if they are operating system specific.  Perhaps
> eventually there would be comp.lang.ada.nt, comp.lang.ada.linux, etc.
>
> These are symptoms of increased use of the language.

--
======================================================================
Marin David Condic - Quadrus Corporation - http://www.quadruscorp.com/
Send Replies To: m c o n d i c @ q u a d r u s c o r p . c o m
Visit my web site at:  http://www.mcondic.com/

    "Giving money and power to Government is like giving whiskey
    and car keys to teenage boys."

        --   P. J. O'Rourke
======================================================================





^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: How to lock keys.
  2000-12-16  3:36 ` DuckE
@ 2000-12-16 14:15   ` Marin David Condic
  2000-12-17 22:40     ` Freelancer
  0 siblings, 1 reply; 13+ messages in thread
From: Marin David Condic @ 2000-12-16 14:15 UTC (permalink / raw)


Great minds think alike! :-) Just saw this after posting my earlier response
concerning SetConsoleCtrlHandler.

Additional information: Look for a package in the Win32ada binding (don't know
where it is in Object Ada, but I believe it exists somewhere there!) named:

package Win32.Wincon is

The call you want to investigate is:

    function SetConsoleCtrlHandler(
        HandlerRoutine: PHANDLER_ROUTINE;
        Add           : Win32.BOOL)
        return Win32.BOOL;

How to hook up to this and provide a handler routine would seem to be a fair Ada
related question.

MDC

DuckE wrote:

> Under Windows NT (the doc's indicate this should work under 98) there is a
> function called "SetConsoleCtrlHandler" that permits you to add a handler
> callback that is invoked when Ctrl+C is typed.  The action that is taken
> depends on the return from this function.

--
======================================================================
Marin David Condic - Quadrus Corporation - http://www.quadruscorp.com/
Send Replies To: m c o n d i c @ q u a d r u s c o r p . c o m
Visit my web site at:  http://www.mcondic.com/

    "Giving money and power to Government is like giving whiskey
    and car keys to teenage boys."

        --   P. J. O'Rourke
======================================================================





^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: How to lock keys.
  2000-12-16 14:15   ` Marin David Condic
@ 2000-12-17 22:40     ` Freelancer
  2000-12-18  1:30       ` DuckE
  0 siblings, 1 reply; 13+ messages in thread
From: Freelancer @ 2000-12-17 22:40 UTC (permalink / raw)


Thanks for answering my question. Here's what I tried to do which I know is
all wrong, but I have no clue about windows programming so please give me a
break :

with text_io;
with win32;
with win32.wincon;
use text_io;

procedure test is

    bool1 : win32.BOOL := 1;
    bool2 : win32.BOOL;
    hdle  : win32.wincon.PHANDLER_ROUTINE;
    ctrlc : win32.DWORD := 0; -- supposing 0 is for the CTRL-C event

begin
    bool2 := hdle (ctrlc); -- If I don't put this, it runs, if I do, it
gives me a constraint_error, due to a access error
    bool2 := win32.wincon.setconsolectrlhandler (hdle, bool1);
    get(c); -- Before entering a character, I pressed CTRL-C and it doesn't
work (happy for that)
            -- After entering the character, the program jams, and it
doesn't close, and I can't recompile it after.
end test;

This crashes the program of course. Could I get some help on working this
function please?


"Marin David Condic" <mcondic.nospam@acm.org> wrote in message
news:3A3B78F4.433594D8@acm.org...
> Great minds think alike! :-) Just saw this after posting my earlier
response
> concerning SetConsoleCtrlHandler.
>
> Additional information: Look for a package in the Win32ada binding (don't
know
> where it is in Object Ada, but I believe it exists somewhere there!)
named:
>
> package Win32.Wincon is
>
> The call you want to investigate is:
>
>     function SetConsoleCtrlHandler(
>         HandlerRoutine: PHANDLER_ROUTINE;
>         Add           : Win32.BOOL)
>         return Win32.BOOL;
>
> How to hook up to this and provide a handler routine would seem to be a
fair Ada
> related question.
>
> MDC
>
> DuckE wrote:
>
> > Under Windows NT (the doc's indicate this should work under 98) there is
a
> > function called "SetConsoleCtrlHandler" that permits you to add a
handler
> > callback that is invoked when Ctrl+C is typed.  The action that is taken
> > depends on the return from this function.
>
> --
> ======================================================================
> Marin David Condic - Quadrus Corporation - http://www.quadruscorp.com/
> Send Replies To: m c o n d i c @ q u a d r u s c o r p . c o m
> Visit my web site at:  http://www.mcondic.com/
>
>     "Giving money and power to Government is like giving whiskey
>     and car keys to teenage boys."
>
>         --   P. J. O'Rourke
> ======================================================================
>
>





^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: How to lock keys.
  2000-12-17 22:40     ` Freelancer
@ 2000-12-18  1:30       ` DuckE
  0 siblings, 0 replies; 13+ messages in thread
From: DuckE @ 2000-12-18  1:30 UTC (permalink / raw)


Here is the test code I used to see the SetConsoleCtrlHandler function at
work:

--------------------------- File TestHandler.adb --------------------
WITH CtrlCHandler;
WITH Win32;
WITH Win32.WinCon;
WITH Ada.Text_Io;

PROCEDURE TestHandler IS
  result : Win32.BOOL;
BEGIN
  Ada.Text_Io.Put_Line( "Start" );
  result := Win32.WinCon.SetConsoleCtrlHandler( HandlerRoutine =>
CtrlCHandler.MyHandler'ACCESS,
                                                Add => Win32.TRUE );
  DELAY 5.0;
  Ada.Text_Io.Put_Line( "Finish" );
  DELAY 2.0;
END TestHandler;

------------------ File: CtrlCHandler.ads --------------------------

WITH Win32;
PACKAGE CtrlCHandler IS

  FUNCTION MyHandler( ctrlType : Win32.DWORD ) RETURN Win32.BOOL;
  PRAGMA Convention( stdcall, MyHandler );

END CtrlCHandler;

------------------- File: CtrlCHandler.adb -----------------------

WITH Win32;
WITH Win32.WinCon;
WITH Ada.Text_Io;

PACKAGE BODY CtrlCHandler IS

  FUNCTION MyHandler( ctrlType : Win32.DWORD ) RETURN Win32.BOOL IS
  BEGIN
    Ada.Text_Io.Put_Line( "Handled!" );
    RETURN Win32.TRUE;
  END MyHandler;

END CtrlCHandler;

-----------------------------------------------------------------------

I hope this helps,

SteveD






^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2000-12-18  1:30 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-12-15 18:24 How to lock keys Freelancer
2000-12-15 19:26 ` Larry Kilgallen
2000-12-15 20:40   ` Freelancer
2000-12-15 22:18     ` Ted Dennison
2000-12-15 22:32     ` Mike Silva
2000-12-15 23:54     ` Gautier
2000-12-16  3:45   ` DuckE
2000-12-16 14:07     ` Marin David Condic
2000-12-15 23:56 ` Alexander Antonenko
2000-12-16  3:36 ` DuckE
2000-12-16 14:15   ` Marin David Condic
2000-12-17 22:40     ` Freelancer
2000-12-18  1:30       ` DuckE

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox