Error: Did not find a dialog class with the specified ID

Dudu 161 Reputation points
2021-03-17T09:01:46.363+00:00

I add dialog class for dialog resource by right click resource and select Add Class in designer.

In header file and cpp file of the dialog class, I add:

namespace N01 {
namespace N02 {
}
}

around codes in those files

When I add a edit box control on dialog resource in design view and right click on the control then select Add Variable, I get error of: Did not find a dialog class with the specified ID

Thanks.

C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,832 questions
0 comments No comments
{count} votes

Accepted answer
  1. Viorel 119.2K Reputation points
    2021-03-17T19:53:47.59+00:00

    It is probably possible to find some workarounds; for example, you can replace the namespace declarations with a macro (inside the .h file only):

    #define NS(n) namespace n {
    
    
    NS(N01) NS(N02)
    
       // Dialog class
       Class MyDialog
       {
          . . .
       }
    } }
    

    Then “Add Variable…” should work. However, MFC was not designed for such scenarios and some of special features, introduced by existing DECLARE_DYNAMIC macros, probably will not always work.

    0 comments No comments

0 additional answers

Sort by: Most helpful

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.