Getting a Pointer to a Menu Item given its Item ID

What is the best way to get a pointer to a menu item given its Menu Item ID? 
I am hoping I will not have to write code to recurse by item position 
through all menu items to find the ID that matches.

I want to find it this way instead of by position because I do not want the 
code to break if a menu item is added above the sought for item. 


0
artist1 (13)
3/3/2007 4:50:20 AM
vc.mfc 33608 articles. 0 followers. Follow

7 Replies
524 Views

Similar Articles

[PageSpeed] 36

I would just get a CMenu pointer to the menu, check the number of items 
using GetMenuItemCount() and then get the ID for each item using 
GetMenuItemID() and find the one I'm looking for if I wanted to know the 
position.  It's not really a pointer although you can call GetMenuItemInfo() 
if you want to get more information about the state of the menu item and 
that does require a LPMENUITEMINFO (pointer).

Tom

"Artist" <artist@sj.speakeasy.net> wrote in message 
news:J5udnbXeMskQY3XYnZ2dnUVZ_uKknZ2d@speakeasy.net...
> What is the best way to get a pointer to a menu item given its Menu Item 
> ID? I am hoping I will not have to write code to recurse by item position 
> through all menu items to find the ID that matches.
>
> I want to find it this way instead of by position because I do not want 
> the code to break if a menu item is added above the sought for item.
> 

0
tom.nospam (3240)
3/3/2007 6:35:38 AM


"Artist" <artist@sj.speakeasy.net> wrote in message
news:J5udnbXeMskQY3XYnZ2dnUVZ_uKknZ2d@speakeasy.net...
> What is the best way to get a pointer to a menu item given its Menu Item
ID?
> I am hoping I will not have to write code to recurse by item position
> through all menu items to find the ID that matches.

That will not work. A menu Item with a particular ID can be in any number of
menus. There is nothing which binds the ID to a Menu. You will need to know
which menu it belongs to and deal with it.

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



0
ajaykalra (6842)
3/3/2007 2:10:06 PM
You don't get pointers to menu items.  The concept does not exist.  You may have an HMENU
handle to a menu, or you may have that HMENU wrapped by a CMenu object, and using that you
can access a menu item by ID or position, but you cannot "address" a menu item except by
its item ID or by its position relative to a menu.

Since we normally make sure that menu items in a menu tree all have unique IDs, it is
sufficient to work in terms of the HMENU/CMenu of the root menu.  What do you want to do
to the menu item?
					joe

On Fri, 2 Mar 2007 20:50:20 -0800, "Artist" <artist@sj.speakeasy.net> wrote:

>What is the best way to get a pointer to a menu item given its Menu Item ID? 
>I am hoping I will not have to write code to recurse by item position 
>through all menu items to find the ID that matches.
>
>I want to find it this way instead of by position because I do not want the 
>code to break if a menu item is added above the sought for item. 
>
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15974)
3/3/2007 11:48:14 PM
Hi Joe,

You can pass in a pointer to a GetMenuItemInfo() call and get information 
about a menu item.  Perhaps that's what OP was looking for...  I've looked 
for menu items before when I want to do something like add other items under 
it positionally, like for recent items or for open files, etc.

Tom

"Joseph M. Newcomer" <newcomer@flounder.com> wrote in message 
news:i42ku2hvk74iv0fvrhmu6lhapctfmgubu0@4ax.com...
> You don't get pointers to menu items.  The concept does not exist.  You 
> may have an HMENU
> handle to a menu, or you may have that HMENU wrapped by a CMenu object, 
> and using that you
> can access a menu item by ID or position, but you cannot "address" a menu 
> item except by
> its item ID or by its position relative to a menu.
>
> Since we normally make sure that menu items in a menu tree all have unique 
> IDs, it is
> sufficient to work in terms of the HMENU/CMenu of the root menu.  What do 
> you want to do
> to the menu item?
> joe

0
tom.nospam (3240)
3/4/2007 1:32:08 AM
But you don't pass a pointer to a menu item; you pass a pointer to a structure which is
filled in from the menu information, which is addressed by a pair <HMENU, id> or <HMENU,
pos>.  (Or using the method of CMenu where the HMENU comes from the CMenu).  So it isn't a
pointer to a menu item, it is a pointer to a structure that *represents* what is in the
menu item.  The nature of the question sounded more like someone who doesn't know how
menus are used or organized, and certainly doesn't understand that menu items cannot have
a "pointer".
					joe

On Sat, 3 Mar 2007 17:32:08 -0800, "Tom Serface" <tom.nospam@camaswood.com> wrote:

>Hi Joe,
>
>You can pass in a pointer to a GetMenuItemInfo() call and get information 
>about a menu item.  Perhaps that's what OP was looking for...  I've looked 
>for menu items before when I want to do something like add other items under 
>it positionally, like for recent items or for open files, etc.
>
>Tom
>
>"Joseph M. Newcomer" <newcomer@flounder.com> wrote in message 
>news:i42ku2hvk74iv0fvrhmu6lhapctfmgubu0@4ax.com...
>> You don't get pointers to menu items.  The concept does not exist.  You 
>> may have an HMENU
>> handle to a menu, or you may have that HMENU wrapped by a CMenu object, 
>> and using that you
>> can access a menu item by ID or position, but you cannot "address" a menu 
>> item except by
>> its item ID or by its position relative to a menu.
>>
>> Since we normally make sure that menu items in a menu tree all have unique 
>> IDs, it is
>> sufficient to work in terms of the HMENU/CMenu of the root menu.  What do 
>> you want to do
>> to the menu item?
>> joe
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15974)
3/4/2007 5:33:12 AM
Hi Joe,

Of course, but I was just trying to point out where OP could have been 
confused by the need for a pointer.

Tom

"Joseph M. Newcomer" <newcomer@flounder.com> wrote in message 
news:5amku2p3stso0rpnjv1p9ej90up8kbjdlq@4ax.com...
> But you don't pass a pointer to a menu item; you pass a pointer to a 
> structure which is
> filled in from the menu information, which is addressed by a pair <HMENU, 
> id> or <HMENU,
> pos>.  (Or using the method of CMenu where the HMENU comes from the 
> CMenu).  So it isn't a
> pointer to a menu item, it is a pointer to a structure that *represents* 
> what is in the
> menu item.  The nature of the question sounded more like someone who 
> doesn't know how
> menus are used or organized, and certainly doesn't understand that menu 
> items cannot have
> a "pointer".
> joe

0
tom.nospam (3240)
3/4/2007 2:52:07 PM
I find more and more that people are under the impression that everything is a pointer.
They talk about pointers-to-files or pointers-to-devices (they mean handles),
pointers-to-brushes (not CBrush * pointers, but HBRUSHes), pointers to menus (not CMenu*,
or HMENU, but what I think I saw here, which is a "pointer" to the actual menu item in the
menu), or want to know where the pointer to their screen buffer is, and generally cannot
distinguish what is going on.  I once had someone send me a question based on the fact
that he was dereferencing a handle and trying to use it as a pointer to a device object,
and was *very* upset at the access fault...after all, a handle is just a pointer, right?
(He had read just enough of the DDK to figure out that device objects represent devices,
but somehow thought that he could examine the device object contents simply by
dereferencing the handle!  And the *real* question was how to read a particular setting
for the device, because there was no API to do it!  I think there was, DeviceIoControl,
but he insisted that he wasn't "controlling" the device, only "querying" it...)

Another classic is "how do I directly write a pixel in the display buffer?" when the
actual question is "how do I fill a non-rectangular area?"

I'm not sure what the OP wanted to accomplish, but asking about a pointer to a menu is
probably already heading down the wrong path.   Again, a question stated in terms of an
erroneous understanding of the implementation, instead of a question asking about how to
accomplish a goal.  
				joe
On Sun, 4 Mar 2007 06:52:07 -0800, "Tom Serface" <tom.nospam@camaswood.com> wrote:

>Hi Joe,
>
>Of course, but I was just trying to point out where OP could have been 
>confused by the need for a pointer.
>
>Tom
>
>"Joseph M. Newcomer" <newcomer@flounder.com> wrote in message 
>news:5amku2p3stso0rpnjv1p9ej90up8kbjdlq@4ax.com...
>> But you don't pass a pointer to a menu item; you pass a pointer to a 
>> structure which is
>> filled in from the menu information, which is addressed by a pair <HMENU, 
>> id> or <HMENU,
>> pos>.  (Or using the method of CMenu where the HMENU comes from the 
>> CMenu).  So it isn't a
>> pointer to a menu item, it is a pointer to a structure that *represents* 
>> what is in the
>> menu item.  The nature of the question sounded more like someone who 
>> doesn't know how
>> menus are used or organized, and certainly doesn't understand that menu 
>> items cannot have
>> a "pointer".
>> joe
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15974)
3/4/2007 7:05:04 PM
Reply:

Similar Artilces:

Importing Item from RMS to GP
Hi All, I am trying to import an inventory item from RMS to GP using Transactions --> Retail Management --> Item Import. The problem is the item is importing properly to GP but the quantity is not updating in GP Inventory. How to import an item with quantity in GP? Please Help. Thanks, Prakash ...

adding a new item to existing matrix in rms 2.0
how come when you add an item to an existhing matrix non of the information is being forward from the main matrix (ex. supplier, price, cost, reorder #, barcode format, etc.) even the size, color, and 3rd dimention that you entered to the new item is not being fowarded. what is going on with 2.0 thank jack I think the Matrix is still is a little buggy.. Get all hotfixed up and see if the helps. There have been 3 for 2.0 hotfixes already. "jack" <jack@discussions.microsoft.com> wrote in message news:45CB84DE-B9B1-4DAC-9043-D8120CB44472@microsoft.com... > how come...

All Task bars gone How do I get them back?
All of a sudden the other day everything at the top of my screen disappeared. I can load my word documents by searching my files and double clicking on the name but I can not Open a document inside word. I have never seen anything like this where all the buttons for using Word are gone. How do I get them back. http://www.gmayor.com/my_toolbars_are_missing.htm or http://word.mvps.org/FAQs/AppErrors/MissingMenusEtc.htm -- <>>< ><<> ><<> <>>< ><<> <>>< <>><<> Graham Mayor - Word MVP ...

Event ID 125
I have received an Event ID 125 on an Exchange 5.5 server. Along with this I have an ID Error #193, 1005 7 and 100 amonst others. Is it possible that during a backup in schedule+ for a client on the client's machine, that the procedure corrupted the EDB.log or any other file? If so, should I be using Microsoft Base Article #275602 to repair. At this point, my Echange server is down. Thanks. Hello Deb Based on the limited information; the 275602 XADM: Microsoft Exchange Server Information Store May Stop After a http://support.microsoft.com/?id=275602 would be a recovery method. Did y...

item look up #3
a customer is having an issue. he scans an item in the pos screen and all details show up. but when he tries to look for it later he cant find it. hes tried it in manager too. he would usse name, or barcode, or anything and still nothing. do we know what the problem is? Thanks If the item is set as inactive (in the item properties) it will not show up in the Find screen, but will scan in at the POS. You can turn off the find option, but I think it is easier to use one of the SOM reports to find the item, such as the price report. The item will show up in any report that includes it as...

Getting the longest string
XML <data> <option>this is test 1</option> <option>this is test 11</option> <option>this is test 111</option> <option>this is test 1111</option> <option>this is test 11111</option> </data> The 5 option has the longest content. I need to get that length and place in a variable. The test has to look across all of the option nodes and return the longest one. Any suggestions? Cheers Keith Keith Chadwick wrote: > <data> > <option>this is test 1</option> > <opti...

Re: How to get all mails, even those for unknown recipient
Yes, good idea :) It is all i need (for example http://www.christensen-software.com/cscatchall.htm) But i wish those NDR are generated. To inform user that used address might be misstyped Is it posible to combine catchall mailbox with a ability of standard NDR generating? TIA Martin Blackstone - MVP wrote / napisal(a): > I think you are talking a Catch All mailbox. > Check this out > http://mostlyexchange.blogspot.com/2005/04/creating-catch-all-mailbox-in-exchange.html > > > "guzzi" <guzzi@_DOT_yandex.ru> wrote in message news:OoSFMGZhGHA.12...

Using Matrix Items
Someone...want to tell me how or if I can default which item is first (selected) when a matrix item is scanned? Is there a way to set this up? -- Thank You Vince :) What are the dimensions you use? Rob "Vince" <Nagarra@yahoo.com.(donotspam)> wrote in message news:E001F1F0-3002-4E1B-8E75-8E62FC6EC01C@microsoft.com... > Someone...want to tell me how or if I can default which item is first > (selected) when a matrix item is scanned? Is there a way to set this up? > -- > Thank You > Vince :) Using Lot Matrix, what I have is a six pack of coke or a sin...

SBS 2008 Fax Sent Items Not showing all faxes sent
Hello, I need to allow sent faxes to be seen by all users. I have Windows XP and Windows 7 64bit client machines. Currently they can only see their sent faxes. In SBS 2003 they were able to see all sent faxes. Any suggestions? Could you create an Outlook rule based on the fax sent acknowledgement that copied the fax to a public folder? "RodSoh" <RodSoh@discussions.microsoft.com> wrote in message news:A4541A0E-18C2-4A83-A13D-8E7D045C29E8@microsoft.com... > Hello, > > I need to allow sent faxes to be seen by all users. I have Windows XP...

I don't have 'as items arrive' option
I have the 5 minute synch option, which works great. But I do not have the 'as items arrive' option. Yes, I am running a MSFP version, I checked the build. Man I am so close to gettting this to work. Please help. Thanks, On Mon, 2 Apr 2007 12:42:00 -0700, MidMOman <MidMOman@discussions.microsoft.com> wrote: >I have the 5 minute synch option, which works great. >But I do not have the 'as items arrive' option. >Yes, I am running a MSFP version, I checked the build. >Man I am so close to gettting this to work. > >Please help. Thanks, You are either mist...

entering multiple costs for an item
I am very new to Retail Management, and am trying to enter inventory, and create a purchase order. I can't figure out how to enter various costs for the same item from the same supplier. For example, when we purchase in lots of 50 pcs., the item cost is .50 per item (total cost of 25.00). However, if we purchase in lots of 100 pcs, the item cost is .47 per item (total cost of 47.00). We can also purchase the item in boxes of 10 (5.50 per box for a cost of .55 per item). How can I enter these costs so when I place a purchase order, the cost will be correct according to the quant...

What is the best procedure for Getting a valid COA/License for a XP SP1 system.
I need to find out the best procedure for Getting a valid COA/License for a XP SP1 system. I've checked E-Bay but maybe dealing directly with M/S would be best Bob Robert J. Stevens wrote: > I need to find out the best procedure for Getting a valid > COA/License for a XP SP1 system. > I've checked E-Bay but maybe dealing directly with M/S would be best Not sure you can, anymore - for Windows XP. Assuming you are doing this because it is counterfeit/bad... http://www.microsoft.com/genuine/ -- Shenan Stanley MS-MVP -- How To Ask Questions The Smart ...

Get paid to surf
Surfjunky pays up to .75$ per hour you surf, no limit to how long you surf. I've had an account for 2 days now, and i've let it sit and i've raked in 27$ http://www.surfjunky.com/?r=Etra1n ...

I have a problem with getting a total Sum of numbers (URGENT)
I'd really appreciate if someone could help me here. I am using Microsoft Excel 2002 on a Microsoft Office XP system. I a trying to develop a minor league baseball schedule, but am having som problems. I have attached a copy of my spreadsheet to give everyone some idea o what I'm doing here. I have where the fans list the "RUNS, HITS & ERRORS) of both teams an for each game of the series. I then have it set up in the TOTA WON/LOST column where if the T-Bones RUNS are more than the SALTDOG runs, a "1" appears in the WON column. If the SALTDOGS have a highe numbe...

How to get device name?
Hello all: I want to know all the name of devices in my PC, because I want to open them using API CreateFile and test it, how to do?thanks. Hi, what you want do by meanin "test it"? You cant open all devices with the API CreateFile (for several reasons). Regards Kerem -- ----------------------- Beste Gr�sse / Best regards / Votre bien devoue Kerem G�mr�kc� Latest Open-Source Projects: http://entwicklung.junetz.de ----------------------- "Lee Tow" <fbjlt@pub3.fz.fj.cn> schrieb im Newsbeitrag news:#vVH#JkqKHA.4220@TK2MSFTNGP0...

Context menu does not appear
Hey everyone. Hopefully someone out there can help with this. I a running OL2K, when I right click on a message, the context menu doe not appear. However, if you right click on a folder in the folder vie you get the menu. Right click functions work fine outside of Outlook. Any feedback is appreciated. Thank ----------------------------------------------- ~~ Message posted from http://www.ExcelTip.com ~~View and post usenet messages directly from http://www.ExcelForum.com ...

Excel 2007. How do I get un-installed add-ins off the toolbar?
I have 2 Large Icons on the ribbon/toolbar of Excel 2007. These are Omnipage and s-force. Both of these have been uninstalled and I have de-activated both add-ins. How do I get these off the toolbar forever? thanks ...

Getting back a deleted test frame after saving the changes
My son just deleted a text frame with all his work and started a new text frame and then when asked if he wanted to save his work he clicked yes. Is there any way to retrieve that missing text frame when it won't allow you to undo? On Sat, 27 Aug 2005 16:04:01 +0100, Denise wrote (in article <09056FDE-03FC-4988-8AB0-D1EA0896BFC7@microsoft.com>): > My son just deleted a text frame with all his work and started a new text > frame and then when asked if he wanted to save his work he clicked yes. Is > there any way to retrieve that missing text frame when it won't a...

Auditing Mailbox item access
Don't ask me why I am asking, you don't want to know....but Is it possible to monitor and log access not only to a mailbox, but actually to individual items within the mailbox and be able to trace it back to the specific item and user who accessed it? I am aware of the ability to log when a non-primary account logs into a mailbox, but that is not granular enough for the scenario I need to look into. The powers that be want to be able to see not only who accessed a particular mailbox, but actually who accessed a particular message within that mailbox. Just wanted to know if...

How do I get a copy of Publisher 2002?
I'd like to get a copy of Publisher 2002. I still have Windows 98 on my computer and don't want to upgrade to XP right at this time. Other than ordering off of e-bay or other sites I'm not familiar with, is it possible to get a copy of Publisher 2002 that would be compatible with Windows 98? Amazon.com -- Don Vancouver, USA "Crystal1365" <Crystal1365@discussions.microsoft.com> wrote in message news:33518C70-6D02-4E03-B9C2-2C1FDEEB4A68@microsoft.com... > I'd like to get a copy of Publisher 2002. I still have Windows 98 on my > computer and don...

Can't get at downloaded transactions
While Money was going through it's online update I also was in the process of requesting a download of transactions from a bank which uses web statements rather than direct statements. Somehow things must have gotten out of sync so that now Money is showing I have 19 transactions from this institution to review (which is correct) but it doesn't present me with anything to review when I'm in that account. I've tried re-downloading from the bank but that doesn't help. Any ideas how I can access the downloaded transactions? In microsoft.public.money, Ken wrote: &...

How do i get send/receive back
-- Peter Please reply to Newsgroup for the benefit of others. "Andrea" <Andrea@discussions.microsoft.com> wrote in message news:DA7F81D0-A97A-4265-8676-82A0CDC143FA@microsoft.com... > ...

Add items to SupplierList
I just imported a new catalog of items to our database using EMS import, were newly insterted and some were updated. The problem I'm having is getting the supplier cost to update for the items that were in already and adding the new items to the supplierlist table. I imported the SupplierID to the Item table just can't figure out the query to go the other way updating and adding new. Any help would be great. You need to use T-SQL in the management studio. Use an InnerJoin of the supplier id to the item id and set the cost to = supplier cost if it is the most recent. "Do...

getting consolidate list of "follow up" items
Dear All, I would like to get a consolidated list of items (sent and received mails)that have matured - i.e. whose follow up time is up. I have the habit of tagging a sent mail (after actually sending) for follow up. Similarly, mails received are also tagged for my further action (for follow up). Would appreciate a consolidated follow up report generation way - rather that opening each folder and looking for mature items (i.e. red). Thanks in advance. Sanjay ...

Event ID ( 5898 & 5892 ) in Source ( CrmExchangeQueueService )
Our CRM decided this morning to stop forwarding emails to the CRM system. The emails still get into the Exchange and OWA. I have checked the url in the `mailserverurl` registry key, and that seems fine. I've uninstalled/reinstalled CRM Connector also. I hadn't applied any patches since a few days after the last MS patch day. I noticed that when trying to access "/MSCRMServices/CrmEmail.srf" that the IIS logs show an error 500 or 401. Full Text of Event log messages: The description for Event ID ( 5898 ) in Source ( CrmExchangeQueueService ) cannot be found. The local c...