Dialogbox affichage erreur codeblocks

23253 Messages postés 11 Date d'inscription mercredi 2 mai 2012 Statut Membre Dernière intervention 14 mai 2013 - 14 mai 2013 à 09:55
23253 Messages postés 11 Date d'inscription mercredi 2 mai 2012 Statut Membre Dernière intervention 14 mai 2013 - 14 mai 2013 à 09:58
bonjour voila encore un soucis, je doit développer un petit programme sous Windows avec code::blocks comme IDE et...
quand je clique sur mon menu -> option -> paramètre je doit afficher une dialogbox et voila ce que ça donne :


bon le code :
main :
#include <windows.h>
#include "ressource.h"

/*  Declare Windows procedure  */
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
BOOL APIENTRY parametre_procedure(HWND,UINT,WPARAM,LPARAM);
char szClassName[ ] = "CodeBlocksWindowsApp";

HINSTANCE instance;

int WINAPI WinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nCmdShow){
    HWND hwnd;             
    MSG messages;           
    WNDCLASSEX wincl;       

    instance = hThisInstance;
    /* The Window structure */
    wincl.hInstance = hThisInstance;
    wincl.lpszClassName = szClassName;
    wincl.lpfnWndProc = WindowProcedure;     
    wincl.style = CS_DBLCLKS;                
    wincl.cbSize = sizeof (WNDCLASSEX);

    /* Use default icon and mouse-pointer */
    wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
    wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
    wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
    wincl.lpszMenuName = "ID_MENU";    
    wincl.cbClsExtra = 0; 
    wincl.cbWndExtra = 0;
    wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;

    if (!RegisterClassEx (&wincl))
        return 0;

    hwnd = CreateWindowEx (0,szClassName,"Code::Blocks Template Windows App",WS_OVERLAPPEDWINDOWCW_USEDEFAULT,CW_USEDEFAULT,544,375,HWND_DESKTOP,NULL,hThisInstance, NULL);

    ShowWindow (hwnd, nCmdShow);

    while (GetMessage (&messages, NULL, 0, 0)){
        TranslateMessage(&messages);
        DispatchMessage(&messages);
    }
    return messages.wParam;
}


LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam){
    switch (message){                 /* handle the messages */
        case WM_COMMAND:{
            switch(LOWORD(wParam)){
                case ID_M_QUITER:{
                    PostQuitMessage(0);
                    SendMessage(hwnd, WM_DESTROY, 0, 0);
                    break;
                }
                //pendant l'affichage de la dialogue box ça plante (l'affichage)
                case ID_M_PARAMETRES:{   
                    DialogBoxParam(instance, "ID_PARAM", hwnd, (DLGPROC)parametre_procedure, (LPARAM)hwnd);
                    break;
                }
                case ID_M_APROPOS:{
                    MessageBox(NULL, "A propos","A propos",NULL);
                    break;
                }
                default:{
                    break;
                }
            }
            break;
        }
        case WM_DESTROY:
            PostQuitMessage (0);      
            break;
        default:                     
            return DefWindowProc (hwnd, message, wParam, lParam);
    }
    return 0;
}



BOOL APIENTRY parametre_procedure(HWND fenetreDialogue,UINT message,WPARAM wParam,LPARAM lParam){
    switch (message){
       case WM_INITDIALOG:{
            return TRUE;
        }
        case WM_COMMAND:{
           switch(LOWORD(wParam)){
                case ID_CANCEL:{
                    PostQuitMessage(0);
                    SendMessage(fenetreDialogue, WM_DESTROY, 0, 0);
                    break;
                }
            }
            break;
        }
    }
}


ressource.h
#ifndef RESSOURCE_H_INCLUDED
#define RESSOURCE_H_INCLUDED

//boutons communs
#define     ID_OK               05001
#define     ID_CANCEL           05002

//boutons du top-menu
#define     ID_M_NOUVEAU        10001
#define     ID_M_OUVRIR         10002
#define     ID_M_SAUVER         10003
#define     ID_M_QUITER         10004
#define     ID_M_PARAMETRES     10005
#define     ID_M_AIDE           10006
#define     ID_M_APROPOS        10007
#define     ID_M_REGLES         10008

#endif // RESSOURCE_H_INCLUDED

ressource.rc
#include "ressource.h"

ID_MENU MENU
BEGIN
    POPUP "Fichier"
    BEGIN
        MENUITEM "Nouveau", ID_M_NOUVEAU
        MENUITEM "Ouvrir", ID_M_OUVRIR
        MENUITEM "Sauver", ID_M_SAUVER
        MENUITEM SEPARATOR
        MENUITEM "Quitter", ID_M_QUITER
    END
    POPUP "Options"
    BEGIN
        MENUITEM "Parametres", ID_M_PARAMETRES
    END
    POPUP "Aide"
    BEGIN
        MENUITEM "Regles", ID_M_REGLES
        MENUITEM "A propos", ID_M_APROPOS

    END
END

ID_PARAM DIALOG 0, 0, 80, 30
CAPTION "Win32 Programming"
FONT 8, "MS Shell Dlg"
BEGIN
    PUSHBUTTON "Anuler/Sortir", ID_CANCEL, 10,   10,    60,     10
END


Si vous comprenez pourquoi ça s'affiche comme ça merci

1 réponse

23253 Messages postés 11 Date d'inscription mercredi 2 mai 2012 Statut Membre Dernière intervention 14 mai 2013
14 mai 2013 à 09:58
voila le resultat :
0
Rejoignez-nous