ON_UPDATE_COMMAND_UI_RANGE not working

Hi, hope somebody can help me with this strange issue.

I've a DLL that exports a CDialog based class, which contains a menu.
For this menu I've declared both ON_UPDATE_COMMAND_UI_RANGE
and ON_COMMAND_RANGE macros:

ON_UPDATE_COMMAND_UI_RANGE(IDC_RESOURCE1,IDC_RESOURCE4,OnUpdateResource)
ON_COMMAND_RANGE(IDC_RESOURCE1,IDC_RESOURCE4,OnResource)

so my idea is to check the correct menu option when it's displayed, by
using OnUpdateResource:

void CMyDialog::OnUpdateResource(CCmdUI* pCmdUI)
{
    pCmdUI->SetCheck((m_nResource == pCmdUI->m_nID - IDC_RESOURCE1 +
1)?1:0);
}

The strange problem is that OnUpdateResource IS NEVER CALLED!!!, so my
menu option is never checked. I use this exactly same code in the main
application menu resource, and there it works fine, so I'm compelled
to think that this has something to do with the fact that the resource
"lives" on a DLL. But, in the other side, the ON_COMMAND macro works
perfectly (?!?!)



0
10/6/2004 8:01:14 PM
vc.mfc 33608 articles. 0 followers. Follow

3 Replies
1765 Views

Similar Articles

[PageSpeed] 57

I'm not certain, but is this an AFX_MANAGE_STATE issue?  See "Exported DLL
Function Entry Points" at
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore98/HTML/_core_exported_dll_function_entry_points.asp
and "TN058: MFC Module State Implementation" at
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmfc98/html/_mfcnotes_tn058.asp

Mike


"Alvaro Palma" <invalid_address@invalid_domain.com> wrote in message
news:%23MffF%239qEHA.1952@TK2MSFTNGP12.phx.gbl...
> Hi, hope somebody can help me with this strange issue.
>
> I've a DLL that exports a CDialog based class, which contains a menu.
> For this menu I've declared both ON_UPDATE_COMMAND_UI_RANGE
> and ON_COMMAND_RANGE macros:
>
> ON_UPDATE_COMMAND_UI_RANGE(IDC_RESOURCE1,IDC_RESOURCE4,OnUpdateResource)
> ON_COMMAND_RANGE(IDC_RESOURCE1,IDC_RESOURCE4,OnResource)
>
> so my idea is to check the correct menu option when it's displayed, by
> using OnUpdateResource:
>
> void CMyDialog::OnUpdateResource(CCmdUI* pCmdUI)
> {
>     pCmdUI->SetCheck((m_nResource == pCmdUI->m_nID - IDC_RESOURCE1 +
> 1)?1:0);
> }
>
> The strange problem is that OnUpdateResource IS NEVER CALLED!!!, so my
> menu option is never checked. I use this exactly same code in the main
> application menu resource, and there it works fine, so I'm compelled
> to think that this has something to do with the fact that the resource
> "lives" on a DLL. But, in the other side, the ON_COMMAND macro works
> perfectly (?!?!)
>
>
>


0
10/6/2004 8:42:23 PM
Thanks for your help. I found the answer, this is a kind of bug:

http://support.microsoft.com/default.aspx?scid=kb;en-us;242577&Product=vcc

Anyway, thanks again

"Michael K. O'Neill" <MikeAThon2000@nospam.hotmail.com> wrote in message
news:OkL4$T%23qEHA.1988@TK2MSFTNGP09.phx.gbl...
> I'm not certain, but is this an AFX_MANAGE_STATE issue?  See "Exported DLL
> Function Entry Points" at
>
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore98/HTML/_core_exported_dll_function_entry_points.asp
> and "TN058: MFC Module State Implementation" at
>
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmfc98/html/_mfcnotes_tn058.asp
>
> Mike
>
>
> "Alvaro Palma" <invalid_address@invalid_domain.com> wrote in message
> news:%23MffF%239qEHA.1952@TK2MSFTNGP12.phx.gbl...
> > Hi, hope somebody can help me with this strange issue.
> >
> > I've a DLL that exports a CDialog based class, which contains a menu.
> > For this menu I've declared both ON_UPDATE_COMMAND_UI_RANGE
> > and ON_COMMAND_RANGE macros:
> >
> > ON_UPDATE_COMMAND_UI_RANGE(IDC_RESOURCE1,IDC_RESOURCE4,OnUpdateResource)
> > ON_COMMAND_RANGE(IDC_RESOURCE1,IDC_RESOURCE4,OnResource)
> >
> > so my idea is to check the correct menu option when it's displayed, by
> > using OnUpdateResource:
> >
> > void CMyDialog::OnUpdateResource(CCmdUI* pCmdUI)
> > {
> >     pCmdUI->SetCheck((m_nResource == pCmdUI->m_nID - IDC_RESOURCE1 +
> > 1)?1:0);
> > }
> >
> > The strange problem is that OnUpdateResource IS NEVER CALLED!!!, so my
> > menu option is never checked. I use this exactly same code in the main
> > application menu resource, and there it works fine, so I'm compelled
> > to think that this has something to do with the fact that the resource
> > "lives" on a DLL. But, in the other side, the ON_COMMAND macro works
> > perfectly (?!?!)
> >
> >
> >
>
>


0
10/6/2004 8:47:08 PM
I woudl not call this a bug. As mentioned in the article, this works for
CFrameWnd derived objects. Since CDialog does not derive from CFrameWnd, you
will need to put this functionality in yourself, as shown in the article.
Its well known  and has been asked many times in this newsgroup. Other
solutions for this are available at codeguru.com.

--
Ajay Kalra [MVP - VC++]
ajaykalra@yahoo.com


"Alvaro Palma" <invalid_address@invalid_domain.com> wrote in message
news:Or1avX#qEHA.2904@TK2MSFTNGP15.phx.gbl...
> Thanks for your help. I found the answer, this is a kind of bug:
>
> http://support.microsoft.com/default.aspx?scid=kb;en-us;242577&Product=vcc
>
> Anyway, thanks again
>
> "Michael K. O'Neill" <MikeAThon2000@nospam.hotmail.com> wrote in message
> news:OkL4$T%23qEHA.1988@TK2MSFTNGP09.phx.gbl...
> > I'm not certain, but is this an AFX_MANAGE_STATE issue?  See "Exported
DLL
> > Function Entry Points" at
> >
>
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore98/HT
ML/_core_exported_dll_function_entry_points.asp
> > and "TN058: MFC Module State Implementation" at
> >
>
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmfc98/htm
l/_mfcnotes_tn058.asp
> >
> > Mike
> >
> >
> > "Alvaro Palma" <invalid_address@invalid_domain.com> wrote in message
> > news:%23MffF%239qEHA.1952@TK2MSFTNGP12.phx.gbl...
> > > Hi, hope somebody can help me with this strange issue.
> > >
> > > I've a DLL that exports a CDialog based class, which contains a menu.
> > > For this menu I've declared both ON_UPDATE_COMMAND_UI_RANGE
> > > and ON_COMMAND_RANGE macros:
> > >
> > >
ON_UPDATE_COMMAND_UI_RANGE(IDC_RESOURCE1,IDC_RESOURCE4,OnUpdateResource)
> > > ON_COMMAND_RANGE(IDC_RESOURCE1,IDC_RESOURCE4,OnResource)
> > >
> > > so my idea is to check the correct menu option when it's displayed, by
> > > using OnUpdateResource:
> > >
> > > void CMyDialog::OnUpdateResource(CCmdUI* pCmdUI)
> > > {
> > >     pCmdUI->SetCheck((m_nResource == pCmdUI->m_nID - IDC_RESOURCE1 +
> > > 1)?1:0);
> > > }
> > >
> > > The strange problem is that OnUpdateResource IS NEVER CALLED!!!, so my
> > > menu option is never checked. I use this exactly same code in the main
> > > application menu resource, and there it works fine, so I'm compelled
> > > to think that this has something to do with the fact that the resource
> > > "lives" on a DLL. But, in the other side, the ON_COMMAND macro works
> > > perfectly (?!?!)
> > >
> > >
> > >
> >
> >
>
>


0
ajaykalra (6842)
10/7/2004 1:24:26 AM
Reply:

Similar Artilces:

VBA Codes does not work as shown in Help for Word 2004
I need to change the directory that opens when I use Dialogs(wdDialogsFileOpen).Show or the similar command to save. Unfortunately the command ChangeFileOpenDirectory "Macintosh HD:Users:Mitch:" does not work. I have tied the same command in a Windows version of word (with the appropriate path separators) and it works there. This is what help says. This example changes the the folder in which Word searches for documents, and then displays the Open dialog box. ChangeFileOpenDirectory "Macintosh HD:Users:Shared:" Dialogs(wdDialogFileOpen).Show. Just in case i...

Out of office not working #6
Hi sbs 2003 standard with exchange 2003. One of the users does not have his out of office working. Have removed all rules and reinstalled Outlook but still no luck. What can I do to try to fix it form here? Many Thanks Regards Have you tried deleting and recreating the Outlook profile? Can the OOF be set using OWA? "John" <info@nospam.infovis.co.uk> wrote in message news:%23v1xSeT2JHA.1096@TK2MSFTNGP06.phx.gbl... > Hi > > sbs 2003 standard with exchange 2003. One of the users does not have his out > of office working. Have removed all rules and reinstalled...

WLM works on one laptop but not another
I am having problems synchronising my mail on my Windows Vista laptop. It doesn't seem to be an issue on my work laptop. I have reinstalled Windows Live but the problem persists. I can view my mail from hotmail.com too on the Vista laptop. here's the latest error message: Unable to send or receive messages for the Hotmail (adwormleighton) account. To send and receive messages in your Hotmail account, go to http://hotmail.live.com on the Web, or try again later. To get help from Windows Live Customer Support, go to http://support.live.com and click Windows Live Mai...

Closing down Excel work books #2
I have made an excel spreadsheet that takes its information from a access data base the information automatically updates each time exce opens, I do not want to save the information. I would like it to clos down wthout the popup -- peterspindrif ----------------------------------------------------------------------- peterspindrift's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=1474 View this thread: http://www.excelforum.com/showthread.php?threadid=26362 ...

Installation cd wont work
please can you help me. i have had to reinstall office 2004 for mac but after erasing my hard drive of the original version i put the installation cd in and my mac wont read it. I am not sure why although the cd looks like it has a difference in the colouration on the readable side. it has been kept in ints box since i bought it so it should be in perfect condition. I cannot get in touch with microsoft unless i pay $35 which i dont want to do, i wondered if anybody had any ideas? thanks > This message is in MIME format. Since your mail reader does not understand this format, some or all o...

Non working time not diplaying in the "View Resource availability"
Hi , I am facing a weird problem with our PMO. We are using Pro server 2003 along with project professional 2003. We are managing our non-working times through a separate project for every team where each team members fill up their own unplanned activities. The problem is with the tracking the vaction time & displaying it in the web page under resource availability view. We are managing the non-working times through each resources individual calendars e.g. blocking the particular days as non-working time. But when we are trying to analyse the resource availability it is ...

SMS Add-in not working in Outlook 2007
I download this free add-in from MS, I a running Office 2007 SP3. The add-in installed fine, configured my Nokia N73 as Bluetooth modem (modem working verified by query modem command in Modems). New toolbar appears. New message window appears. But on sending get an error saying ' A required property is missing. Please reinstall MS outlook SMS Add-in'. try installing a couple of times but same problem. can anyone guide. "Ashish Naik" <naik.ashu@gmail.com> wrote in message news:05bb9a8c-0a54-482c-a1ad-2d2ed4b9eec0@o21g2000vbl.googlegroups.com... > I download this ...

How does Outlook's auto-complete work?
Sometime about six weeks ago, it seems that Outlook has become much more stingy in how it provides suggestions for email addresses when I type in the To line. It will only suggest from email addresses that it finds in my Inbox, whereas I thought that previously it would also keep a cache of recently used adresses or make suggestions from other folders. Did I hallucinate that? Did a setting get changed somewhere? While my Outlook usage is constant, in the last month, I have probably had to track down an address from my Sent Items about a dozen times, while normally I don't have to d...

Processing Read Receipts Doesn't Work
Hi, I use Outlook 2003. I have created a folder called: Read Receipts under my InBox. I have checked the following and asked the program to direct read receipts to the folder I created: Process requests and responses on arrival Process receipts on arrival After Processing, move receipts to "read receipts" The read receipts simply are not being moved the to read receipts folder as I want them to? I'm connected to a Exchange 2003 Server Any ideas? -- K.J.B. On Wed, 6 Dec 2006 13:46:50 -0800, "K.J.B." <blah@blah.com> wrote: >Hi, > >I use Outloo...

module function not always working
The database I created in Access 2003 has a function that checks to see if a form is loaded. The function works on the XP system it was created on as well as at least 4 others. One of which is now running Access 2007. One computer will not use the function and says it cannot find "isformloaded" function. I have verified the module is intact. I also checked the reference library which is the same. What am I missing? Mike Mike, Is the database in a Trusted Location? http://www.regina-whipp.com/index_files/TrustedLocation.htm -- Gina Whipp "I feel I have ...

E-mail notification not working. UDP packets and Citrix Environment
Hello, In our network we use Citrix Presentation Server 4.0. Our citrix server (windows 2003 SP1) has Office 2002 installed with SP3. All users use outlook to connect to Exchange 2003 SP2. When a new mail arrives at the Exchange server it takes between 1 second to 1 minute for the new mail item to popup (new mail notification) in outlook. This indicates that the UDP packet, which is send by Exchange, is not picked up by the client because the mail is not immediatly shown in outlook. When UDP fails, outlook 2002 reverts back to polling with a random interval of max 1 minute. A simple test (...

My News menu button does not work correctly. #2
My News menu button does not work correctly. When clicked, it brings up th file folder 1033, and can not be deleted. Why? How can I remove this "News" button and then enter into the news reader? I'm using XP with Office 2003, (Outlook). bernie.home <bernie.home@discussions.microsoft.com> wrote: > My News menu button does not work correctly. When clicked, it brings > up th file folder 1033, and can not be deleted. Why? How can I > remove this "News" button and then enter into the news reader? I'm > using XP with Office 2003, (Outlook). ...

spell check not working
My spell check in my vista program is not working on my email Define "not working". Any error message? -- Bruce Hagen MS-MVP [Mail] Imperial Beach, CA "Debra" <Debra@discussions.microsoft.com> wrote in message news:E236030E-6127-43E0-959B-680F5B4D0715@microsoft.com... > My spell check in my vista program is not working on my email Always include the complete error message. If it says something like "This language is no longer available..." then do the following: =20 In the main screen of Windows Mail, (no...

Auto Fill Macro Not Working Properly
Hi, I used a macro that I found through this newsgroup that auto fills down when you've got spaces in Column A that need filling with a prior value. It looks like this. Sub FillBlanksColumnA() Application.ScreenUpdating = False Extent = Cells.Rows.Count For i = 2 To Extent If Cells(i, 1) = "" Then Cells(i, 1) = Cells(i - 1, 1) Next i End Sub My problem is that this continues onto line 65000+. How can I revise this macro to stop when there is a blank or no value in Col B? Or can it be revised to say stop at line 2000? Thanks in advance. Jason Jason, If you want...

Search email won't work
Whenever I try to search my email for a word, I get a message that Outlook is indexing my items. However, the index is never created. It is trying to index 10,000 items. (I certainly do not have that many emails.) One solution to this problem that I rec'd on this forum is to eliminate all the email and start again. The problem is that I NEED the emails. Would archiving my emails make the search function work? I'm a little afraid to do that after reading that folks can't find their archived email. I always say "no" when it asks to archive. For inst...

Office Small Business 2007 Upgrade doesn't work
I purchased Office Small Business 2007 Upgrade version (on CD - purchased from Amazon.com), and have both Office Professional 2000 (CD) and Works 9.0 (OEM install on computer) installed on my computer, both of which are listed by Microsoft on the Office upgrade webpage as upgradeable products. Yet the installer says it can find no upgradeable products on my computer, and thus refuses to install Office SB 2007. I'm at a loss, and Microsoft demands a minimum $99 for email support, and/or $259 for telephone support, to help me install what is apparently a defective product -...

Private Activity Not Working ?
Hello ! I have an understanding with MSCRM concerning Activities. But this can be applied to all others objects, I assume. Searching for an attribute describing the Private/Public status for an Activity, I've only found a field in the ActivityBase table named 'isPrivate' (I think all objects have such a field in their corresponding tables). Searching to test the functionnality, I changed the values from 0 to 1 (it's of bit type) for an activity and tried to access it with different users with different Roles on the Web client. I was surprise that everybody can be able to r...

Actual Work Protected not Matching Actual Work
We have a project file where Actual Work Protected is ~1,000 hours greater than Actual Work. We've reviewed invididual tasks with this discrepancy, and Actual Work contains the correct hours and Actual Work Protected displays a bloated version of those hours on various tasks. For example, one task shows 164 hours in actual work protected and actual work only shows 1 hour. If you review these two fields in the Task Usage view, you can only see 1 hr posted. Reviewing the task owner's timesheet also shows the task owner has only posted 1 hour. We have seen this in a few o...

partial names note working
On my Win98 machine, I can type "zog" in the TO field and it figures out that I mean my friend "Mattzog Bell" and gets his email info. On my new XP machine with the same imported address book, it figures out who I mean if I type "Mattzog" but not "Zog". Somehow, it needs to know to look at parts of names. Is this just a switch somewhere? Also, it's putting a parenthesized "(email)" after everyone's name. Why? Can I get rid of that? Thanks! Your operating system has nothing to do with this. Your Outlook version does. You ne...

Does SHGetFileInfo work in Access 2003?
Hi, Does the SHGetFileInfo API call work in Access 2003? I have copied and tested various bits of code invoking this, but the hIcon and index parts of SHFILEINFO keep coming back as 0 which seems in turn to cause an "invalid picture". TIA Bob It should work fine. How are you calling it? -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no private e-mails, please) "Bob Landers" <bob@onenet.com.au> wrote in message news:c2ZUh.14722$M.10937@news-server.bigpond.net.au... > Hi, > > Does the SHGetFileInfo API call work in Access 2003? >...

working with 2 workbooks
Hi Guys, I am wanting to work with data from 2 seperate workbooks. Workbook One is a template with data stored to specific cells that want to access in workbook 2. Sort of like: ='[TPA v6.1 DEC03.xls]Consolidated'!$D$64 My problem is that 'TPA v6.1 DEC03.xls' is not always the name of th first workbook. TPA v6.1 DEC03.xls is the template but when saved by users they ca name this anything they want. My question is can the workbook (in this case TPA v6.1 DEC03.xls) be variable that the user enters. AND does the workbook have to be open or can the user be prompted to ent...

How can I work with more than 15 numbers
I have a little problem. I don't know how to work with numbers greater than 15 digits. If someone can help me, please don't hesitate. thanks! Enter them in cells preformatted as Text or with a leading apostrophe ('). If you're just entering credit card numbers, or suchlike, you generally don't need to do math, so this should suffice. XL's limited to 15 decimal digits of precision, so to work with numbers with more digits than that will require you to use string functions to manipulate parts of the numbers. In article <BD10C1C0-E717-4FD0-94CF-57CCEDC506B6@mi...

Citibank Not working
When I try and add account on MoneyCentral I get: Add Accounts Technical problems prevented us from adding your accounts at this time. Please try again later. This is going on for a week now. ...

Right click to save address doesn't always work
Why is it that sometimes I can right click on a sender's e-mail address to add it to my address book and sometimes I can't. I've selected the option to download headers for e-mail, but that doesn't seem to make any difference. Others in my office have complained about this also and the ability seems to appear or disappear when you re-install or for no reason at all. Is it the luck of the install or is there some sort of bug? We're all current on the Office updates, so we can't figure it out. Chris You didn't mention your Outlook version. If you open the email ...

trying to save a presentation (pps) It doesn't work
I've tried to save a presentation (pps) for automatic running, but I can't. Saving it as pps, it opens as ppt. Any suggestions? I'm using power point 2003 HOW are you opening? pps files only open in show mode if you open from windows explorer (ie double click) File > Open will always open in edit mode. If this is not the problem get back. -- john ATSIGN PPTAlchemy.co.uk Free PPT Hints, Tips and Tutorials http://www.pptalchemy.co.uk/powerpoint_hints_and_tips_tutorials.html "Paloma - Lanzarote" wrote: > I've tried to save a...