How to change the text of a menu item dynamically?

Hi to all,

I created a dialog-based project with Visual C++ 6.0 and 
added to the dialog a menu. This menu is the following:

File          Help
  Sound On      About
  Exit

Everything is working fine so far. What I want to do, is 
change the text of the menu item "Sound On" to "Sound 
Off" every time the user clicks on it. I am using the 
CCmdUI* pCmdUI of the ON_UPDATE_COMMAND_UI handler to do 
it as follows:

  void CMyDlg::OnUpdateFileSound(CCmdUI* pCmdUI) 
  {
     TRACE("OnUpdate\n");
     pCmdUI->SetText(m_bSound ? "Sound On" : "Sound Off");
  }

Where 'm_bSound' is a boolean variable that is toggled in 
the ON_COMMAND handler:

  void CMyDlg::OnFileSound() 
  {
     TRACE("OnFileSound\n");
     m_bSound = !m_bSound;
  }

This is not working. The problem I'm having is that 
OnUpdateFileSound() is called when I click on the "Sound 
On" menu item where it should be called when the "File" 
submenu is poped up.

Can someone please help me with this one?

Thanks in advance.

Geo.
0
ckarakiro (63)
7/27/2003 3:13:18 PM
vc.mfc 33608 articles. 0 followers. Follow

1 Replies
639 Views

Similar Articles

[PageSpeed] 18

Thank you for your answers. I found what I wanted in the 
MFC sample: dlgcbr32.

Geo

>-----Original Message-----
>Hi to all,
>
>I created a dialog-based project with Visual C++ 6.0 and 
>added to the dialog a menu. This menu is the following:
>
>File          Help
>  Sound On      About
>  Exit
>
>Everything is working fine so far. What I want to do, is 
>change the text of the menu item "Sound On" to "Sound 
>Off" every time the user clicks on it. I am using the 
>CCmdUI* pCmdUI of the ON_UPDATE_COMMAND_UI handler to do 
>it as follows:
>
>  void CMyDlg::OnUpdateFileSound(CCmdUI* pCmdUI) 
>  {
>     TRACE("OnUpdate\n");
>     pCmdUI->SetText(m_bSound ? "Sound On" : "Sound 
Off");
>  }
>
>Where 'm_bSound' is a boolean variable that is toggled 
in 
>the ON_COMMAND handler:
>
>  void CMyDlg::OnFileSound() 
>  {
>     TRACE("OnFileSound\n");
>     m_bSound = !m_bSound;
>  }
>
>This is not working. The problem I'm having is that 
>OnUpdateFileSound() is called when I click on the "Sound 
>On" menu item where it should be called when the "File" 
>submenu is poped up.
>
>Can someone please help me with this one?
>
>Thanks in advance.
>
>Geo.
>.
>
0
ckarakiro (63)
7/28/2003 2:23:49 PM
Reply:

Similar Artilces:

Text Shadow
I want to add a shadow to text in a cell. This shouldn't be complicated. The help section said to choose the Text Shadow button on the formatting bar. I don't see one. I tried to add/remove buttons from the bar it wouldn't let me into the bar to do anything. Any suggestions. I cannot imagine that Excel doesn't have a text shadow option. Thanks! Help section? That is for wordart, text boxes and pictures, for plain text there is none, why would it? -- Regards, Peo Sjoblom (No private emails please) "Natalie" <Natalie@discussions.microsoft.com> w...

No 'Services' option on Tools menu
Using Outlook 2000. Trying to configure an add-in address book. Directions are to go to Tools | Services. However, I don't have a Services option. Checked & I am setup as an IMO. Any ideas would be great. What address book service? Most likely it won't work with IMO because IMO doesn't support MAPI. You can always switch if you want. For information on choosing a mail support mode or changing to the other mail support mode, look here: http://www.slipstick.com/outlook/choosingmode.htm -- Russ Valentine [MVP-Outlook] "Berkshire" <raburn@yahoo.com> wrote...

External data link change
Hi, I've a sheet linked to an external data on the net, and I would like that a cell in this sheet to indicate the last date and time it was updated, the simplest way the better but I can do some programming too. Thanks for your attention, -- Domingos Junqueira No need of help any more, I solved the question. Thanks again ...

Import from Notepad delimited text
Is it possible to import from Notepad . There is a table with pipe delimiters that is automatically generated in a .dat text file using Notepad which I would like to import / link into my database daily. This .dat file arrives via email each day as an attachment. I tried saving the .dat file into a .txt extension but ACCESS wouldn't recognize it . I currently need to use the excel text wizard everyday to convert this file into an .xls format . I then have my access 2003 database linking to this ..xls file. Although I know how to convert this .dat file there are others ...

Why does the change change to a number?
Hi all, I've noticed something wierd and always wondered WHY it happens. When you type a date into a cell, and then change the Formatting of it to a 'general' cell, it turns into a number. How does it come up with that number? What is the significance? i.e. type today's date of "12/7/2007" - change it to a 'General' format, and it then says "39423". I'm a trainer of Excel and this question always comes up. I'm curious myself too. Thanks! Joe It's the number of days since January zero 1900 using Excel default for windows (M...

changing the way Excel displays selected cells
Is there a way to change the way Excel displays selected cells? I'm interested in viewing all the selected cells highlighted (with light blue for instance), but by default excel highlights all the cells but not the first one the same occurs when you define a range with no adyacents cells Your definition of the display is not quite correct. Excel highlights the current cell, Excel also highlights a selecte range. The currently selected cell is generally the first of a range, bu press enter and the current cell changes and becomes the second, the third etc in the range. You cannot...

physical count of serialized items
how RMS will deal with serialized items if we make a physical count and the quantity was different of database. our setting is : -require serial number when receiving inventory -synchronize quantiy with serial numbers -inforce unique serial in POS how will we synchronize the serial numbers the new QTY . any help please. best reqards This is a multi-part message in MIME format. ------=_NextPart_000_00F2_01C89A52.C606CF70 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Bacha11, Badly, its been repor...

Track Changes
How do i remove the track changes in outlook? When i press "Enter", a symbol that represents "Enter" will appears. Same for space etc. ...

DST changes for Exchange 5.5
I noticed the 2007 DST Calendar Update "Exchange tool" is available now: http://support.microsoft.com/kb/930879 This will seemingly take care of calendars for mailboxes still on Exchange 5.5 servers, as Exchange 5.5 is listed as "compatible" . However would this address the CDO issues such as BlackBerry users and OWA users still on Exchange 5.5 ? Thanks in advance, Itrcb4 On Mon, 12 Feb 2007 14:31:00 -0800, itrcb4 <itrcb4@discussions.microsoft.com> wrote: >I noticed the 2007 DST Calendar Update "Exchange tool" is available now: > >http://su...

more on VBA function name change
I thought I'd start a new thread since I haven't received any replies to my first one... To recap: I've declared a function in a module using mixed case: Function TMDE_Category (FormName As Form) I noticed recently that it appeared in the module as Function tmde_category(FormName As Form) I changed it back to the mixed case declaration, saved the module, exited the app, reopened it and looked. The function had changed back to the all lowercase declaration. Things I've tried since the original post: Using the databse documenter, I selected all ob...

Can't Publish changes with Deploy Manager
After a migration process, I can't publish the changes made on CRM. When I try do this in Deploy Manager I get the follow error: ---------------------------------------------------------------------------- ----- Publish done with errors. See the event log to get deitails NETRA-INOVACAO: ***Error*** Failed to download XSL template files from Web Server ---------------------------------------------------------------------------- ----- Can somebody help me? I don't know if the migration process have any relationship with the error. Thank you for pay attention. []'s Vin´┐Żcius Pitta...

Convert dates stored as text
I have Excel 2007 in English, but I sometimes receive data that comes from another applicationes, so dates are stored as text because they come in following format: dd/mm/yyyy. And I have the format mm/dd/yyyy. So, in the same column, I have dates stored as dates, and dates stored as text. Which is the easiest way to convert them all to date format? Thanks in advance. Regards, Emece.- Be careful. I'd bet that those values that come in as real dates aren't what the original data represent. For instance, if you have two values: 25/12/2010 and 01/02/2010 The...

How to change icon for my application
Hi, I am currently developing an application on visual studio 6.0, and i wish to change the MFC icon on my application header. Anyone can help? Thank you. Raed Sawalha wrote: > Hi, I am currently developing an application on visual studio 6.0, and i > wish to change the MFC icon on my application header. Anyone can help? Thank > you. > > Open the icon resource for editing by double clicking. Then notice the control just above the editing grid that lets you switch between editing the large icon and editing the small one. -- Scott McPhillips [VC++ MVP] thanx that work...

Send.Item message when using mapi emailing
Hi, When using the MAPI profile to send mails via Send.Item Outlook stops and shows the Yes, No message for permission to send. I have checked all IE settings and Outlook but cant turn this off? I know its there somewhere, any help locating and turning off this setting would be fantastic! Kind Regards James See http://www.outlookcode.com/d/sec.htm for your options with regard to the "object model guard" security in Outlook 2000 SP2 and later versions. -- Sue Mosher, Outlook MVP Author of Microsoft Outlook Programming - Jumpstart for Administrators, Power Users, an...

Excel Pivot Items Using C#
I am working on a C# add-in that modifies pivot tables. I have done this work in VBA, and the object model seems straightforward, e.g., PivotTable-PivotFields-PivotItems, but I can not get the object for PivotItems, or iterate through the items. Do I need something other than PivotItems? Code for PivotFields, that works: IExcel.PivotFields pvtfs = (IExcel.PivotFields) pvtTable.get_PageFields(Missing.Value); foreach (IExcel.PivotField pvtf in pvtfs) { Code for the does nto work, and PivotItems shows no va...

Border with text
I'm trying to make a border using text. I want to repeat the same phrase over and over again. Idealy, I'd like the words to make a rectangular border for a sign... and when it hit the corner of the page, the phrase would continue down the next angle, and so on, until it made a box. Does anyone have any ideas on how to do this? WordArt would be your only option. If you had a draw program... Serif has a free draw application. http://www.freeserifsoftware.com/ OpenOffice is free and has a draw feature. www.openoffice.org I have a method using WordArt on my web site that might be...

How to change newsgroup message font
Like many other ribbon based programs I sometimes struggle to find how to make a change. This time its how to change the font just for newsgroup messages? regards "nobody" wrote in message news:EWTao.39493$GF5.7129@hurricane... > Like many other ribbon based programs I sometimes struggle to find how to make a change. This time its how to change the font just for newsgroup messages? Newsgroup messages are usually plain text. The font used is that selected at [no name tab] > Options > Mail > Read > Fonts for the encoding specified for the messag...

How do I replace the last entire word in text cells?
I understand the REPLACE command but it seems restricted to characters or bytes. I this case, I want to replace the last word in all cells but the word is always different (ie. varying number of characters). Thanks in advance! Array entered (CTRL+SHIFT+ENTER), this will work: =LEFT(A1,LEN(A1)-MATCH(" ",MID(A1,LEN(A1)-ROW(INDIRECT("1:"&LEN(A1)))+1,1),0)) Change the reference to A1 to which ever cell you want. -- Regards, Dave "George" wrote: > I understand the REPLACE command but it seems restricted to characters or > bytes. I this case, I wan...

Notify change of email address when changing ISP
How do I notify my entire address book of an email address when I change ISP's? Thanks By sending a mail to everyone ? If you do so, please use BCC for the adresses, this way you won't spread everybody's e-mail adres to everybody. Niels Bob Baker wrote: > How do I notify my entire address book of an email address when I change ISP's? > Thanks ...

Change a formula to an acual number
I want to change the formula I have created to the number it has created Example: Cell A1 is the number 1. Cell A2 is the formula =a1+1 creatin the number 2. I want this to be a two not a formula. Any ideas? Laura, copy, then paste special, valves -- Paul B Always backup your data before trying something new Please post any response to the newsgroups so others can benefit from it Feedback on answers is always appreciated! Using Excel 2000 & 97 ** remove news from my email address to reply by email ** "Laura" <anonymous@discussions.microsoft.com> wrote in message news...

Text Functions
I'm trying to split a text string ... Apart from it not working quite right yet! I'm sure I've over complicated it. Base Data "Path": \\SERVER\X$\data\Team Name\Personal Data\JOE BLOGGS\mail\ \\SERVER\X$\ \\SERVER\X$\RECYCLER\ \\SERVER\X$\$Extend\ \\SERVER\X$\$Extend\Test I'm trying to split into High Level Directory (HLD) / Team/User Directory (TUD) / Team/User Sub-Directory HLD: =IFERROR(SUBSTITUTE(LEFT(Path,(SEARCH("\",Path,(SEARCH("\",Path,(SEARCH("X$",Path,1))+3))+1))),"\\SERVER\X$\",""),SUBS...

How do I use cond format formula to set cell text and color?
Using MS Excel 2003: As and example, I entered into Conditional Format for cell B1: "Formula is", IF(A1="","Test",""). For true condition, the format is set to fill Yellow and font color red. I'm expecting cell B1 to display, "Test" in red text with yellow background when A1 is blank, but it does not work. No errors are displayed. Any ideas? in my experience you can only set the format,you cant have the word test show up.Apply the format condition only using =A1="" and put a seperate if statement in the cell.If it blank ...

Problem Changing an Investment Name
I am trying to change an investment name and Money 2006 tells me "The name or symbol 'TRP Spectrum Income' has already been used for a deleted investment. Please enter a different name." When I go to delete investments the name does not appear! Any ideas on how I get Money to accept the name change? This is the first time I have run into this situation and I have made numerous name changes in Money over the years. In microsoft.public.money, Ken wrote: >I am trying to change an investment name and Money 2006 tells me "The name >or symbol 'TRP Spec...

Should I change this code?
Should I change 556 to 560???..............Thanks for your help..........Bob Private Sub Command560_Click() On Error GoTo Err_Command556_Click Dim stDocName As String Dim stLinkCriteria As String stDocName = "frmClientInfomation" DoCmd.OpenForm stDocName, , , stLinkCriteria Exit_Command556_Click: Exit Sub Err_Command556_Click: MsgBox Err.Description Resume Exit_Command556_Click End Sub On Sun, 15 Jul 2007 16:37:26 +1200, "Bob V" <rjvance@ihug.co.nz> wrote: > >Should I change 556 to 560???..............Thanks for your help.....

Sub Menu in CTreeCtrl
Hi, are there any examples that add a sub menu showing when the user right clicks the tree item? thanks again. You could catch the WM_RBUTTONUP message and call following function: { CMenu menu; menu.CreatePopupMenu(); menu.AppendMenu(MF_STRING,1,"String 1"); menu.AppendMenu(MF_STRING,2,"String 2"); menu.AppendMenu(MF_STRING,3,"String 3"); menu.AppendMenu(MF_STRING,4,"String 4"); CPoint pt; GetCursorPos(&pt); int ret = menu.TrackPopupMenu(TPM_NONOTIFY | TPM_RETURNCMD,pt.x,pt.y,this); switch(ret) { ...