resource parse error

This is a discussion on resource parse error within the Windows Programming forums, part of the Platform Specific Boards category; One more try. When I attempt to compile the following code I receive a [Resource error] parse error message. The ...

  1. #1
    Registered User
    Join Date
    May 2003
    Posts
    7

    resource parse error

    One more try.

    When I attempt to compile the following code I receive a [Resource error] parse error message. The error is reported in the resource.rc file in the line beginning with "STYLE DS_MODALFRAME|DS_3DLOOK...." Does anyone have any ideas as to why?

    main.cpp
    Code:
    #include <windows.h>
    
    #include "resource.h" 
    
    static char g_szClassName[] = "MyWindowClass";
    static HINSTANCE g_hInst = NULL;
    
    BOOL CALLBACK AboutDlgProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
    {
       switch(Message)
       {
          case WM_INITDIALOG:
    
          return TRUE;
          case WM_COMMAND:
             switch(LOWORD(wParam))
             {
                case IDOK:
                   EndDialog(hwnd, IDOK);
                return TRUE;
                case IDCANCEL:
                   EndDialog(hwnd, IDCANCEL);
                return TRUE;
             }
          break;
       }
       return FALSE;
    }
    
    LRESULT CALLBACK WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
    {
       int ret;
       
       switch(Message)
       {
          case WM_COMMAND:
             switch(LOWORD(wParam))
             {
                case CM_FILE_EXIT:
                   PostMessage(hwnd, WM_CLOSE, 0, 0);
                break;
                case CM_HELP_ABOUT:
                   ret = DialogBox(g_hInst, "ABOUTDLG", hwnd, AboutDlgProc);
                   if(ret == IDOK){
                      MessageBox(hwnd, "Dialog exited with IDOK.", "Notice",
                         MB_OK | MB_ICONINFORMATION);
                   }
                   else if(ret == IDCANCEL){
                      MessageBox(hwnd, "Dialog exited with IDCANCEL.", "Notice",
                         MB_OK | MB_ICONINFORMATION);
                   }
                   else if(ret == -1){
                      MessageBox(hwnd, "Dialog failed!", "Error",
                         MB_OK | MB_ICONINFORMATION);
                   }
                break;
             }
          break;
          case WM_CLOSE:
             DestroyWindow(hwnd);
          break;
          case WM_DESTROY:
             PostQuitMessage(0);
          break;
          default:
             return DefWindowProc(hwnd, Message, wParam, lParam);
       }
       return 0;
    }
    
    
    int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
       LPSTR lpCmdLine, int nCmdShow)
    {
       WNDCLASSEX WndClass;
       HWND hwnd;
       MSG Msg;
    
       g_hInst = hInstance;
    
       WndClass.cbSize        = sizeof(WNDCLASSEX);
       WndClass.style         = 0;
       WndClass.lpfnWndProc   = WndProc;
       WndClass.cbClsExtra    = 0;
       WndClass.cbWndExtra    = 0;
       WndClass.hInstance     = g_hInst;
       WndClass.hIcon         = LoadIcon(NULL, IDI_APPLICATION);
       WndClass.hCursor       = LoadCursor(NULL, IDC_ARROW);
       WndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
       WndClass.lpszMenuName  = "MYMENU";
       WndClass.lpszClassName = g_szClassName;
       WndClass.hIconSm       = LoadIcon(NULL, IDI_APPLICATION);
    
       if(!RegisterClassEx(&WndClass))
       {
          MessageBox(0, "Window Registration Failed!", "Error!",
             MB_ICONEXCLAMATION | MB_OK | MB_SYSTEMMODAL);
          return 0;
       }
    
       hwnd = CreateWindowEx(
          WS_EX_CLIENTEDGE,
          g_szClassName,
          "The title of my window",
          WS_OVERLAPPEDWINDOW,
          CW_USEDEFAULT, CW_USEDEFAULT, 320, 240,
          NULL, NULL, g_hInst, NULL);
    
       if(hwnd == NULL)
       {
          MessageBox(0, "Window Creation Failed!", "Error!",
             MB_ICONEXCLAMATION | MB_OK | MB_SYSTEMMODAL);
          return 0;
       }
    
       ShowWindow(hwnd, nCmdShow);
       UpdateWindow(hwnd);
    
       while(GetMessage(&Msg, NULL, 0, 0))
       {
          TranslateMessage(&Msg);
          DispatchMessage(&Msg);
       }
       return Msg.wParam;
    }

    resource.h
    Code:
    #define CM_FILE_EXIT 9001
    #define CM_HELP_ABOUT 9002

    resource.rc
    Code:
    #include "resource.h" 
    
    MYMENU MENU
    {
       POPUP "&File"
       {
          MENUITEM "E&xit", CM_FILE_EXIT
       }
       POPUP "&Help", HELP
       {
          MENUITEM "&About", CM_HELP_ABOUT
       }
    }
    ABOUTDLG DIALOG 0, 0, 155, 102
    STYLE DS_MODALFRAME | DS_3DLOOK | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
    CAPTION "This is my About Box"
    FONT 8, "MS Sans Serif"
    {
       CONTROL "&OK", IDOK, "BUTTON", BS_DEFPUSHBUTTON | BS_CENTER | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 6, 83, 50, 14
       CONTROL "&Cancel", IDCANCEL, "BUTTON", BS_PUSHBUTTON | BS_CENTER | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 95, 83, 50, 14
       CONTROL "About This Program", -1, "button", BS_GROUPBOX | WS_CHILD | WS_VISIBLE | WS_GROUP, 5, 5, 144, 73
       CONTROL "An example program showing how to use dialog boxes.\r\n\r\nby theForger", -1, "static", SS_CENTER | WS_CHILD | WS_VISIBLE, 27, 27, 100, 50
    }

  2. #2
    Cat
    Cat is offline
    Registered User
    Join Date
    May 2003
    Posts
    1,571
    Well, what is the exact error message you get, word for word?

  3. #3
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    My guess is that the dialog should be a DIALOGEX, but that's only a guess...
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  4. #4
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    Well, what is the exact error message you get, word for word?
    Add to that the name/version of your compiler.

    But 'parse error' suggests you are using mingw. If so you must #include <windows.h> in your resource script (rc file) to successfully compile resources (I think theForger's winprog tutorials are aimed at msvc and bcc5.5 cmd line tools).

    You might also want to consider removing the 'DS_3DLOOK' style because
    The DS_3DLOOK style is required only by Win32-based applications compiled for system versions earlier than Windows 95 or Windows NT 4.0. The system automatically applies the three-dimensional look to dialog boxes created by applications compiled for current versions of the system. ~ msdn DLGTEMPLATEEX resource definition statement
    And if that's wrong - well that was my guess, too.

  5. #5
    Registered User
    Join Date
    May 2003
    Posts
    7
    Thanks for the responses guys,

    Word for word
    line 1
    "[Resource Error] parse error"
    line 2
    "[Build Error] [dialog_private.res] Error1"

    I've tried DIALOGEX and removing DS_3DLOOK.

    The compiler is DevC++ 4.9.7.0.

    Once again, all suggestions are greatly appreciated,

  6. #6
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    Originally posted by cj56
    The compiler is DevC++ 4.9.7.0.
    That's the ide; the compiler is mingw. [/pedantic]

    So:
    But 'parse error' suggests you are using mingw. If so you must #include <windows.h> in your resource script (rc file) to successfully compile resources
    Did you try this?

  7. #7
    Registered User
    Join Date
    May 2003
    Posts
    7

    Thanks

    Thank you Ken Fitlike,
    Including windows.h in the rc file does indeed resolve this issue! Your help is greatly appreciated. These matters are very difficult for beginners. Thank goodness there are seasoned programmers such as yourself willing and able to help us!!! ...cj56

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 02:07 AM
  2. Getting other processes class names
    By Hawkin in forum Windows Programming
    Replies: 3
    Last Post: 03-20-2008, 04:02 PM
  3. Connecting to a mysql server and querying problem
    By Diod in forum C++ Programming
    Replies: 8
    Last Post: 02-13-2006, 09:33 AM
  4. Post...
    By maxorator in forum C++ Programming
    Replies: 12
    Last Post: 10-11-2005, 08:39 AM
  5. pointer to array of objects of struct
    By undisputed007 in forum C++ Programming
    Replies: 12
    Last Post: 03-02-2004, 03:49 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21