[comp.windows.ms.programmer] ChangeAccelerator

risto@tuura.UUCP (Risto Lankinen) (02/06/91)

Hi!

I'm making a Windows program with a few controls (mainly buttons), which are
children of a child window of the main window.  I'll show ya:

   hWndMain --(child)--> hWndChild --(children)-+-> hWndButton[1]
                                                +-> hWndButton[2]
                                                |      . . .
                                                +-> hWndButton[N]

The child window is 'ribbon', in terminology used by Word for Windows.
I cannot (=wouldn't like to) create the buttons directly from the main
window, because I'm planning to make the ribbon control a stand-alone
class in a custom DLL, which would have its own resizing logic, etc.

The buttons are changed dynamically at run-time, and they most have an
accelerator (as in "Do &This" being triggered with the Alt+'T'), which
is defined with WM_SETTEXT, and makes the underlined character be shown
accordingly.

By pressing the buttons with the mouse, there's no problem in receiving
WM_COMMAND messages at the hWndChild's window procedure, nor forwarding
them to the main window procedure.  Unfortunately I haven't found a way
to use their 'accelerators' from the keyboard.

I've managed to make a more or less working handler for the WM_MENUCHAR
message in order to trap the Alt+<char> events and act depending on the
state of the buttons.  I think there's also a way to do what I'm aiming,
by fiddling with child window activation & focus setting functions, but
they're kinda scary...

What I'd like to do, is to tell the accelerator table to modify itself at
run-time and reflect the changes I'm making to the configuration of the
buttons.  This is much like the Windows already does, when an application
changes its menu. (<in low voice:> Maybe there's an undocumented call...)

If impossible, I'd be glad of any ideas on how to do it in an other way,
using which I could avoid the struggle I'm having with the WM_MENUCHAR
message handling.

Terveisin: Risto Lankinen

P.S. I've tried R:ing TFM, really.  The Guide to Programming is verbose
on the different ways you can make use of a particular control, but even
the sample program utilizes one control only, making itself essentially
unusable as an example for one who wishes to learn how to make a number
of them interact.
-- 
Risto Lankinen / product specialist ***************************************
Nokia Data Systems, Technology Dept *  2                              2   *
THIS SPACE INTENTIONALLY LEFT BLANK * 2 -1 is PRIME!  Now working on 2 +1 *
replies: risto@yj.data.nokia.fi     ***************************************

mmshah@athena.mit.edu (Milan M Shah) (02/08/91)

Accelerator tables are resources, and associated with window classes. So,
if you are infact registering your class with a specified accelerator table,
perhaps you can do a SetClassWord on the accelerator resource?

I am pretty sure I could make this fly if it were a 'regular' window class
/ window, but I have not played around with custom controls, so I don't know.
These, I think, can be used simultaneously by different apps, so I don't know
if doing a SetClassWord would work.

Milan.
.