1. using keys in windows

Does anyone know how to use the arrow keys with win32lib
I've tried onKeyPress, and onKeyDown but can't get it to work
any suggestions would be great help.

new topic     » topic index » view message » categorize

2. Re: using keys in windows

procedure do_arrow_key( integer key, integer shift )
if key = VK_LEFT  then  --do whatever...
if key = VK_UP then  -- do whatever else...
if key = VK_RIGHT then  -- do this...
if key = VK_DOWN then  -- do the last...
onKeyDown[ control_with_focus ] = routine_id("do_arrow_key")

> Does anyone know how to use the arrow keys with win32lib
> I've tried onKeyPress, and onKeyDown but can't get it to work
> any suggestions would be great help.

new topic     » goto parent     » topic index » view message » categorize

3. Re: using keys in windows

Frank Collins wrote:

> Does anyone know how to use the arrow keys with win32lib
> I've tried onKeyPress, and onKeyDown but can't get it to work

onKeyPress will only return "visible" keys; you need to use onKeyDown.

Windows maps the keys a bit differently than DOS; take a look at the VK_
(virtual key) constants: VK_UP, VK_DOWN, VK_LEFT, etc.

-- David Cuny

new topic     » goto parent     » topic index » view message » categorize

4. Re: using keys in windows

Frank,

Here's a demonstration of how to use the arrow keys in Win32Lib:

<tested code follows>

--  demonstrates using the arrow keys

include Win32Lib.ew
without warning

constant MainWin = create(Window,"Press Arrow Keys",0,0,0,400,400,0)

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

procedure MainWin_onKeyDown ( int scanCode, int shift )
--  ** FOR AN ARROW KEY PRESSED:

--  UP ARROW
  if scanCode = VK_UP then
    repaintWindow(MainWin)
    wPuts(MainWin,"up arrow")

--   DOWN ARROW
  elsif scanCode = VK_DOWN then
   repaintWindow(MainWin)
   wPuts(MainWin,"down arrow")

--   LEFT ARROW
  elsif scanCode = VK_LEFT then
   repaintWindow(MainWin)
   wPuts(MainWin,"left arrow")

--   RIGHT ARROW
  elsif scanCode = VK_RIGHT then
   repaintWindow(MainWin)
   wPuts(MainWin,"right arrow")

  end if
end procedure
------------------------------------------------------------

onKeyDown[MainWin] = routine_id("MainWin_onKeyDown")

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

WinMain( MainWin, Normal )

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

<end code>

----- Original Message -----
From: "Frank Collins" <Smoky1930 at AOL.COM>
To: <EUPHORIA at LISTSERV.MUOHIO.EDU>
Sent: Saturday, August 12, 2000 6:00 PM
Subject: using keys in windows


> Does anyone know how to use the arrow keys with win32lib
> I've tried onKeyPress, and onKeyDown but can't get it to work
> any suggestions would be great help.

new topic     » goto parent     » topic index » view message » categorize

5. Re: using keys in windows

How about just using the regular key monitoring functions like get_key()?


----- Original Message -----
From: "Frank Collins" <Smoky1930 at AOL.COM>
To: <EUPHORIA at LISTSERV.MUOHIO.EDU>
Sent: Saturday, August 12, 2000 9:00 PM
Subject: using keys in windows


> Does anyone know how to use the arrow keys with win32lib
> I've tried onKeyPress, and onKeyDown but can't get it to work
> any suggestions would be great help.
>

new topic     » goto parent     » topic index » view message » categorize

6. Re: using keys in windows

Thanks for everyone's help it works now.

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu