Menu

DIALOG ressource compile problem

2009-04-16
2012-09-26
  • Gérard CARRY

    Gérard CARRY - 2009-04-16

    Avec Dev C++ 4.9.9.2 (désinstallé et ré-installé ce matin 16 Avril 2009) je récupère un message d'erreur de compilation en compilant le source ci-dessous et voici le journal de compilation:

    La ligne du .rc incriminée est : STYLE WS_POPUP | DS_MODALFRAME | WS_CAPTION | WS_SYSMENU

    log

    Compilateur: Default compiler
    Building Makefile: "D:\Bibi\Cc\MinProg\Makefile.win"
    Exécution de make...
    make.exe -f "D:\Bibi\Cc\MinProg\Makefile.win" all
    windres.exe -i Scra_private.rc --input-format=rc -o Scra_private.res -O coff

    windres.exe: minprg.rc:40: syntax error

    make.exe: *** [Scra_private.res] Error 1

    Exécution terminée

    Source: scra.cpp, minprg.rc, minprg.h

    scra.cpp

    /--------------------------------------------------------------------------------/
    / 'C' Programming Under WIN32 G.Carry (2009)/
    / /
    / WEB : http://pagesperso-orange.fr/vb-audio/fr/pub/programming/index.htm /
    /--------------------------------------------------------------------------------/

    ifndef __cplusplus

    #ifndef STRICT
    #define STRICT
    #endif

    endif

    include <windows.h>

    include <stdio.h>

    include "minprg.h"

    / Declare Windows procedure /
    LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
    //LRESULT CALLBACK ODSNumberManageEvent(HWND, UINT,WPARAM,LPARAM);
    BOOL APIENTRY DialogODSProc(HWND, UINT, WPARAM, LPARAM);

    / Make the class name into a global variable /
    char szClassName[ ] = "WindowsApp";
    char szWindowClassName[]="MainWindowClass";
    //char szODSNumberClassName[]="ODSWindowClass";
    //
    //define globals
    //
    static HWND hwndmain = NULL;
    //static HWND hwndods = NULL;
    static HWND hwndliste = NULL;
    //static HWND hwndbutton01 = NULL;
    //static HWND hwndbutton02 = NULL;
    //static HWND hwndbutton04 = NULL;
    //static HWND hwndbutton05 = NULL;
    //static HWND hwndbutton06 = NULL;
    static HINSTANCE G_hinstance = NULL;

    static int odscourant = CST_ODSDEFAULT;

    /***********/
    /
    MESSAGE MANAGEMENT FUNCTIONS /
    /***********
    /
    void ManageCloseMessage(HWND hw)
    {
    int rep;
    char titre[]="Close Application...";
    char message[512];

    PostMessage(hw,WM_DESTROY,0,0L); //DestroyWindow(G_hwnd_MainWindow);
    } //void ManageCloseMessage(HWND hw)
    void ManageAboutBox(HWND hw)
    {
    char titre[]="About...";
    char message[512];
    strcpy(message,SZPUBLICNAME);
    strcat(message,"\nVersion : ");
    strcat(message,SZPUBLICVERSION);
    strcat(message,"\n");
    strcat(message,SZCOMMENTS);

    MessageBox(hw,message,titre,MB_APPLMODAL | MB_OK | MB_ICONINFORMATION);
    } //void ManageAboutBox(HWND hw)
    void ManageDefinition(HWND hw, WPARAM p,LPARAM w)
    {
    int i, flagexit, flagparametre, flagindex;
    char entree[80];
    } //void ManageDéfinition(HWND hw, WPARAM p,LPARAM w)
    /*************/

    void ManageMenu(HWND hw, WPARAM p,LPARAM w)
    {
    char sss[256];
    HDC dc;
    PAINTSTRUCT ps;

    switch(LOWORD(p))
    {
    case IDT_NUMERODODS:
    DialogBox(G_hinstance, "DIALOGODS" , hwndmain, (DLGPROC)DialogODSProc);
    break;
    case IDM_QUIT:
    ManageCloseMessage(hw);
    break;
    case IDM_CARTOGRAPHIE:
    ManageAboutBox(hw);
    break;
    case IDM_DEFINITION:
    ManageDefinition(hw, p, w);
    break;
    }
    } //void ManageMenu(HWND hw, WPARAM p,LPARAM w)
    /***********/
    BOOL InitSoftware(HWND hw)
    {
    return TRUE;
    }
    BOOL EndSoftware(HWND hw)
    {
    return TRUE;
    }
    /***********
    /
    / CALLBACK Functions /
    /*************/
    LRESULT CALLBACK MainWindowManageEvent(HWND hw, //handle of the window.
    UINT msg, //Message Ident.
    WPARAM p1, //parameter 1.
    LPARAM p2) //parameter 2

    {
    char sss[256];
    HDC dc;
    PAINTSTRUCT ps;
    switch (msg)
    {
    case WM_CREATE:
    //return -1 here cancel the window creation
    if (InitSoftware(hw) == FALSE) return -1;
    break;
    case WM_COMMAND:
    ManageMenu(hw,p1,p2);
    break;

      case WM_PAINT:
    
         if ( (HWND)p2 == hwndliste &amp;&amp; (INT)hwndliste != 0)
         {
            dc=BeginPaint(hwndliste,&amp;ps);
            strcpy (sss, &quot;Entrer le mot cherché: &quot;);
            SetBkMode(dc, TRANSPARENT);
            TextOut(dc, 10, 10, sss , lstrlen(sss));
            EndPaint(hwndliste,&amp;ps);
         }
         return 0;
         break;
      case WM_CLOSE:
         ManageCloseMessage(hw);
         break;
      case WM_DESTROY:
         EndSoftware(hw);
         PostQuitMessage(0);
         break;
      default:
         return (DefWindowProc(hw,msg,p1,p2));
    

    }
    return (0L);
    }
    BOOL APIENTRY DialogODSProc(HWND hDlg,UINT uMsg,WPARAM wParam,LPARAM lParam)
    {
    char sss[256];
    HDC dc;
    PAINTSTRUCT ps;

    switch (uMsg)
    { 
      case WM_INITDIALOG:
         return TRUE;
      case WM_COMMAND:
         switch(LOWORD(wParam))
         {
         case ID_BUTTON04:
         case ID_BUTTON05:
         case ID_BUTTON06:
            odscourant = LOWORD(wParam);
            sprintf(sss, &quot;Choix de l'ODS courant: %d&quot;, odscourant);
            SetWindowText(hDlg,sss);
            UpdateWindow(hDlg);
            dc=BeginPaint(hDlg,&amp;ps);
            EndPaint(hDlg,&amp;ps);
            break;
         case ID_BUTTON01:
            sprintf(sss, &quot;Scra ODS%d&quot;, odscourant);
            SetWindowText(hwndmain,sss);
            UpdateWindow(hwndmain);
            EndDialog(hDlg,0);
    

    // SendMessage(hw,WM_CLOSE,0,0);
    break;
    case ID_BUTTON02:
    odscourant = CST_ODSDEFAULT;
    sprintf(sss, "Scra ODS%d", odscourant);
    SetWindowText(hwndmain,sss);
    UpdateWindow(hwndmain);
    // SendMessage(hw,WM_CLOSE,0,0);
    EndDialog(hDlg,0);
    break;
    }
    if (LOWORD(wParam) == IDCANCEL || LOWORD(wParam) == IDOK)
    {
    EndDialog(hDlg,0);
    return TRUE;
    }
    default:
    return FALSE;
    }
    } //BOOL APIENTRY DialogODSProc(HWND hDlg,UINT uMsg,WPARAM wParam,LPARAM lParam)
    /***********/
    /
    MAIN PROCEDURE /
    /***********
    /
    int WINAPI WinMain(HINSTANCE handle_app, //Application hinstance.
    HINSTANCE handle_prev, //NULL.
    LPTSTR param, //Command Line Parameter.
    int com_show) //How to display window (optionnal).
    {
    long wstyle;
    MSG msg;
    char title_main[]="Scra ODS5";
    char title_ods[]="Choix du numéro d'ODS";

    WNDCLASS wc_main;
    WNDCLASS wc_ods;
    //we first store the APP Hinstance
    G_hinstance=handle_app;
    //we define a window class to create a window from this class
    wc_main.style =CS_HREDRAW | CS_VREDRAW; //property.
    wc_main.lpfnWndProc=(WNDPROC)MainWindowManageEvent; //Adresse of our Callback.
    wc_main.cbClsExtra =0; //to store some byte inside a class object.
    wc_main.cbWndExtra =0; //to store some byte inside a window object.
    wc_main.hInstance =handle_app; //handle of the application hinstance.
    wc_main.hIcon =LoadIcon(NULL, IDI_APPLICATION);//handle of icon displayed in the caption.
    wc_main.hCursor =LoadCursor(NULL,IDC_ARROW); //handle of cursor mouse .
    wc_main.hbrBackground=(HBRUSH)(COLOR_MENU+1); //Background color.
    wc_main.lpszMenuName="MyMainAppMenu"; //pointer on menu defined in resource.
    wc_main.lpszClassName=szWindowClassName; //pointer on class name.
    //register class.
    if (RegisterClass(&wc_main)==0)
    {
    MessageBox(NULL,"Failed to register main class...",title_main,MB_APPLMODAL | MB_OK | MB_ICONERROR);
    return 0;
    }

    wstyle=WS_OVERLAPPEDWINDOW | WS_VISIBLE;
    hwndmain=CreateWindow(szWindowClassName, // address of registered class name.
    title_main, // address of window name string
    wstyle, // window style
    CW_USEDEFAULT, // horizontal position of window
    CW_USEDEFAULT, // vertical position of window
    UI_WIN_DX, // window width
    UI_WIN_DY, // window height
    NULL, // parent handle is NULL for a main window.
    NULL, // menu name defined in resource
    //(NULL if defined in the Class).
    handle_app, // handle of application instance
    NULL); // address of window-creation data

    if (hwndmain==NULL)
    {
    MessageBox(NULL,"Failed to create main window...",title_main,MB_APPLMODAL | MB_OK | MB_ICONERROR);
    return 0;
    }
    ShowWindow(hwndmain,SW_SHOW); //Display the window.
    UpdateWindow(hwndmain); //Send WM_PAINT.

    /---------------------------------------------------------------------------/
    / Messages Loop. /
    /---------------------------------------------------------------------------/
    while (GetMessage(&msg,NULL,0,0)) //Get Message if any.
    {
    TranslateMessage(&msg); //Translate the virtuel keys event.
    DispatchMessage(&msg); //DispatchMessage to the related window.
    }
    //here you can make last uninitialization and release
    return (int)(msg.wParam);
    }

    minprg.rc

    /--------------------------------------------------------------------------------/
    / 'C' Programming Under WIN32 G.Carry (2009)/
    / /
    / /
    /--------------------------------------------------------------------------------/

    include "minprg.h"

    //1 ICON Book.ico

    /////////////////////////////////////////////////////////////////////////////
    //
    // Menu
    //

    MyMainAppMenu MENU DISCARDABLE
    BEGIN
    POPUP "&File"
    BEGIN
    MENUITEM "&ODS courant", IDT_NUMERODODS
    MENUITEM "&Cartographie", IDM_CARTOGRAPHIE
    MENUITEM SEPARATOR
    MENUITEM "&Quit", IDM_QUIT
    END
    POPUP "&Liste"
    BEGIN
    MENUITEM "&Do Another Thing", IDT_DOANOTHERTHING
    MENUITEM SEPARATOR
    MENUITEM "&Do A third Thing", IDM_DOATHIRDTHING
    MENUITEM "&Do What you want", IDM_DOWHATYOUWANT
    END
    MENUITEM "&Définition", IDM_DEFINITION
    END

    /////////////////////////////////////////////////////////////////////////////
    //
    // DIALOG
    //
    DIALOGODS DIALOG
    100, 100, 240, 150
    STYLE WS_POPUP | DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
    CAPTION "Numéro d'ODS"
    BEGIN
    DEFPUSHBUTTON "VALIDER", ID_BUTTON01, 20,60, 90, 30
    DEFPUSHBUTTON "ANNULER", ID_BUTTON02, 120,60, 90, 30
    DEFPUSHBUTTON "4", ID_BUTTON04, 80,20, 20, 20
    DEFPUSHBUTTON "5", ID_BUTTON05, 110,20, 20, 20
    DEFPUSHBUTTON "6", ID_BUTTON06, 140,20, 20, 20

    // ICON 1, -1, 20, 15, 32, 32
    LTEXT "Entrer le numéro de l'ODS aà utiliser !", -1, 60, 18, 80, 10
    END

    /////////////////////////////////////////////////////////////////////////////
    //
    // STRING
    //

    STRINGTABLE
    BEGIN
    IDS_CONFIRMCLOSE "Do you want to close this application ?"
    END

    /////////////////////////////////////////////////////////////////////////////
    //
    // Version
    //

    1 VERSIONINFO
    FILEVERSION FILEVERSION
    PRODUCTVERSION PRODUCTVERSION
    FILEFLAGSMASK 0x3fL

    ifdef _DEBUG

    FILEFLAGS 0x1L

    else

    FILEFLAGS 0x0L

    endif

    FILEOS 0x0L
    FILETYPE 0x1L
    FILESUBTYPE 0x0L
    BEGIN
    BLOCK "StringFileInfo"
    BEGIN
    BLOCK "000004b0"
    BEGIN
    VALUE "Comments", COMMENTS
    VALUE "CompanyName", COMPANYNAME
    VALUE "FileDescription", FILEDESCRIPTION
    VALUE "FileVersion", SZFILEVERSION
    VALUE "InternalName", INTERNALNAME
    VALUE "LegalCopyright", LEGALCOPYRIGHT
    VALUE "OriginalFilename", ORIGINALFILENAME
    VALUE "ProductName", PRODUCTNAME
    VALUE "ProductVersion", SZPRODUCTVERSION
    END
    END
    BLOCK "VarFileInfo"
    BEGIN
    VALUE "Translation", 0x0, 1200
    END
    END

    minprg.h

    /--------------------------------------------------------------------------------/
    / 'C' Programming Under WIN32 G.Carry (2009)/
    / /
    /--------------------------------------------------------------------------------/

    ifndef MINPRG_H

    define MINPRG_H

    //version information (for program)

    define SZPUBLICVERSION "1.0.0.0" //displayed version in about box

    define SZPUBLICNAME "Scra" //displayed title in main window

    define SZCOMMENTS "Listes, anagrammes, etc"

    //Information for Main window

    define UI_WIN_DX 1024

    define UI_WIN_DY 768

    //Information for ODSNumber window

    define UI_ODSNUMBER_X 100

    define UI_ODSNUMBER_Y 100

    define UI_ODSNUMBER_DX 240

    define UI_ODSNUMBER_DY 150

    //version information (used in resource file)

    define FILEVERSION 1,0,0,0

    define PRODUCTVERSION 1,0,0,0

    define SZFILEVERSION "1, 0, 0, 0\0"

    define SZPRODUCTVERSION "1, 0, 0, 0\0"

    #define __COMMENTS__            &quot;Listes, anagrammes, etc&quot;
    #define __COMPANYNAME__         &quot;Carry Production\0&quot;
    #define __FILEDESCRIPTION__     &quot;Windows Application\0&quot;
    #define __INTERNALNAME__        &quot;Scra&quot;
    #define __LEGALCOPYRIGHT__      &quot;Copyright G.Carry©2009\0&quot;
    #define __ORIGINALFILENAME__    &quot;Scra.EXE\0&quot;
    #define __PRODUCTNAME__         &quot;Scra\0&quot;
    

    //definitions for MENU

    define IDT_NUMERODODS 50

    define IDM_QUIT 100

    define IDM_CARTOGRAPHIE 101

    define IDT_DOANOTHERTHING 60

    define IDM_DOATHIRDTHING 200

    define IDM_DOWHATYOUWANT 201

    define IDM_DEFINITION 302

    define ID_LISTBOX 500

    //definitions for STRING-TABLE

    define IDS_CONFIRMCLOSE 100

    //definitions for CONTROLS

    define ID_BUTTON01 1

    define ID_BUTTON02 2

    define ID_BUTTON03 3

    define ID_BUTTON04 4

    define ID_BUTTON05 5

    define ID_BUTTON06 6

    define ID_BUTTON07 7

    define ID_BUTTON08 8

    define ID_BUTTON09 9

    define ID_COMBONUMEROODS 301

    define CST_ODSDEFAULT 5

    endif /MINPRG_H/

     
    • Gérard CARRY

      Gérard CARRY - 2009-04-16

      J'ai oublié: je travaille sous Windows XP Edition familiale Version 2002 Service Pack 3

      Merci d'avance de votre aide.

       
    • cpns

      cpns - 2009-04-16

      In the following:

      DIALOGODS DIALOG
      100, 100, 240, 150
      STYLE WS_POPUP | DS_MODALFRAME | WS_CAPTION | WS_SYSMENU

      there is a comma missing after the second line. It is a single command thus:

      DIALOGODS DIALOG 100, 100, 240, 150, STYLE WS_POPUP | DS_MODALFRAME | WS_CAPTION | WS_SYSMENU


      Dans ce qui suit :

      DIALOGODS DIALOG
      100, 100, 240, 150
      STYLE WS_POPUP | DS_MODALFRAME | WS_CAPTION | WS_SYSMENU

      il y a une virgule manquant après la deuxième ligne. C'est ainsi une commande simple :

      DIALOGODS DIALOG 100, 100, 240, 150, STYLE WS_POPUP | DS_MODALFRAME | WS_CAPTION | WS_SYSMENU

      Aucun doute la traduction n'est pauvre ; désolé.

      Clifford

       
      • Gérard CARRY

        Gérard CARRY - 2009-04-17

        Clifford,

        Thank you for the french version, it was very good.
        Thank you also for the proposition of solution, unfortunately it doesn't work. I get the same error message.

        Have a good day.
        Bye.

         
    • cpns

      cpns - 2009-04-17

      My mistake; checking the documentation, it seems that a comma does not appear between the height parameter and the STYLE option. I am not sure if line breaks are critical, but examples I can find have the style bits and the STYLE keyword on the same line, so:

      Mon erreur ; vérifiant la documentation, il semble que une virgule n'apparaît pas entre le paramètre de taille et l'option de STYLE. Je ne suis pas sûr si la ligne coupures sont critique, mais des exemples que je peux trouver pour avoir le 'bits' de modèle et le mot-clé de STYLE sur la même ligne, ainsi :

      DIALOGODS DIALOG 100, 100, 240, 150
      STYLE WS_POPUP | DS_MODALFRAME | WS_CAPTION | WS_SYSMENU

      Note also that there are some differences between Microsoft's resource compiler and the Open Source windres resource compiler.

      Notez également qu'il y a quelques différences entre le compilateur de ressource de Microsoft et le compilateur de ressource d'Open Source (windres).

      Clifford

       
    • Gérard CARRY

      Gérard CARRY - 2009-04-22

      Clifford,

      I was out for few days.
      Thank you for your answers. I just have found a solution, not very elegant but ...
      I have replaced the constants by their values and it works even if you keep line breaks.

      STYLE WS_POPUP | DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
      becomes
      STYLE 0x80C80080.

      The problem seems in the Open Source resource compiler. I have read some lines in some web pages about such problems.

      Have a good day.

      Gerard

       
      • cpns

        cpns - 2009-04-22

        Ah! The light dawns. You have to include <windows.h> in windres resource scripts so that these macros are defined.

        In Microsoft's resource compiler this appears to be unnecessary and it is implicitly included (which is reasonable - why would you not wnat these definitions!?). Consequently you will see a lot of resource scripts that do not work out of the box with windres.

        Sorry, I should have spotted that straight away since it is the most common resource script problem posted on this forum.

        That said, I think that manually created resource scripts are a quaint anachronism, and not worth the effort. If you want to do GUI development with Dev-C++ out-of-the-box, you have no choice' but all that tells me is that Dev-C++ is therefore not an appropriate tool for GUI development.

        Clifford

         
    • cpns

      cpns - 2009-04-22

      Note that these are machine translations courtesy of http://babelfish.yahoo.com. My French is not that good, only enough to correct the more obvious translation errors!

      Notez que ce sont courtoisie de traductions automatiques de http://babelfish.yahoo.com. Mon Français n'est pas celui bon, assez seulement pour corriger les erreurs plus évidentes de traduction !


      Ah ! Les aubes de lumière. Vous devez inclure <windows.h> en manuscrits de ressource de windres de sorte que ces macros soient définis.

      Dans le compilateur de ressource de Microsoft ceci semble être inutile et il est implicitement inclus (qui est raisonnable - pourquoi vous ne voudriez pas ces définitions ! ?). En conséquence vous verrez beaucoup de manuscrits de ressource qui n'établissent pas de la boîte avec des windres.

      Désolé, je devrais avoir repéré cela immédiatement puisque c'est le problème de manuscrit de ressource le plus commun signalé sur ce forum.

      Ce dit, je pense que les manuscrits manuellement créés de ressource sont un anachronisme étrange, et pas en valeur l'effort. Si vous voulez faire le développement de GUI avec la dehors-de-le-boîte de Dev-C++, vous n'avez aucun choice' ; mais tout ce qui m'indique est ce Dev-C++ est donc pas un outil approprié pour le développement de GUI.

      Clifford

       
    • Gérard CARRY

      Gérard CARRY - 2009-04-23

      Clifford,

      Dev C++ is perhaps not the appropriate tool for GUI development, but it is the only one I have. Anyway, I develop only for personal concern and not in a professional environment, so even if it takes more effort it is not very important. And it gives me the opportunity to discuss with you, so it is a good product!
      Excuse me for the lost of your time (my english is very poor and I do not know how to say; I'm very sorry for the time you spent answering me). Finally, the solution you proposed works fine.

      Have a good day.

      Gerard

       
    • cpns

      cpns - 2009-04-23

      > but it is the only one I have.

      There are many free alternatives, all you need is an Internet connection, and you obviously have that. I recommend VC++ 2008 Express if you are happy doing .NET C++/CLI development, or wxDev-C++ is you want to do native code GUI development with ISO C++. wxDev-C++ is a derivitive of Dev-C++ so you will be familiar with it.

      > And it gives me the opportunity to discuss
      > with you, so it is a good product!

      Note that I no longer use Dev-C++. And this is not the only C++ forum I frequent. I can also be found on DevShed.

      > my english is very poor

      Far superior to my French! And I'll bet that you did not need machine translation!?

      > Finally, the solution you proposed works fine.

      Good. I am sorry it took so long to realise the problem. It was your work in finding a solution that gave me the clue. Well done.

      Good luck.

      Clifford

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.