Win32lib code, sorta doesnt work, or does it?

new topic     » topic index » view thread      » older message » newer message

I need some one to, tweek, this...
The code is right from pretend.exw,(keyup/keydown) i just changed it so it
works with the variables from my code...
The code traps the keys, but only to the buttons at the bottom.....
I do not understand how windows is handling the keys

<code>
include Win32Lib.ew
without warning

object button1, button2, button3, button4, button5
object button6, button7, button8, button9, button10
object button11, button12, button13

--create the main window
global constant GW = create( Window,"Omega",0,0,0,0,0, or_all({}))

-- load the bitmaps
global constant ToolBMP = loadBitmapFromFile("tiles.bmp")
global constant Blank   = loadBitmapFromFile("d:/omega/blank.bmp")
global constant Map     = loadBitmapFromFile("d:/omega/map.bmp")
global constant Ship    = loadBitmapFromFile("d:/omega/ship1.bmp")

global sequence ships

ships = {{10,10}}

--create the command buttons
button1  = create(PictureButton, "", GW,  10-2, 538, 35, 35, ToolBMP )
button2  = create(PictureButton, "", GW,  50-2, 538, 35, 35, ToolBMP )
button3  = create(PictureButton, "", GW,  90-2, 538, 35, 35, ToolBMP )
button4  = create(PictureButton, "", GW, 130-2, 538, 35, 35, ToolBMP )
button5  = create(PictureButton, "", GW, 170-2, 538, 35, 35, ToolBMP )
button6  = create(PictureButton, "", GW, 210-2, 538, 35, 35, ToolBMP )
button7  = create(PictureButton, "", GW, 250-2, 538, 35, 35, ToolBMP )
button8  = create(PictureButton, "", GW, 290-2, 538, 35, 35, ToolBMP )
button9  = create(PictureButton, "", GW, 330-2, 538, 35, 35, ToolBMP )
button10 = create(PictureButton, "", GW, 370-2, 538, 35, 35, ToolBMP )
button11 = create(PictureButton, "", GW, 410-2, 538, 35, 35, ToolBMP )
button12 = create(PictureButton, "", GW, 450-2, 538, 35, 35, ToolBMP )
button13 = create(PictureButton, "", GW, 490-2, 538, 35, 35, ToolBMP )

----------------------------------------------------------------------
procedure paint_play_window()
-- fill with the 48x48 bitmaps
    for x = 5 to 485 by 48 do
        for y = 5 to 485 by 48 do
           drawBitmap(GW, Blank, x, y )
       end for
   end for
end procedure
----------------------------------------------------------------------

procedure paint_scanner_window()
-- fill with the 48x48 bitmaps
    for x = 538 to 762 by 32 do
        for y = 5 to 230 by 32 do
           drawBitmap(GW, Map, x, y )
       end for
   end for
end procedure
----------------------------------------------------------------------procedure
paint_map_window()
-- fill with the 48x48 bitmaps
    for x = 538 to 762 by 32 do
        for y = 266 to 490 by 32 do
           drawBitmap(GW, Map, x, y )
       end for
   end for
end procedure
----------------------------------------------------------------------procedure
paint_ship()
-- paint ship, 32X32
object x,y
x = ships[1][1]
y = ships[1][2]

           drawBitmap(GW, Ship, x, y )

end procedure
----------------------------------------------------------------------procedure
onKeyPress_Control( integer keyPress, integer shift )

closeWindow( GW )

end procedure

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

procedure Main_Paint(integer x1, integer y1, integer x2, integer y2)

   paint_play_window()
   paint_scanner_window()
   paint_map_window()
   paint_ship()
end procedure

----------------------------------------------------------------------procedure
KeyDown( integer key, integer shift )
    -- handle key presses

    if key = VK_UP then
        -- move ship up
        ships[1][1] = ships[1][1] - 4

    elsif key = VK_DOWN then
        -- move ship down
        ships[1][2] = ships[1][2] + 4

    end if
   paint_ship()
end procedure

----------------------------------------------------------------------
procedure KeyUp( integer key, integer shift )
    -- handle key presses

    if key = VK_UP
    or key = VK_DOWN then
        -- stop moving
--        shipDY = 0
    end if

end procedure

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

onPaint[ GW ]   = routine_id("Main_Paint")
onKeyUp[ GW ]   = routine_id("KeyUp"     )
onKeyDown[ GW ] = routine_id("KeyDown"   )

WinMain( GW, Maximize )





______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu