1. Win32Lib Question
- Posted by Irv Mullins <irv at ELLIJAY.COM> Sep 15, 1999
- 548 views
Dave: I need to write a Windows program which will respond to keystrokes regardless of which control has focus. onKeyPress[ x ] works if x is a control, but not if x is the main Win. Any hints? Thanks, Irv
2. Re: Win32Lib Question
- Posted by David Cuny <dcuny at LANSET.COM> Sep 15, 1999
- 535 views
Irv Mullins wondered: >I need to write a Windows program which will respond to keystrokes >regardless of which control has focus. > >onKeyPress[ x ] works if x is a control, but not if x is the main Win. I was under the impression that the Window control trapped key events. I'll take a look at the code. -- David Cuny
3. Re: Win32Lib Question
- Posted by David Cuny <dcuny at LANSET.COM> Sep 15, 1999
- 478 views
Irv wrote: >I need to write a Windows program which will respond to keystrokes >regardless of which control has focus. > >onKeyPress[ x ] works if x is a control, but not if x is the main Win. It should work just fine, no matter what the window is. Keep in mind that onKeyPress sees only 'printable' keys (more or less), while onKeyDown sees all keys (but only as key codes). I'm giving some serious consideration into folding these two functions into a unified onKey function. WM_KEYDOWN would pass the cursor-type events, while WM_CHAR would pass 'normal' keys. I'll also probably be adding the Shift and Control key states as parameters. -- David Cuny
4. Re: Win32Lib Question
- Posted by Irv Mullins <irv at ELLIJAY.COM> Sep 16, 1999
- 491 views
On Wed, 15 Sep 1999, you wrote: > Irv wrote: > > >I need to write a Windows program which will respond to keystrokes > >regardless of which control has focus. > > > >onKeyPress[ x ] works if x is a control, but not if x is the main Win. > > It should work just fine, no matter what the window is. Well - it does, sort of... If you have a window with zero controls, it works. Add a listbox, for example, and the keystrokes are no longer trapped. Example: include win32lib.ew integer key sequence kp constant Win = create(Window, "Test",0,Default,Default,640,420,0), -- Uncomment the following line to break the program: -- List1 = create(List,"",Win,100,100,80,140,0) procdure kep (object a) wPrintf(Win,"%s\n",{a}) -- doesn't really matter whether you print, or call procedures -- based on the value of 'a', it quits working when a control -- is added. end procedure onKeyPress [Win] = routine_id("kep") WinMain (Win,Normal) Irv
5. Re: Win32Lib Question
- Posted by "Cuny, David" <David.Cuny at DSS.CA.GOV> Sep 16, 1999
- 484 views
Irv Mullins wrote: > If you have a window with zero controls, it works. Add a listbox, > for example, and the keystrokes are no longer trapped. That's because the listbox has focus, and keys are sent to the control with focus. When there are controls on a window and that window gets focus, Win32Lib tries to give it to a control that can get focus (has WS_TABSTOP attribute). Don't mess with the attribute, though - Win32Lib also uses it to set the tab key behavior. In theory, you could change Win32Lib to automatically send all key events to the main window, changing the calls: elsif iMsg = WM_KEYDOWN then if onKeyDown[ id ] != -1 then call_proc( onKeyDown[ id ], {wParam} ) end if (etc...) into: elsif iMsg = WM_KEYDOWN then if onKeyDown[ mainWindow ] != -1 then call_proc( onKeyDown[ mainWindow ], {wParam} ) end if (etc...) But I wouldn't suggest it - I mention it only to clarify what's happening in the code. Instead, just attach the same handler to each control: onKeyPress [Win] = routine_id("kep") onKeyPress [Button1] = routine_id("kep") onKeyPress [Button2] = routine_id("kep") onKeyPress [List1] = routine_id("kep") Hope this helps! -- David Cuny
6. Re: Win32Lib Question
- Posted by Irv Mullins <irv at ELLIJAY.COM> Sep 16, 1999
- 490 views
On Thu, 16 Sep 1999, you wrote: > Irv Mullins wrote: > > > If you have a window with zero controls, it works. Add a listbox, > > for example, and the keystrokes are no longer trapped. > > That's because the listbox has focus, and keys are sent to the control with > focus. <snip> just attach the same handler to each control: > > onKeyPress [Win] = routine_id("kep") > onKeyPress [Button1] = routine_id("kep") > onKeyPress [Button2] = routine_id("kep") > onKeyPress [List1] = routine_id("kep") Many thanks! This solves the problem - which was to emulate as closely as possible the user interface of a legacy DOS program. Regards, Irv
7. Win32Lib Question
- Posted by Irv Mullins <irv at ELLIJAY.COM> Oct 24, 1999
- 499 views
--Boundary_(ID_R+kJccjra2TM6g5e/0pxXg) Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: quoted-printable Hi: I am using some edittext controls for numbers, and it would be nice if = the numbers would line up vertically, but that won't happen with proportional fonts.=20 However, when I change the font to a fixed-width font, either Courier or = Fixedsys,=20 suddenly the numbers drop off at the decimal point: e.g. 29.95 is now = shown as 29, and 1.49 is shown as 1, so things don't line up still, and worse, the = numbers are screwy. I'm loading the controls with = setText(EditText1,sprintf("%8.2f",mynumber))..... Any ideas? Thanks, Irv --Boundary_(ID_R+kJccjra2TM6g5e/0pxXg) Content-type: text/html; charset=iso-8859-1 Content-transfer-encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META content=3D"text/html; charset=3Diso-8859-1" = http-equiv=3DContent-Type> <META content=3D"MSHTML 5.00.2614.3500" name=3DGENERATOR> <STYLE></STYLE> </HEAD> <BODY bgColor=3D#ffffff> <DIV><FONT face=3DArial size=3D2>Hi:<BR></FONT></DIV> <DIV><FONT face=3DArial size=3D2>I am using some edittext controls for = numbers, and=20 it would be nice if the numbers would</FONT></DIV> <DIV><FONT face=3DArial size=3D2>line up vertically, but that won't = happen with=20 proportional fonts. </FONT></DIV> <DIV><FONT face=3DArial size=3D2>However, when I change the font to a = fixed-width=20 font, either Courier or Fixedsys, </FONT></DIV> <DIV><FONT face=3DArial size=3D2>suddenly the numbers drop off at the = decimal point:=20 e.g. 29.95 is now shown as 29,</FONT></DIV> <DIV><FONT face=3DArial size=3D2>and 1.49 is shown as 1, so things don't = line up=20 still, and worse, the numbers are screwy.</FONT></DIV> <DIV><FONT face=3DArial size=3D2>I'm loading the controls with=20 <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>Any ideas?</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>Thanks,</FONT></DIV> <DIV><FONT face=3DArial size=3D2>Irv</FONT></DIV> --Boundary_(ID_R+kJccjra2TM6g5e/0pxXg)--
8. Re: Win32Lib Question
- Posted by Ad Rienks <kwibus at ZONNET.NL> Oct 25, 1999
- 505 views
- Last edited Oct 26, 1999
------=_NextPart_000_0012_01BF1F3E.7C9A8CC0 charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi Irv, Maybe the width of the EditText control should be set higher, or the = formatting string should be changed, but I found no problems, running = the example below: --start code-- include win32lib.ew without warning atom junk constant Win =3D create(Window, "edit-control", 0, 0, 0, 200, 200, 0), EditText1 =3D create(EditText, "", Win, 10, 10, 100, 20, 0), Number =3D 129.95 procedure onLoad_Win() setFont(EditText1, "FixedSys", 12, 0) setText(EditText1, sprintf("%12.2f", Number)) end procedure onOpen[Win] =3D routine_id("onLoad_Win") WinMain(Win, Normal) --end code-- ----- Oorspronkelijk bericht -----=20 Van: Irv Mullins=20 Aan: EUPHORIA at LISTSERV.MUOHIO.EDU=20 Verzonden: zondag 24 oktober 1999 20:47 Onderwerp: Win32Lib Question Hi: I am using some edittext controls for numbers, and it would be nice if = the numbers would line up vertically, but that won't happen with proportional fonts.=20 However, when I change the font to a fixed-width font, either Courier = or Fixedsys,=20 suddenly the numbers drop off at the decimal point: e.g. 29.95 is now = shown as 29, and 1.49 is shown as 1, so things don't line up still, and worse, the = numbers are screwy. I'm loading the controls with = setText(EditText1,sprintf("%8.2f",mynumber))..... Any ideas? =20 Thanks, Irv =20 ------=_NextPart_000_0012_01BF1F3E.7C9A8CC0 charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META content=3D"text/html; charset=3Diso-8859-1" = http-equiv=3DContent-Type> <META content=3D"MSHTML 5.00.2314.1000" name=3DGENERATOR> <STYLE></STYLE> </HEAD> <BODY bgColor=3D#ffffff> <DIV>Hi Irv,</DIV> <DIV> </DIV> <DIV>Maybe the width of the EditText control should be set higher, or = the=20 formatting string should be changed, but I found no problems, running = the=20 example below:</DIV> <DIV> </DIV> <DIV>--start code--<BR>include win32lib.ew<BR>without warning<BR>atom = junk</DIV> <DIV> </DIV> <DIV>constant<BR> Win =3D create(Window, = "edit-control", 0, 0,=20 0, 200, 200, 0),<BR> EditText1 =3D create(EditText, = "", Win, 10,=20 10, 100, 20, 0),<BR> Number =3D 129.95</DIV> <DIV> </DIV> <DIV>procedure onLoad_Win()<BR> setFont(EditText1, = "FixedSys",=20 12, 0)<BR> setText(EditText1, sprintf("%12.2f",=20 Number))<BR>end procedure</DIV> <DIV> </DIV> <DIV>onOpen[Win] =3D routine_id("onLoad_Win")</DIV> <DIV> </DIV> <DIV>WinMain(Win, Normal)<BR>--end code--</DIV> <BLOCKQUOTE=20 style=3D"BORDER-LEFT: #000000 2px solid; MARGIN-LEFT: 5px; MARGIN-RIGHT: = 0px; PADDING-LEFT: 5px; PADDING-RIGHT: 0px"> <DIV style=3D"FONT: 10pt arial">----- Oorspronkelijk bericht ----- = </DIV> <DIV=20 style=3D"BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: = black"><B>Van:</B>=20 <A href=3D"mailto:irv at ELLIJAY.COM" title=3Dirv at ELLIJAY.COM>Irv = Mullins</A> </DIV> <DIV style=3D"FONT: 10pt arial"><B>Aan:</B> <A=20 href=3D"mailto:EUPHORIA at LISTSERV.MUOHIO.EDU"=20 title=3DEUPHORIA at LISTSERV.MUOHIO.EDU>EUPHORIA at LISTSERV.MUOHIO.EDU</A> = </DIV> <DIV style=3D"FONT: 10pt arial"><B>Verzonden:</B> zondag 24 oktober = 1999=20 20:47</DIV> <DIV style=3D"FONT: 10pt arial"><B>Onderwerp:</B> Win32Lib = Question</DIV> <DIV><BR></DIV> <DIV><FONT face=3DArial size=3D2>Hi:<BR></FONT></DIV> <DIV><FONT face=3DArial size=3D2>I am using some edittext controls for = numbers,=20 and it would be nice if the numbers would</FONT></DIV> <DIV><FONT face=3DArial size=3D2>line up vertically, but that won't = happen with=20 proportional fonts. </FONT></DIV> <DIV><FONT face=3DArial size=3D2>However, when I change the font to a = fixed-width=20 font, either Courier or Fixedsys, </FONT></DIV> <DIV><FONT face=3DArial size=3D2>suddenly the numbers drop off at the = decimal=20 point: e.g. 29.95 is now shown as 29,</FONT></DIV> <DIV><FONT face=3DArial size=3D2>and 1.49 is shown as 1, so things = don't line up=20 still, and worse, the numbers are screwy.</FONT></DIV> <DIV><FONT face=3DArial size=3D2>I'm loading the controls with=20 setText(EditText1,sprintf("%8.2f",mynumber)).....</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>Any ideas?</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>Thanks,</FONT></DIV> <DIV><FONT face=3DArial size=3D2>Irv</FONT></DIV> <DIV><FONT face=3DArial = ------=_NextPart_000_0012_01BF1F3E.7C9A8CC0--