How to intercept the ALT key in a datawindowcontrol

Back Up Next

Title: How to intercept the ALT key in a datawindowcontrol
Author: Eric Aling
Accessed:

Sometimes, people want to intercept the ALT key when they are in an editable field of a datawindow. Now this ALT key is a pretty special key and intercepting it is not as easy as intercepting another keystroke. However, we can intercept it because when pressing the ALT key, the windows menu is activated, so a message was sent. To intercept this message, create a userevent mapped to pbm_syscommand, which is in fact mapped to WM_SYSCOMMAND. This event is triggered when a window''s control menu is activated by a keystroke ( which is done via the ALT key ).

For instance, I want to intercept the ALT key when dw_2 has the focus, so in the window's userevent mapped to pbm_syscommand code:

GraphicObject lgo_go
DataWindow ldw_dw
/* check for SC_KEYMENU (61696) */
if commandtype = 61696 then
	lgo_go = GetFocus( ) 
	if TypeOf(lgo_go) = DataWindow! then
		ldw_dw = lgo_go

		if handle(ldw_dw) = handle(dw_2) then
			beep(1)
/* do here what you want i.e. dw_2.Event ue_KeyAltPressed() */
			message.processed = true
			dw_2.SetFocus()
		end if
	end if
end if

Good luck!

 

Back Up Next