Philip Salgannik showed how to intercept keys from a DataWindow in a post to
sybase.public.powerbuilder.datawindow on 2004-04-27. This really filters the keys, rather than undoing them.
Declare an external function for PeekMessage (for older PB use PeekMessageA):
:
function boolean PeekMessage( Ref blob lpMsg, long hWnd, UINT uMsgFilterMin, UINT uMsgFilterMax, UINT wRemoveMsg ) Library "USER32.dll" alias for "PeekMessageW"
//WM_KEYFIRST = 0x0100 // 256
//WM_KEYLAST = 0x0108 // 264
//PM_REMOVE = 1
Map the pbm_dwnkey event and name it either key
or ue_key
according to your philosopy. Add this code to the event:
if 0 = keyflags and (key = KeyDash! or key = KeySubtract!) then
choose case ls_col
case "col_1", "col_2" // ... we have many columns in the list
PeekMessage( Msg, 0, 256, 264, 1 ) // see the declaration for values. this removes the message.
message.processed=TRUE
message.returnvalue=1
return
case else
// nothing else
end choose
end if
I tried several times to get this to format correctly with no success.
I'm not sure that setting message.processed and message.returnvalue has any effect. It doesn't normally from this event. I kept them when I used the code because I didn't have time to experiment.