Context Menu Resource Allocation
I have a dynamically created context menu which varies in the number of elements depending on the data contained within a file. When I am creating the menu how can I define unique resource identifiers to facilitate the message handling required.
The appendmenu() function requires this identifier, simply inserting a value does not prevent resource identifier conflicts.
I need to allocate valid identifiers so that the returned value from the trackpopupmenu function handles the selection of these items.
Any suggestions?
sma
[563 byte] By [
sma] at [2007-11-18 18:28:55]

# 1 Re: Context Menu Resource Allocation
The resource ID's are just numbers and only need to be unique within your application. Just start your dynamic id's using a number greater than the highest number defined in your resource file and increase by 1 for each element.
RussG1 at 2007-11-11 1:21:06 >

# 2 Re: Context Menu Resource Allocation
Thanks for your reply, I just don't see how this method is good practice given that later updates to the app may introduce conflict problems.
sma
sma at 2007-11-11 1:22:06 >

# 3 Re: Context Menu Resource Allocation
That is a problem with dynamically created resources.
You can add a define to your resource.h file for the starting number that could be referenced/changed when doing future upgrades.
ie.
#define ID_DYNAMIC_MENUITEMS_START 4000
Then use use that ID in your code for your dynamc items:
ID_DYNAMIC_MENUITEMS_START
ID_DYNAMIC_MENUITEMS_START + 1
, etc
Look at the Microsoft MFCIE sample to see how it dynamically builds the favorites menu.
RussG1 at 2007-11-11 1:23:05 >

# 4 Re: Context Menu Resource Allocation
Thanks for your help, I look at the suggested example.
sma
sma at 2007-11-11 1:24:05 >
