Aller au menu - Aller au contenu

[Plan du site] Vous êtes ici --- > Le Site du Zéro > Les forums > Programmation > Langage C++ > Erreur de compilation > Lecture du sujet

Erreur de compilation

Vous devez être inscrit pour pouvoir poster des messages

RésoluLe problème de ce sujet a été résolu

Page : 1 
Auteur Message
1 visiteur sur ce sujet (1 anonyme)
Page : 1 
Hors ligne Mario38 # Posté le 02/06/2007 à 09:04:22
Groupe : Membres
Voila quand je compile mon code avec code::blocks.
Et il me trouve une erreurs alors que je ne vois rien de faux :p


Code : C++
#include <windows.h>
#include <stdio.h>
#include <shlobj.h>
#include "constantes.h"

HINSTANCE instance;

#define ID_PUSHBUTTON_1     110
#define ID_PUSHBUTTON_2     111
#define ID_PUSHBUTTON_3     112
#define ID_CHECKBOX_1       113
#define ID_CHECKBOX_2       114
#define ID_CHECKBOX_3       115
#define ID_CHECKBOX_4       116
#define ID_RADIOBUTTON_11   117
#define ID_RADIOBUTTON_12   118
#define ID_RADIOBUTTON_13   119
#define ID_RADIOBUTTON_21   120
#define ID_RADIOBUTTON_22   121
#define ID_RADIOBUTTON_23   122
#define ID_STATIC_1     123
#define IDC_BTN_BROWSE  500



VOID RemplieFenetrePrincipale(HWND fenetrePrincipale)

{



        HWND hCtl=CreateWindow(
        "STATIC",
        "Choisissez le fichier d'origine...                                   puis le dossier de destination du fichier convertit",
        WS_CHILD|WS_VISIBLE|SS_CENTER|SS_NOTIFY,
        0,205,
        700,60,
        fenetrePrincipale,
        (HMENU)ID_STATIC_1,
        instance,
        NULL);

    hCtl=CreateWindow(
        "STATIC",
        "",
        WS_CHILD|WS_VISIBLE|SS_BITMAP,
        120,60,
        0,0,
        fenetrePrincipale,
        NULL,
        instance,
        NULL);
    HANDLE hImage=LoadImage(NULL,MAKEINTRESOURCE(OBM_CHECK),IMAGE_BITMAP,0,0,LR_SHARED);
    SendMessage(hCtl,STM_SETIMAGE,(WPARAM)IMAGE_BITMAP,(LPARAM)hImage);


    // Premier groupe: le push button
    HWND hGroup=CreateWindow(
        "BUTTON",
        "",
        WS_CHILD|WS_VISIBLE|BS_GROUPBOX,
        0,0,
        1,1,
        fenetrePrincipale,
        NULL,
        instance,
        NULL);
    {
        HWND hControle;
        // On le remplit avec un premier push button tout bête
        hControle=CreateWindow(
            "BUTTON",
            "",
            WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON,
            10+10,10+20,
            1,1,
            fenetrePrincipale,
            (HMENU)ID_PUSHBUTTON_1,
            instance,
            NULL);
        // un second avec quelques flags : plat et plusieurs lignes
        hControle=CreateWindow(
            "BUTTON",
            "Convertir",
            WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON|BS_FLAT|BS_MULTILINE,
            290,490,
            100,40,
            fenetrePrincipale,
            (HMENU)ID_PUSHBUTTON_2,
            instance,
            NULL);
        // et un troisième un peu plus exotique, c'est aussi le bouton par défaut de la fenêtre
        // on lui met aussi une image alignée à gauche
        hControle=CreateWindow(
            "BUTTON",
            "Quitter",
            WS_CHILD|WS_VISIBLE|BS_DEFPUSHBUTTON|BS_ICON|BS_LEFT,
            410,490,
            100,40,
            fenetrePrincipale,
            (HMENU)ID_PUSHBUTTON_3,
            instance,
            NULL);

        HANDLE hIcon=LoadIcon(NULL,IDI_ERROR);
        SendMessage(hControle,BM_SETIMAGE,IMAGE_ICON,(LPARAM)hIcon);
    }
    // Deuxième groupe: les check box
    hGroup=CreateWindow(
        "BUTTON",
        "Paramètres Supplementaires",
        WS_CHILD|WS_VISIBLE|BS_GROUPBOX,
        260,370,
        500,100,
        fenetrePrincipale,
        NULL,
        instance,
        NULL);
    {
        HWND hControle;
        // une check box automatique deux états
        hControle=CreateWindow(
            "BUTTON",
            "Le fichier de destination est sur un disque amovible",
            WS_CHILD|WS_VISIBLE|BS_AUTOCHECKBOX,
            260+10,370+30,
            400,20,
            fenetrePrincipale,
            (HMENU)ID_CHECKBOX_1,
            instance,
            NULL);

        // le même mais non automatique :)
        hControle=CreateWindow(
            "BUTTON",
            "Supprimer le fichier d'origine",
            WS_CHILD|WS_VISIBLE|BS_3STATE,
            260+10,370+60,
            400,20,
            fenetrePrincipale,
            (HMENU)ID_CHECKBOX_4,
            instance,
            NULL);
    }
    // troisième groupe : les radio button
    hGroup=CreateWindow(
        "BUTTON",
        "Mode de conversion",
        WS_CHILD|WS_VISIBLE|BS_GROUPBOX,
        10,320,
        240,150,
        fenetrePrincipale,
        NULL,
        instance,
        NULL);
    {
        HWND hControle;
        // trois radio button
        hControle=CreateWindow(
            "BUTTON",
            "MP3",
            WS_CHILD|WS_VISIBLE|BS_AUTORADIOBUTTON|WS_GROUP,
            10+10,320+30,
            100,20,
            fenetrePrincipale,
            (HMENU)ID_RADIOBUTTON_11,
            instance,
            NULL);
            hControle=CreateWindow(
            "BUTTON",
            "OGG",
            WS_CHILD|WS_VISIBLE|BS_AUTORADIOBUTTON|WS_GROUP,
            10+10,320+60,
            100,20,
            fenetrePrincipale,
            (HMENU)ID_RADIOBUTTON_12,
            instance,
            NULL);
            hControle=CreateWindow(
            "BUTTON",
            "OGG",
            WS_CHILD|WS_VISIBLE|BS_AUTORADIOBUTTON|WS_GROUP,
            10+10,320+90,
            100,20,
            fenetrePrincipale,
            (HMENU)ID_RADIOBUTTON_13,
            instance,
            NULL);

        // trois autres, mais qui forment un autre groupe
        hControle=CreateWindow(
            "BUTTON",
            "WMA",
            WS_CHILD|WS_VISIBLE|BS_AUTORADIOBUTTON|WS_GROUP,
            130+10,320+30,
            100,20,
            fenetrePrincipale,
            (HMENU)ID_RADIOBUTTON_21,
            instance,
            NULL);
            hControle=CreateWindow(
            "BUTTON",
            "MP3",
            WS_CHILD|WS_VISIBLE|BS_AUTORADIOBUTTON|WS_GROUP,
            130+10,320+60,
            100,20,
            fenetrePrincipale,
            (HMENU)ID_RADIOBUTTON_22,
            instance,
            NULL);
hControle=CreateWindow(
            "BUTTON",
            "OGG",
            WS_CHILD|WS_VISIBLE|BS_AUTORADIOBUTTON|WS_GROUP,
            130+10,320+90,
            100,20,
            fenetrePrincipale,
            (HMENU)ID_RADIOBUTTON_23,
            instance,
            NULL);

    }

}

VOID AfficheActionCheckBox(int index,HWND hCtl,HWND fenetrePrincipale)
{
    // test si la check box est cochée, non cochée ou inderterminée.
    LRESULT lRes=SendMessage(hCtl,BM_GETCHECK,0,0);
    CHAR lpMessage[128];

    sprintf(lpMessage,"Paramétre modifier avec succès",index,
        lRes==BST_CHECKED?"cochée":
        lRes==BST_UNCHECKED?"décochée":"inderterminée");

    MessageBox(fenetrePrincipale,lpMessage,"Succès",
        MB_ICONINFORMATION|MB_OK);
}

VOID DemandeActionCheckBox4(HWND hCtl,HWND fenetrePrincipale)
{
    // test si la check box est cochée, non cochée ou inderterminée.
    LRESULT lRes=SendMessage(hCtl,BM_GETCHECK,0,0);
    PCHAR lpProchainEtat;
    UINT iProchainEtat;
    UINT iChoix;
    CHAR lpMessage[128];

    if(lRes==BST_CHECKED)
    {
        lpProchainEtat="inderterminée";
        iProchainEtat=BST_INDETERMINATE;
    }
    else if(lRes==BST_INDETERMINATE)
    {
        lpProchainEtat="décochée";
        iProchainEtat=BST_UNCHECKED;
    }
    else
    {
        lpProchainEtat="cochée";
        iProchainEtat=BST_CHECKED;
    }

    sprintf(lpMessage,"Etes vous sur de vouloir supprimmer le fichier d'origine ?",lpProchainEtat);

    iChoix=MessageBox(fenetrePrincipale,lpMessage,"",MB_YESNO);
    if(iChoix==IDYES)
        SendMessage(hCtl,BM_SETCHECK,(WPARAM)iProchainEtat,0);
}

VOID NotificationControle(HWND fenetrePrincipale,UINT message, WPARAM wParam, LPARAM lParam)
{
    UINT iId=LOWORD(wParam);
    HWND hCtl=(HWND)lParam;

    switch(iId)
    {
        case ID_PUSHBUTTON_1:
            MessageBox(fenetrePrincipale,"Vous avez appuyé sur le premier bouton","",MB_OK);
            break;
        case ID_PUSHBUTTON_2:
            MessageBox(fenetrePrincipale,"Initiation du processus de conversion","",MB_OK);
            break;
        case ID_PUSHBUTTON_3:
            MessageBox(fenetrePrincipale,"Voulez-vous vraiment quitter","",MB_OK);
            break;
        case ID_CHECKBOX_1:
        case ID_CHECKBOX_2:
        case ID_CHECKBOX_3:
            AfficheActionCheckBox(iId-ID_CHECKBOX_1,hCtl,fenetrePrincipale);
            break;
        case ID_CHECKBOX_4:
            DemandeActionCheckBox4(hCtl,fenetrePrincipale);
            break;
    }
}

LRESULT CALLBACK procedureFenetrePrincipale(HWND fenetrePrincipale, UINT message, WPARAM wParam, LPARAM lParam)
{
    static HWND boutons[2] = {NULL};

    switch (message)
    {
        case WM_CREATE:
            RemplieFenetrePrincipale(fenetrePrincipale);
            return 0;
        case WM_COMMAND:
            NotificationControle(fenetrePrincipale,message,wParam,lParam);
            return 0;
        case WM_DESTROY:
            PostQuitMessage(0);
            return 0;
        default:
            return DefWindowProc(fenetrePrincipale,message,wParam,lParam);
    }
}


HWND hWndMain,hWndBtn;
char Result[MAX_PATH];

int FolderBrowse()
{
    BROWSEINFO bi;
        ITEMIDLIST *il;
    char Buffer[MAX_PATH];

    bi.hwndOwner=hWndMain;
    bi.pidlRoot=NULL;
    bi.pszDisplayName=&Buffer[0];
    bi.lpszTitle="Select a folder...";
    bi.ulFlags=0;
    bi.lpfn=NULL;

        if ((il=SHBrowseForFolder(&bi))==NULL) return 0;
        return SHGetPathFromIDList(il,&Result[0]);
}
LRESULT WINAPI WndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
    PAINTSTRUCT ps;
        HDC hdc;
    switch( msg )
    {
        case WM_COMMAND:
        {
            switch(LOWORD(wParam))
            {
                case IDC_BTN_BROWSE:
                                        if(FolderBrowse())
                            MessageBox(hWndMain,&Result[0],"Returned path",MB_ICONINFORMATION);
                    break;
            }
        } break;
        case WM_DESTROY:
            PostQuitMessage( 0 );
            return 0;
        case WM_PAINT:
            hdc=BeginPaint(hWnd,&ps);
            EndPaint(hWnd,&ps);
            return 1;
    }

    return DefWindowProc( hWnd, msg, wParam, lParam );
}

INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow, int modeDAffichage,HINSTANCE cetteInstance, HINSTANCE precedenteInstance,
             LPSTR lignesDeCommande)
{

    HWND fenetrePrincipale;
    MSG message;
    WNDCLASS classeFenetre;

    instance = cetteInstance;

    classeFenetre.style = 0;
    classeFenetre.lpfnWndProc = procedureFenetrePrincipale;
    classeFenetre.cbClsExtra = 0;
    classeFenetre.cbWndExtra = 0;
    classeFenetre.hInstance = NULL;
    classeFenetre.hIcon = LoadIcon(NULL, IDI_APPLICATION);
    classeFenetre.hCursor = LoadCursor(NULL, IDC_ARROW);
    classeFenetre.hbrBackground = (HBRUSH)(1 + COLOR_BTNFACE);
    classeFenetre.lpszMenuName = NULL;
    classeFenetre.lpszClassName = "classeF";

// On prévoit quand même le cas où ça échoue
    if(!RegisterClass(&classeFenetre))
        return FALSE;

    fenetrePrincipale=CreateWindow(
        "classeF",
        "MP4 Heart Convert 1.0 ::: Interface de conversion",
        WS_OVERLAPPEDWINDOW,
        CW_USEDEFAULT,CW_USEDEFAULT,
        800,600,
        NULL,
        NULL,
        cetteInstance,
        NULL);

    if (!fenetrePrincipale)
        return FALSE;

    ShowWindow(fenetrePrincipale,modeDAffichage);
    UpdateWindow(fenetrePrincipale);

{
    WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_HREDRAW | CS_VREDRAW, WndProc, 0L, 0L,
                      hInst, NULL, LoadCursor(NULL, IDC_ARROW), (HBRUSH)(COLOR_BTNFACE+1), NULL,
                      "MY_CLASS", NULL };
    RegisterClassEx( &wc );

    hWndMain = CreateWindow( "MY_CLASS", "SHBrowseForFolder",
                              WS_OVERLAPPED | WS_SYSMENU, 50, 50, 250,100,
                              NULL, NULL, hInst, NULL );
    ShowWindow( hWndMain, nCmdShow );
    UpdateWindow( hWndMain );

    hWndBtn = CreateWindow("BUTTON","Browse ...",WS_CHILD|WS_VISIBLE,10,10,100,25,hWndMain,(HMENU)IDC_BTN_BROWSE,hInst,NULL);

    MSG msg;
    while( GetMessage( &msg, NULL, 0, 0 ) )
    {
        TranslateMessage( &msg );
        DispatchMessage( &msg );
         }
    return 0;
}

Voila les erreurs qu'il me trouve (Pour infos la ligne 430 et la derniere de mon code):

main.cpp:430: error: expected `}' at end of input

Mais bon il la faut bien l'accolade tout a la fin de mon code o_O

Merci d'avance et bonnne Journée
Hors ligne Nanoc # Posté le 02/06/2007 à 09:26:39
Apprenez à utiliser la STL !!
Avatar
Groupe : Membres
Il te manque un } à la fin de ton code. Compte le nombre d'accolades ouvrante dans ta dernière fonction et compare aux nombres de fermantes.

A part ça, évite les #define blablabla; C'est du C et pas du C++
 
Hors ligne neuneutrinos # Posté le 02/06/2007 à 12:35:29
Avatar
Groupe : Membres
ou alors tu a mis un "{" en trop.

(au fait je sais pas si c'est normal mais tu as oublier un break;
dans ton code source (je vais te passer le passage en question :lol: )
Code : C++
LRESULT WINAPI WndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
    PAINTSTRUCT ps;
        HDC hdc;
    switch( msg )
    {
        case WM_COMMAND:
        {
            switch(LOWORD(wParam))
            {
                case IDC_BTN_BROWSE:
                                        if(FolderBrowse())
                            MessageBox(hWndMain,&Result[0],"Returned path",MB_ICONINFORMATION);
                    break;
            }
        } break;
        case WM_DESTROY:
            PostQuitMessage( 0 );
            return 0;
/*ou est le break ici???*/
        case WM_PAINT:
            hdc=BeginPaint(hWnd,&ps);
            EndPaint(hWnd,&ps);
            return 1;
    }

    return DefWindowProc( hWnd, msg, wParam, lParam );
}




maintenant pour le "{" ou le "}"
Code : C++

INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow, int modeDAffichage,HINSTANCE cetteInstance, HINSTANCE precedenteInstance,
             LPSTR lignesDeCommande)
{//debut main

    HWND fenetrePrincipale;
    MSG message;
    WNDCLASS classeFenetre;

    instance = cetteInstance;

    classeFenetre.style = 0;
    classeFenetre.lpfnWndProc = procedureFenetrePrincipale;
    classeFenetre.cbClsExtra = 0;
    classeFenetre.cbWndExtra = 0;
    classeFenetre.hInstance = NULL;
    classeFenetre.hIcon = LoadIcon(NULL, IDI_APPLICATION);
    classeFenetre.hCursor = LoadCursor(NULL, IDC_ARROW);
    classeFenetre.hbrBackground = (HBRUSH)(1 + COLOR_BTNFACE);
    classeFenetre.lpszMenuName = NULL;
    classeFenetre.lpszClassName = "classeF";

// On prévoit quand même le cas où ça échoue
    if(!RegisterClass(&classeFenetre))
        return FALSE;

    fenetrePrincipale=CreateWindow(
        "classeF",
        "MP4 Heart Convert 1.0 ::: Interface de conversion",
        WS_OVERLAPPEDWINDOW,
        CW_USEDEFAULT,CW_USEDEFAULT,
        800,600,
        NULL,
        NULL,
        cetteInstance,
        NULL);

    if (!fenetrePrincipale)
        return FALSE;

    ShowWindow(fenetrePrincipale,modeDAffichage);
    UpdateWindow(fenetrePrincipale);

{//accolade ouvrante 1
    WNDCLASSEX wc = {//accolade ouvrante 2
 sizeof(WNDCLASSEX), CS_HREDRAW | CS_VREDRAW, WndProc, 0L, 0L,
                      hInst, NULL, LoadCursor(NULL, IDC_ARROW), (HBRUSH)(COLOR_BTNFACE+1), NULL,
                      "MY_CLASS", NULL };//accolade fermante 1
    RegisterClassEx( &wc );
//-----------------------------------------------------------------
//OU es l'accolade fermante 2?
//-----------------------------------------------------------------

    hWndMain = CreateWindow( "MY_CLASS", "SHBrowseForFolder",
                              WS_OVERLAPPED | WS_SYSMENU, 50, 50, 250,100,
                              NULL, NULL, hInst, NULL );
    ShowWindow( hWndMain, nCmdShow );
    UpdateWindow( hWndMain );

    hWndBtn = CreateWindow("BUTTON","Browse ...",WS_CHILD|WS_VISIBLE,10,10,100,25,hWndMain,(HMENU)IDC_BTN_BROWSE,hInst,NULL);

    MSG msg;
    while( GetMessage( &msg, NULL, 0, 0 ) )
    {//accolade while
        TranslateMessage( &msg );
        DispatchMessage( &msg );
         }//fin while
    return 0;
}//fin main


n'ayant absolument rien compris à ce programme :euh: :-°
je ne sais pas où mettre l'accolade fermante 2
:p à toi de te debroiller maintenant

:p il n'y a que les abriutis qui ne changent pas d'avis :p

notre équipe ;)

 

Retour au forum "Langage C++" ou à la liste des forums

Vous devez être inscrit pour pouvoir poster des messages

Changer de design | En savoir plus | Plan du site | Politique d'accessibilité | Règles | RSS tutoriels | RSS news
Édité par Simple IT SARL : Nous contacter | Notre blog | Revue de presse | Publicité

Y'a plus rien à lire, faut remonter maintenant !

Hébergement web - Correction de tutoriels - Créer un site
Vous souhaitez apparaître ici ? Contactez-nous.

Nombre de connectés 135 Zéros connectés | Requêtes SQL 6 requêtes | Temps de génération de la page : Total (SQL) 0.0299s (0.0069s)