Partage
  • Partager sur Facebook
  • Partager sur Twitter

créer une fenêtre avec Codes::Blocks

    11 décembre 2019 à 11:56:30

    Bonjour,

    En fait je souhaiterais créer une fenetre à partir de C::B.

    Quel Librairies pourrais-je installer ?

    ps: je sais que on peux le faire avec qt créator, si c'est beaucoup trop compliquée sur C::B j'ai l'intention de passer à Qt.

    • Partager sur Facebook
    • Partager sur Twitter
      11 décembre 2019 à 19:19:29

      Bonsoir,

      Sur C::B (version 17.12), tu as la possibilité de créer un projet "wxWidgets" ( boutons File / New / Project... et tout au bout " wxWidgets project"). Je n'ai jamais utilisé, je ne sais pas comment ca marche, ... mais ça répond peut-être à ta demande.

      Bien cordialement.

      • Partager sur Facebook
      • Partager sur Twitter
        12 décembre 2019 à 10:26:28

        merci de t'a réponse @dedeun , en effet on peut créer une application graphique avec xwWidgets mais j'ai un problème.

        En fait j'ai télécharger xwidgets à partir de ce lien: http://www.wxwidgets.org/downloads/

        puis j'ai suivi le tuto "vos applications avec widgets", voici le lien sur le site OC : 

        https://openclassrooms.com/fr/courses/1594736-vos-applications-avec-wxwidgets/1595342-compilation-sous-windows

        puis on me demande de copiez mon code "main.cpp" dans les fichiers, je le fait en insérant l' include de "main.cpp" (#include "C:\Users\mareg\documents\programation\wxApp05\main.cpp") dans le fichiers "MyApp.cpp" et la sa ne compile pas.

        voici une capture d'écran de ce qui était demandez :

        Sa affiche ses erreurs là:

        ||=== Build: Release in wxApp05 (compiler: GNU GCC Compiler) ===|

        \wxWidgets-3.1.3\lib\gcc_dll\mswu||No such file or directory [-Werror=missing-include-dirs]|

        C:\Users\mareg\documents\programation\wxApp05\main.cpp||In function 'int WinMain(HINSTANCE, HINSTANCE, LPSTR, int)':|

        C:\Users\mareg\documents\programation\wxApp05\main.cpp|33|error: zero as null pointer constant [-Werror=zero-as-null-pointer-constant]|

        C:\Users\mareg\documents\programation\wxApp05\main.cpp|34|error: zero as null pointer constant [-Werror=zero-as-null-pointer-constant]|

        C:\Users\mareg\documents\programation\wxApp05\main.cpp|35|error: zero as null pointer constant [-Werror=zero-as-null-pointer-constant]|

        C:\Users\mareg\documents\programation\wxApp05\main.cpp|36|error: zero as null pointer constant [-Werror=zero-as-null-pointer-constant]|

        C:\Users\mareg\documents\programation\wxApp05\main.cpp|57|error: zero as null pointer constant [-Werror=zero-as-null-pointer-constant]|

        C:\Users\mareg\documents\programation\wxApp05\main.cpp|59|error: zero as null pointer constant [-Werror=zero-as-null-pointer-constant]|

        C:\Users\mareg\documents\programation\wxApp05\main.cpp|66|error: zero as null pointer constant [-Werror=zero-as-null-pointer-constant]|

        C:\Users\mareg\documents\programation\wxApp05\main.cpp|75|error: conversion from 'WPARAM' {aka 'long long unsigned int'} to 'int' may change value [-Werror=conversion]|

        ||=== Build failed: 9 error(s), 0 warning(s) (0 minute(s), 1 second(s)) ===|

        et voici mon code :
        fichiers MyApp.h
        #ifndef MYAPP_H
        #define MYAPP_H
        
        
        class MyApp
        {
            public:
                MyApp();
                virtual ~MyApp();
        
            protected:
        
            private:
        };
        
        #endif // MYAPP_H
        
        fichier MyApp.cpp
        #include "MyApp.h"
        #include "C:\Users\mareg\documents\programation\wxApp05\main.cpp"
        MyApp::MyApp()
        {
            //ctor
        }
        
        MyApp::~MyApp()
        {
            //dtor
        }
        fichier main.cpp
        #if defined(UNICODE) && !defined(_UNICODE)
            #define _UNICODE
        #elif defined(_UNICODE) && !defined(UNICODE)
            #define UNICODE
        #endif
        #include <tchar.h>
        #include <windows.h>
        /*  Declare Windows procedure  */
        LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
        /*  Make the class name into a global variable  */
        TCHAR szClassName[ ] = _T("CodeBlocksWindowsApp");
        int WINAPI WinMain (HINSTANCE hThisInstance,
                             HINSTANCE hPrevInstance,
                             LPSTR lpszArgument,
                             int nCmdShow)
        {
            HWND hwnd;               /* This is the handle for our window */
            MSG messages;            /* Here messages to the application are saved */
            WNDCLASSEX wincl;        /* Data structure for the windowclass */
            /* The Window structure */
            wincl.hInstance = hThisInstance;
            wincl.lpszClassName = szClassName;
            wincl.lpfnWndProc = WindowProcedure;      /* This function is called by windows */
            wincl.style = CS_DBLCLKS;                 /* Catch double-clicks */
            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 = NULL;                 /* No menu */
            wincl.cbClsExtra = 0;                      /* No extra bytes after the window class */
            wincl.cbWndExtra = 0;                      /* structure or the window instance */
            /* Use Windows's default colour as the background of the window */
            wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;
            /* Register the window class, and if it fails quit the program */
            if (!RegisterClassEx (&wincl))
                return 0;
            /* The class is registered, let's create the program*/
            hwnd = CreateWindowEx (
                   0,                   /* Extended possibilites for variation */
                   szClassName,         /* Classname */
                   _T("Code::Blocks Template Windows App"),       /* Title Text */
                   WS_OVERLAPPEDWINDOW, /* default window */
                   CW_USEDEFAULT,       /* Windows decides the position */
                   CW_USEDEFAULT,       /* where the window ends up on the screen */
                   544,                 /* The programs width */
                   375,                 /* and height in pixels */
                   HWND_DESKTOP,        /* The window is a child-window to desktop */
                   NULL,                /* No menu */
                   hThisInstance,       /* Program Instance handler */
                   NULL                 /* No Window Creation data */
                   );
            /* Make the window visible on the screen */
            ShowWindow (hwnd, nCmdShow);
            /* Run the message loop. It will run until GetMessage() returns 0 */
            while (GetMessage (&messages, NULL, 0, 0))
            {
                /* Translate virtual-key messages into character messages */
                TranslateMessage(&messages);
                /* Send message to WindowProcedure */
                DispatchMessage(&messages);
            }
            /* The program return-value is 0 - The value that PostQuitMessage() gave */
            return messages.wParam;
        }
        /*  This function is called by the Windows function DispatchMessage()  */
        LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
        {
            switch (message)                  /* handle the messages */
            {
                case WM_DESTROY:
                    PostQuitMessage (0);       /* send a WM_QUIT to the message queue */
                    break;
                default:                      /* for messages that we don't deal with */
                    return DefWindowProc (hwnd, message, wParam, lParam);
            }
            return 0;
        }
                                                    merci de vos futur réponses
        PS : Le tuto est-il toujours à jour ?

        -
        Edité par sarazin 13 décembre 2019 à 8:01:55

        • Partager sur Facebook
        • Partager sur Twitter
          13 décembre 2019 à 14:40:28

          comment on utilise WIN 32 GUI project ?

          c'est quoi le code de la partie "précedente" ? 

          -
          Edité par sarazin 13 décembre 2019 à 17:42:28

          • Partager sur Facebook
          • Partager sur Twitter

          créer une fenêtre avec Codes::Blocks

          × Après avoir cliqué sur "Répondre" vous serez invité à vous connecter pour que votre message soit publié.
          × Attention, ce sujet est très ancien. Le déterrer n'est pas forcément approprié. Nous te conseillons de créer un nouveau sujet pour poser ta question.
          • Editeur
          • Markdown