Re: Trapping the TAB key
- Posted by euman at bellsouth.net May 06, 2002
- 389 views
----- Original Message ----- From: "Jonas Temple" <jktemple at yhti.net> > > Does anyone know how, using Win32lib, to trap when the TAB key is > pressed in: edit control, combo, dropdownlist? I dont mind helping those who help theirself..... Here's what you need to look for Jonas..... global function shift_left (atom x, integer count) return x * power (2, count) end function global function MAKELONG (atom a, atom b) return or_bits (a, shift_left (b, 16)) end function atom user32 user32 = open_dll("user32.dll") constant xPeekMessage = define_c_func(user32, "PeekMessageA",{C_POINTER,C_LONG,C_UINT,C_UINT,C_UINT},C_LONG) ,xGetParent = define_c_func(user32, "GetParent",{C_LONG},C_LONG) ,xSendMessage = define_c_func(user32, "SendMessageA", {C_LONG, C_LONG, C_INT, C_LONG}, C_LONG) global function SendMessage(atom hwnd, atom msg, atom wParam, atom lParam) return c_func(xSendMessage,{hwnd, msg, wParam, lParam}) end function constant WM_CHAR = 258, PM_REMOVE = 1 -- this should be consealed in your edit controls subclass in "if iMsg = WM_KEYDOWN then" if wParam = 9 then -- handle tabkey fo edit control junk = c_func(xPeekMessage,{tagMSG, c_func(xGetParent,{handle}), 0, 0, PM_REMOVE}) junk = SendMessage(handle, WM_CHAR, wParam, MAKELONG(1, 14)) end if handle will be the control ID....should work the same for MLE's, Combo's etc, etc.. This traps the tabkey by sending a message to itself for further processing. WOW, Cool eh? Euman