Click here to Skip to main content
15,891,607 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
I am running the following to create a dialog box in windows. when I run it I get the follwoing error:
Error 1 error C2065: 'IDD_DLGFIRST' : undeclared identifier



Here is the code:


HWND hWnd;
               LRESULT CALLBACK DlgProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);

          INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
              LPSTR lpCmdLine, int nCmdShow)
    {
                 DialogBox(hInstance, MAKEINTRESOURCE(IDD_DLGFIRST),
                 hWnd, reinterpret_cast<DLGPROC>(DlgProc));

              return FALSE;
              }

      LRESULT CALLBACK DlgProc(HWND hWndDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
            {
          switch(Msg)
            {
              case WM_INITDIALOG:
                             return TRUE;

                case WM_COMMAND:
              switch(wParam)
            {
              case IDOK:
                      EndDialog(hWndDlg, 0);
                   return TRUE;
            }
               break;
             }

              return FALSE;
           }


I do know that there are resource files but I haven't understood that very well. could someone help me out to resolve this error please.
Posted
Comments
P Uday kishore 9-May-13 3:16am    
check in properties of that dialog whether u have given ID properly or not.
Aayman Khalid 9-May-13 3:37am    
could you tell me please how do I do that?
P Uday kishore 9-May-13 3:48am    
r8 click on the dialog and select properties.

You should have declared a dialog in your resource file with the id IDD_DLGFIRST, and you should also have a definition for IDD_DLGFIRST in your resource.h header. Something like:
C++
// project.rc resource file
IDD_DLGFIRST	DIALOGEX	200, 100, 266, 240
STYLE		WS_POPUP | WS_CAPTION | WS_SYSMENU | DS_MODALFRAME | DS_CENTER
CAPTION		"Dialog Test"
FONT		10, "Verdana"
BEGIN
	LTEXT			"This is the dialog", IDC_STATIC, 80, 14, 100, 8
END

// resource.h header file
#define IDD_DLGFIRST	132

If you are using the Visual Studio dialog and class wizards then these values should be generated automatically for you.
 
Share this answer
 
Comments
CPallini 9-May-13 3:47am    
5.
Aayman Khalid 9-May-13 5:01am    
I need a little more of your help,I've performed the steps that you mentioned but I get this: error RC2104 : undefined keyword or key name: WS_POPUP
could you please help me with it?
Richard MacCutchan 9-May-13 7:08am    
Have you included windows.h in your .rc script file?
Aayman Khalid 9-May-13 7:39am    
yes.
Richard MacCutchan 9-May-13 7:47am    
That should include all other necessary headers so WS_POPUP gets defined. Perhaps you can edit your question and add in your dialog definition.
These type of symbols are typically defined in a file called resource.h. You can rename the file or use another file but if you haven't done that, it is the place to look first. The resource.h file and app.rc file are maintained by the IDE and can sometimes get out of sync. If this has happened, exit the IDE and edit the resource.h file (eg. notepad or restart the IDE), adding the missing symbol, using a new unique value. Until you understand all the details of resource.h, I suggest a unique value between 1 and 99.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900