1. Trapping virtual keys in combo boxes
I cannot seem to make windows ignore the pagedown key in a combobox
after processing it myself. Below is a test program showing how far I
got. I can trap '+' (via w32HKeyDown), ignore it, or set the combobox
to "plus". I can trap pagedown (via w32HKeyPress) (if you press
pagedown twice, "pagedown" does appear) but cannot stop windows
selecting "error" from the dropdown. I have also tried manually
resetting it in the onchange event, also with a returnValue(-1) to no
avail. Can anyone help me please? If I can't trap it like this, where
would be a good place to reset it later?
I get the same results using win32lib 0.57.12, 55.5, and 55.1
Pete
include win32lib.ew
constant MAIN =3D create(Window,"Main",0,0,0,Default,Default,0),
Cbox =3D create(ComboBox,"",MAIN,220,4,120,340,0)
constant Cstrings =3D {"start","error"}
addItem(Cbox,Cstrings)
setIndex(Cbox,1)
procedure onkeydown(integer self, integer event, sequence params)
integer keycode
keycode=3Dparams[1]
if keycode=3D'+' then
-- setText(Cbox,"plus")
returnValue(-1)
end if
if keycode=3DVK_PAGEDOWN then
setText(Cbox,"pagedown")
returnValue(-1) -- ineffective
end if
end procedure
integer Ctxt -- the editbox child control of the ComboBox
sequence void
void =3D findChildren(Cbox)
Ctxt=3Dvoid[1][1]
constant controllist=3D{MAIN,Cbox,Ctxt}
setHandler(controllist,{w32HKeyDown,w32HKeyPress},
routine_id("onkeydown"))
WinMain(MAIN,Normal)
2. Re: Trapping virtual keys in combo boxes
On Mon, 9 Dec 2002 13:55:22 +1100, Patrick.Barnes at transgrid.com.au
wrote:
>I changed your test proggy a bit, and this works.
>You don't really need the returnValue(-1)'s either
I wrote:
>If I can't trap it like this, where
>would be a good place to reset it later?
That's actually what you have found, When you press pagedown, you can
see error appear on the screen & it goes away when you release the
pagedown key. Thanks, I may be able to hack something from this with
half a dozen more control flags :(
Pete