From: David Webber on
I want to change the text on a menu on the fly.

So I do this with pCmdUI->SetText() in its ON_UPDATE_COMMAND_UI handler.

It works fine except....

....when the text ends in \tCtrl+X to add my (home grown) shortcut, (or
\tAnything) this bit is subsequently removed (as the command has no entry in
the ACCELERATORS table).

With the old CMDIFrameWnd, CToolBar, CMenu etc stuff it all worked the way
it said on the tin.

But with the new CMDIFrameWndEx, CMFCToolBar, CMFCMenuBar stuff, it's
deciding it knows better than I do what the text should be. This is
infuriating. What has happened to the MFC framework I knew and ... (well
knew)?

(I've checked pCmdUI->m_bContinueProcessing and it's definitely FALSE. )

Any ideas on where the override might be happening? Looking through the
MFC source code for clues is like finding a needle in a haystack.

Dave
--
David Webber
Mozart Music Software
http://www.mozart.co.uk
For discussion and support see
http://www.mozart.co.uk/mozartists/mailinglist.htm



From: Joseph M. Newcomer on
The new framework is smart, has support for letting you add shortcuts, and creates the
shortcut information dynamically.

Since it is possible to add the shortcut to the accelerator table, you should do so.
joe

On Sun, 27 Jun 2010 09:37:36 +0100, "David Webber" <dave(a)musical-dot-demon-dot-co.uk>
wrote:

>I want to change the text on a menu on the fly.
>
>So I do this with pCmdUI->SetText() in its ON_UPDATE_COMMAND_UI handler.
>
>It works fine except....
>
>...when the text ends in \tCtrl+X to add my (home grown) shortcut, (or
>\tAnything) this bit is subsequently removed (as the command has no entry in
>the ACCELERATORS table).
>
>With the old CMDIFrameWnd, CToolBar, CMenu etc stuff it all worked the way
>it said on the tin.
>
>But with the new CMDIFrameWndEx, CMFCToolBar, CMFCMenuBar stuff, it's
>deciding it knows better than I do what the text should be. This is
>infuriating. What has happened to the MFC framework I knew and ... (well
>knew)?
>
>(I've checked pCmdUI->m_bContinueProcessing and it's definitely FALSE. )
>
>Any ideas on where the override might be happening? Looking through the
>MFC source code for clues is like finding a needle in a haystack.
>
>Dave
Joseph M. Newcomer [MVP]
email: newcomer(a)flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
From: David Webber on


"Joseph M. Newcomer" <newcomer(a)flounder.com> wrote in message
news:rrde26t4eo35r1p6hlar1ao272set02gkp(a)4ax.com...

> The new framework is smart, has support for letting you add shortcuts, and
> creates the
> shortcut information dynamically.
>
> Since it is possible to add the shortcut to the accelerator table, you
> should do so.

That is one of the routes I'm exploring - as you say it may be the best one.

There seems to be a CKeyboardManager class which does this sort of thing and
a method

CWinAppEx::GetKeyboardManager()

that gets the one which looks after the frame windows. I'll experiment!
(Suck it and see is the only way given the state of the documentation.)

Dave
--
David Webber
Mozart Music Software
http://www.mozart.co.uk
For discussion and support see
http://www.mozart.co.uk/mozartists/mailinglist.htm