MFC resource.h command/message IDs

I'm working on an MFC application, that got pretty messy over years and over different teams of developers. The resource.h file, which contains all command/message mappings grew pretty big over time, and has lots of problems (like duplicate IDs). I am not proficient with MFC, so the question might sound pretty stupid...

MSDN docs mention that Command IDs and Message IDs should not be less than WM_USER and WM_APP correspondingly. I saw that most of the command IDs in resource.h generated by Visual Studio begin around 100. Shouldn't this cause some interfering with MFC/Windows commands and messages, that overlap with the application defined IDs? For example, I have a command ID :

#define ID_MY_ID 101

and there is a windows command that has the same ID. When MC send this command to the APP, it's handled like an application defined ID_MY_ID, and the app is taking unnecessary actions. Is it a possible scenario?

Also, is there some third party tool that helps to profile the project resources?

Update 1:

New question showed up: What is the preferred way of adding new custom commands to the application classes? As I understood, before they were added in the following way: add a command ID to the resouce.h, and then add a message map handler to the handling class.

-------------Problems Reply------------

You are mixing two things:

  1. Message IDs. These must be larger than WM_USER. Message IDs are not defined in resource.h. It seems from your description that you are not using application private messages.
  2. Command IDs. Your application itself must not have duplicate command IDs. The command ID values should also not interfere with the standard MFC IDs defined in afxres.h. Theses command IDs start at 0xE100, so it is unlikely that the values in resource.h. The resource compiler will generate an error for duplicate IDs in you rc file

There is probably no need for you to edit resource.h manually.

I would recommend to use the "Resource symbols" tool (right click on the resources in resource view and choose from the popup menu, I assume you are using VC++), to remove all the unused IDs from resource.h.

command messages are sent in WM_COMMAND with command id in parameter so it won't conflict other messages.

Generally, there is no need to insert or edit the identifiers in resources manually (identifiers assingned by VS automatically in a correct manner). There are some cases that require manual interference in identifiers, but you can start with assumption, that work of previous teams of developers with resources was right. So if you did not encountered a problem because of resources, keep them untouched (IMHO).

"MSDN docs mention that Command IDs and Message IDs should not be less than WM_USER and WM_APP correspondingly." - It seems you something mixed up.

Category:mfc Views:0 Time:2010-04-03

Related post

  • Cannot load resource DLL error message 2012-12-21

    Every time I start my computer I get a "cannot load resource DLL" error message. I close it out and my computer seems to work fine. Just wondering what the error message is about and is it actually affecting my computer's operation. Any help would be

  • Efficiently get unretrieved message Ids from a POP3 server 2009-07-01

    I understand most of the POP3 protocol, but one thing that bothers me is how POP3 clients efficiently get a list of unretrieved message ids from the POP3 server. Many services like Yahoo and Gmail now offer gigs of space and most people (myself inclu

  • How to map EditModel to Command Messages? 2009-12-14

    Jimmy Bogard at Los Techies says that he maps his EditModel to Command Messages instead of mapping EditModel to DomainModel. Can anyone explain this further? --------------Solutions------------- I'd guess it'd be a version of the command pattern that

  • const ints as Message IDs = Recompile Everything 2011-08-04

    I'm hoping for confirmation of what I just told someone. We have a large software project that is divided out into several libraries (.so). The message definitions are all in one library with a set of .h files for the declarations. The message ids ar

  • Command and Conquer Generals - Missing Messages IDS Auto run 2012-04-05

    I have Command and Conquer Generals, it used to run fine on my Windows 7. But not when the tries to start, an error message comes up"IDS_AUTORUN_TITLE and IDS_CANT_FIND I have tried a friends disk and that comes up with the same message. I have unins

  • How do I bypass GUI in MFC app if command line options exist? 2010-06-17

    I've got an existing simple MFC app that the user specifies the input file, output file, and then a "Process" button. I'd like to just add the capability so that the input/output files are command line parameters. But, if they exist, I don't want the

  • "Resource not available" message for an applicarion created with spring roo 2012-04-10

    Hi i'm an absolute beginner in spring roo.I followed a tutorial on web and created a sample roo application. When i run the application using tomcat it always gives the message "The requested resource (/phonebook) is not available." i have mentioned

  • Best practices for MATLAB message IDs? 2010-06-24

    When creation a MATLAB exception (MException object) or printing a warning or error message, MATLAB lets you supply a message ID that defines the except you're throwing. The message ID is in the format: component:mnemonic For example, MATLAB's own un

  • Trouble with multiple resources on creating message board 2011-05-01

    I'm working on a message board for my application and it has the typical three resources to make it all work: Forums, Topics and Posts. The routes are defined as so: resources :forums do resources :topics do resources :posts end end Topics have posts

  • MFC aero shake window message 2011-08-07

    I am working on a program built in MFC. I have this weird situation when I shake my CFormView. The first time everything is minimised correctly, but when I shake it the second time while all of the windows are restored, one of my CDialog's inside the

  • "Error executing the insertHtml command" message in cleditor when inserting html in "View Source" mode 2012-02-10

    I've searched for the solution for this everywhere and have not found an answer, so you're my last hope, Stackoverflow... With regard to cleditor, does anybody know how to make the "inserthtml" command in "View Source" mode work? Currently, I have a

  • what is the "WSST_ENGINE MFC has stopped working" message 2013-01-25

    My screen goes dark and a dialogue box comes up with this message. --------------Solutions------------- Hello G.P.HHiker, Take a look at this thread

  • SQL command message when opening Word 2012-05-23

    Everytime I open Word I get a screen that says this: "This message can appear if your document contains code for accessing information from a database - for example, if your document is a form letter that retrieves an address from a mailing list. If

  • T-Mobile Wing Voice Command/Messaging issue and WMP issue 2012-09-10

    On the T-Mobile Wing WM6, I was unable to OPEN messaging at all to view/send email or text mail-no error message. At the same time, I began randomly getting the error "Voice command has encountered a problem. Restart voice cammand and start again". I

  • Getting "insufficient resources exist" error message when trying to launch an application. 2013-02-16

    Dell Inspiron Laptop running XP Home SP3, all updates current. The computer is on a secured wireless SOHO network. Typically, the computer is left on and running all the time except when it is taken on a trip. Browsers used are IE8 and Firefox; brows

  • Can't Save Resource Pool: Error Message - Cannot Open the File 2013-09-22

    I am working with MS Project 2013 and I have a resource pool linking sub-projects. Although I can open and work in the file, I cannot save any changes to the file. I get the following error message: Project cannot open the file Check that the file na

  • ZeroConfg Svc MFC, Cc Svc Hst, messages stopped working, then next day zune quit working all after a automatic update 2014-06-24

    Can anyone tell me what ZeroConfg Svc MFC application has encounter a problem and needs to close means when I turn on my computer it always comes up? Also when I restart or shutdown my computer Cc Svc Hst has stopped comes up but so fast I cant get w

  • "Cannot Find Command" Message When Opening a Document 2014-10-03

    Hi All, Issue: I have Office 2007 Installed on a Windows 7 Ultimate PC. When I start up the computer and logon and I try to open a word document for the first time in that logon session; an error message pops up as Word opens up. It says something li

  • MFC ctrls and duplicate messages 2011-03-13

    I have two CListCtrl objects in my form. I want selected list in both of them be same. How I can do it. I want duplicate the message that sent to a ClistCtrl and send to other one. How I can do it? if this is a good way? thanks herzl --------------So

Copyright (C), All Rights Reserved.

processed in 0.108 (s). 11 q(s)