Faulty #define in Resource.h

Bryan Kelly 516 Reputation points
2025-07-29T21:55:33.57+00:00

Visual Studio 2022, Version 17.13.3, Windows 11, C++, MFC

This problem has been present for, maybe, since the project was first started.  I am rather new with user interfaces and Visual Studio.

This project has, so far, 3 dialog classes with several buttons in each.  In dialog C_Do_Arithmetic, a new button was added to test a function.  After adding the handler, put a breakpoint in the handler, clicked the button, and the breakpoint is not hit.  Making this short, part of Resource.h looks like this:

#define IDC_BTN_CLEAR_TEMP              1023
#define IDC_TEST_ADD                    1024
#define IDC_BTN_CLEAR_CARRY             1024  // duplicate
#define IDC_BUTTON1                     1025
#define IDC_BTN_CLEAR_A                 1025 // duplicate
#define IDC_BTN_TEST_MULTIPLY           1025  // duplicate
#define IDC_BTN_TEST_SUBTRACT           1026
#define IDC_BTN_CLEAR_RESULT            1026  // duplicate
#define IDC_BTN_CLEAR_ALL               1027

VS has a habit of duplicating these numbers. It does not put the new number at the end. In this case every item except IDC_BTN_TEST_MULTIPLY was present, then the one just mentioned was put in the place shown above. Why not the end?

Manually edit them and make them increment by one with no missed or duplicate numbers. No other changes.  It works, breakpoint caught.

This has happened repeatedly.  Have I done something wrong?  Might this be a known problem?  Or maybe something else?

Developer technologies | Visual Studio | Other
{count} votes

1 answer

Sort by: Most helpful
  1. Bryan Kelly 516 Reputation points
    2025-07-31T19:03:53.94+00:00

    Tested (see previous post in comments section) and there appears to be a problem. Added one button. Here is the bottom section of the #define list.

    #define IDC_BTN_CLEAR_CARRY 1027

    #define IDC_BUTTON1 1028

    #define IDC_BTN_TEST 1028 // New item added here

    #define IDC_BTN_CLEAR_A 1029

    #define IDC_BTN_TEST_MULTIPLY 1030

    #define IDC_BTN_TEST_SUBTRACT 1031

    #define IDC_BTN_CLEAR_RESULT 1032

    #define IDC_BTN_CLEAR_ALL 1033

    The new button is IDC_BTN_TEST

    the mentioned item is

    #define _APS_NEXT_CONTROL_VALUE 1034

    So Visual Studio inserted the new item at location 1028 but should have added a new 1034 item.

    From what I see, I will check Resource.h after adding each new control and make the appropriate edits.

    This appears to be a problem in Visual Studio.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.