Re: Want to change menu text on the fly
- From: r_z_aret@xxxxxxxxxxxx
- Date: Thu, 20 Apr 2006 18:54:13 -0400
On Thu, 20 Apr 2006 11:48:03 -0700, "Dennis" <junk@xxxxxxxxxx> wrote:
I'm developing a non-MFC C++ app using EVC 3.0.
I have a menu bar along the bottom of the screen and one of the items shown
on it is 'TX' which means 'click this if you want to transmit data'. What I
want to do is to change the text of this menu item on the fly so that if
there are 15 items to transmit, it will say, 'TX15'. And when there are
none, it will say, 'TX00'.
Note, TX is right on the bar - it is not a drop down. I can click TX and
the transmits happen.
I've written the following code to
(1) get the current text for the item
(2) update the text for the item
(3) force the menu bar to update so the new text is displayed.
Seems straightforward but I cannot get the menu bar to update and show the
new text. Here's the code:
I change menu item text only when responding to a WM_INITMENU (or
WM_INITMENUPOPUP for CE). I don't see any notes, but think that's the
only way I've succeeded. I don't know how that would (or could) work
for the main menu. Fortunately for _me_, I haven't had to change
labels on the main menu.
---------------------------------
_TCHAR sz[ 32 ]; // big enough by far
int nCnt = g_pRegBuf->PcktCnt(); // get # of items to send
UINT uMiiSiz = sizeof( MENUITEMINFO );
HMENU hMenu = SHGetMenu( g_mbi.hwndMB ); // g_mbi is a global elsewhere
MENUITEMINFO mii;
ZeroMemory( PVOID( &mii ), uMiiSiz );
//...read current menu data
mii.cbSize = uMiiSiz;
mii.fMask = MIIM_TYPE;
mii.fType = MFT_STRING;
mii.wID = IDM_OPT_TX; // identifies my menu item on the bar
mii.hSubMenu = NULL;
mii.dwTypeData = sz;
mii.cch = MINBUFSIZ;
I think cch should be the length of the actual string (_tcslen( sz )).
I _assume_ you left out the call to SetMenuItemInfo.
------------------------------------------------------------
Any clues would be helpful.
Many thanks in advance.
Dennis Gallagher
-----------------------------------------
To reply to me, remove the underscores (_) from my email address (and please indicate which newsgroup and message).
Robert E. Zaret, eMVP
PenFact, Inc.
20 Park Plaza, Suite 478
Boston, MA 02116
www.penfact.com
.
- References:
- Want to change menu text on the fly
- From: Dennis
- Want to change menu text on the fly
- Prev by Date: Re: PPC2002 with built in WiFi ???
- Next by Date: Re: Read line from file
- Previous by thread: Want to change menu text on the fly
- Next by thread: PPC2002 with built in WiFi ???
- Index(es):