Shortcuts for buttons don't work when focus is on OCX-control

streetpeet

New Member
Hi there,

We have used the MS version 6 Treeview -OCX in our progress 9.1C application. However, when the focus is on the treeview-control the shortcuts for buttons on the containing window do not work (nor do some other keyevents for the containing window; the menu-shortcuts work however!).
(we have implemented the shortcuts on the buttons by using the '&'-character in the label).

Does anyone know a solution or work-around to this problem?
(Except for writing code calling each button 'hard-coded')

Greetings,
Peter
 
Try hacking this for your own use.

You have to trap the keydown event in the ocx.



/*********************************************************************************
** I N C L U D E
** -------------
**
** File: result/object/accel.i
**
** Author: Chris Paulson
**
** Date: 17-09-96
**
** Description: Code to pass activate window menu accelerators from within
** vbxs. Circumvents a known Progress bug.
**
**
*********************************************************************************/

define variable keymodifier as integer no-undo.

define temp-table t_accelerator no-undo
field accelerator as char
field h_menu-item as handle

index primary is primary unique
accelerator .


PROCEDURE BuildAccelerators :
/**/
define input parameter p_menu as handle no-undo.

define variable widget as widget-handle no-undo.
define variable butAcc as character no-undo.

/* MJGK - 9 January 1998 */
if p_menu:type = "BUTTON" then do:
assign butAcc = p_menu:label.
if index(butAcc, "&") <> 0 and
substring(butAcc, (index(butAcc, "&") + 1), 1) <> "&" then
assign butAcc = "ALT-" + substring(butAcc, (index(butAcc, "&") + 1), 1).
else
assign butAcc = "ALT-" + substring(butAcc, 1, 1).
if butAcc <> "ALT-" then do:
find t_accelerator exclusive-lock
where t_accelerator.accelerator = butAcc
NO-ERROR.

if not available ( t_accelerator ) then
do:
create t_accelerator.
assign t_accelerator.accelerator = butAcc.
end.

assign t_accelerator.h_menu-item = p_menu:handle.
end.
end.
else do:
assign widget = p_menu:first-child.

do while widget ne ?:
if widget:type = "SUB-MENU":u
then
run BuildAccelerators ( input widget ).
else
if can-query ( widget, "ACCELERATOR":u ) and
widget:ACCELERATOR ne ? then
do:
find t_accelerator exclusive-lock
where t_accelerator.accelerator = widget:ACCELERATOR
NO-ERROR.

if not available ( t_accelerator ) then
do:
create t_accelerator.
assign t_accelerator.accelerator = widget:ACCELERATOR.
end.

assign t_accelerator.h_menu-item = widget:handle.
end.

assign widget = widget:next-sibling.
end.
end.

END PROCEDURE.


PROCEDURE CheckKeyAccelerator :
/**/
define input parameter nKeyCode as integer no-undo.
define input parameter nKeyShift as integer no-undo.

if keymodifier = 0 and ( nKeyShift > 0 or nKeyCode = 18 )
then
assign keymodifier = nKeyShift + 1.
else
do:
find t_accelerator exclusive-lock
where t_accelerator.accelerator = (if keymodifier > 0
then entry ( keymodifier
, "ALT-,SHIFT-,CTRL-,,ALT-" )
else "":u )
+ (if nKeyCode < 112 or nKeyCode > 123
then keylabel ( nKeyCode )
else "F" + string ( nKeyCode - 111 ) )
NO-ERROR.

if available ( t_accelerator ) and
valid-handle ( t_accelerator.h_menu-item )
then
apply "choose":U to t_accelerator.h_menu-item.

assign keymodifier = 0.
end.

END PROCEDURE.

/****************************** END INCLUDE *************************************/
 
Back
Top