1. Win32lib code, sorta doesnt work, or does it?
- Posted by Grape_ Vine_ <g__vine at HOTMAIL.COM> Mar 06, 2000
- 515 views
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
2. Re: Win32lib code, sorta doesnt work, or does it?
- Posted by David Cuny <dcuny at LANSET.COM> Mar 06, 2000
- 448 views
"Grape Vine" wrote: > I need some one to, tweek, this... The problem is probably that the controls grab focus of the keys away from the game. You might have to hack the code a bit. Perhaps something like: 1. Create a hidden control (positioned at {100,-100}). Trap key events going to this control. 2. After a toolbar button (or any other control) is clicked, restore focus back to the hidden control. 3. If you want, you can freeze the gameplay when the hidden control loses focus. 4. Similar to the Editor_KeyHandler routine in IDE_EDIT, you may want to call: returnValue( True ) at the end of your key handling routine, so that the hidden control doesn't actually process any keystrokes. Hope this helps! -- David Cuny
3. Re: Win32lib code, sorta doesnt work, or does it?
- Posted by Grape_ Vine_ <g__vine at HOTMAIL.COM> Mar 06, 2000
- 446 views
- Last edited Mar 07, 2000
Kinda, Isnt there a way to set unfocus the button and set the focus to the main window or just to the bitmap window?(I have been reading the docs, seams like it would work...) J Reeves Grape Vine ICQ# 13728824 >From: David Cuny <dcuny at LANSET.COM> >Reply-To: Euphoria Programming for MS-DOS <EUPHORIA at LISTSERV.MUOHIO.EDU> >To: EUPHORIA at LISTSERV.MUOHIO.EDU >Subject: Re: Win32lib code, sorta doesnt work, or does it? >Date: Mon, 6 Mar 2000 18:24:46 -0800 > >"Grape Vine" wrote: > > > > I need some one to, tweek, this... > >The problem is probably that the controls grab focus of the keys away from >the game. You might have to hack the code a bit. Perhaps something like: > >1. Create a hidden control (positioned at {100,-100}). Trap key events >going >to this control. > >2. After a toolbar button (or any other control) is clicked, restore focus >back to the hidden control. > >3. If you want, you can freeze the gameplay when the hidden control loses >focus. > >4. Similar to the Editor_KeyHandler routine in IDE_EDIT, you may want to >call: > > returnValue( True ) > >at the end of your key handling routine, so that the hidden control doesn't >actually process any keystrokes. > >Hope this helps! > >-- David Cuny J Reeves Grape Vine ICQ# 13728824 ______________________________________________________ Get Your Private, Free Email at http://www.hotmail.com
4. Re: Win32lib code, sorta doesnt work, or does it?
- Posted by David Cuny <dcuny at LANSET.COM> Mar 07, 2000
- 449 views
J Reeves wrote: > Kinda, Isnt there a way to set unfocus the > button and set the focus to the main window > or just to the bitmap window? Well, the toolbar and status bar are special cases. Ordinarily, Win32Lib will give focus to the first active control it can find in a window. But the toolbar and status bars are actually windows, of sorts, and they can't get focus, in and of themselves. The controls in the toolbar belong to the toolbar, not the window that holds the toolbar. So I suspect that you could, in fact, remove focus from the button and set it to the window. The 'bitmap' isn't really a control at all, and it can't get focus. -- David Cuny
5. Re: Win32lib code, sorta doesnt work, or does it?
- Posted by Grape_ Vine_ <g__vine at HOTMAIL.COM> Mar 07, 2000
- 517 views
AH i c, I am just going to get rid of the buttons, They limit my options for nested controls and custom controls for the user >From: David Cuny <dcuny at LANSET.COM> >Reply-To: Euphoria Programming for MS-DOS <EUPHORIA at LISTSERV.MUOHIO.EDU> >To: EUPHORIA at LISTSERV.MUOHIO.EDU >Subject: Re: Win32lib code, sorta doesnt work, or does it? >Date: Tue, 7 Mar 2000 00:49:13 -0800 > >J Reeves wrote: > > > Kinda, Isnt there a way to set unfocus the > > button and set the focus to the main window > > or just to the bitmap window? > >Well, the toolbar and status bar are special cases. Ordinarily, Win32Lib >will give focus to the first active control it can find in a window. But >the >toolbar and status bars are actually windows, of sorts, and they can't get >focus, in and of themselves. The controls in the toolbar belong to the >toolbar, not the window that holds the toolbar. So I suspect that you >could, >in fact, remove focus from the button and set it to the window. > >The 'bitmap' isn't really a control at all, and it can't get focus. > >-- David Cuny ______________________________________________________ Get Your Private, Free Email at http://www.hotmail.com