Bonjour,
j'écris ce message pour un problème que j'ai avec un de mes programmes.
Je compile avec DevCpp Version 4.9.9.2 et j'ai crée deux fichiers sources: l'un s'appelle "main.cpp" et l'autre "MoteurCentral.h".
Voici leurs codes:
MoteurCentral.h:
#pragma once
#include <windows.h>
#include <mmsystem.h>
#include <vector>
using namespace std;
#ifndef MoteurCentral
#define MoteurCentral
class MoteurCentral
{
protected:
HINSTANCE m_hInstance;
HWND m_hHwnd;
TCHAR m_szWindowClass[32];
TCHAR m_szTitre[32];
WORD m_wIcon, m_wSmallIcon;
int m_iLongueur, m_iLargeur;
int m_iDelai;
public:
MoteurCentral(HINSTANCE hInstance, LPTSTR szWindowClass, LPTSTR szTitre,
WORD wIcon, WORD wSmallIcon,
int iLongueur = GetSystemMetrics(SM_CXSCREEN),
int iLargeur = GetSystemMetrics(SM_CYSCREEN));
virtual ~MoteurCentral();
BOOL Initialisation(int iCmdShow);
LRESULT HandleEvent(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
HINSTANCE GetInstance() {return m_hInstance;};
HWND GetHwnd() {return m_hHwnd;};
LPTSTR GetTitre() {return m_szTitre;};
WORD GetIcon() {return m_wIcon;};
WORD GetSmallIcon() {return m_wSmallIcon;};
int GetLongueur() {return m_iLongueur;};
int GetLargeur() {return m_iLargeur;};
int GetDelai() {return m_iDelai;};
int GetNombreAction() {return (1000/m_iDelai);};
int GetLongueurEcriture() {return m_iLongueur-
(GetSystemMetrics(SM_CYFIXEDFRAME)*2);};
int GetLargeurEcriture() {return m_iLargeur-
(GetSystemMetrics(SM_CYFIXEDFRAME) * 2 +
GetSystemMetrics(SM_CYCAPTION));};
void SetInstance(HINSTANCE hInstance) {m_hInstance=hInstance;};
void SetHwnd(HWND hwnd) {m_hHwnd=hwnd;};
void SetTitre(LPTSTR szTitre) {
if((lstrlen(szTitre)>0)&&(lstrlen(szTitre)<31)){
lstrcpy(m_szTitre,szTitre);}};
void SetIcon(WORD wIcon) {m_wIcon=wIcon;};
void SetSmallIcon(WORD wSmallIcon) {m_wSmallIcon=wSmallIcon;};
void SetLongueur(int iLongueur) {m_iLongueur=iLongueur;};
void SetLargeur(int iLargeur) {m_iLargeur=iLargeur;};
void SetDelai(int iDelai) {m_iDelai=iDelai;};
void SetNombreAction(int iNombre) {m_iDelai=1000/iNombre;};
void SetLongueurEcriture(int iLongueur){m_iLongueur=iLongueur+
(GetSystemMetrics(SM_CYFIXEDFRAME)*2);};
void SetLargeurEcriture(int iLargeur) {m_iLargeur=iLargeur+
(GetSystemMetrics(SM_CYFIXEDFRAME) * 2 +
GetSystemMetrics(SM_CYCAPTION));};
};
#endif
main.cpp:
#include <windows.h>
using namespace std;
#include "MoteurCentral.h"
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
char szClassName[ ] = "WindowsApp";
int WINAPI WinMain (HINSTANCE hThisInstance,
HINSTANCE hPrevInstance,
LPSTR lpszArgument,
int nFunsterStil)
{
HWND hwnd;
MSG messages;
WNDCLASSEX wincl;
wincl.hInstance = hThisInstance;
wincl.lpszClassName = szClassName;
wincl.lpfnWndProc = WindowProcedure;
wincl.style = CS_DBLCLKS;
wincl.cbSize = sizeof (WNDCLASSEX);
wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
wincl.lpszMenuName = NULL;
wincl.cbClsExtra = 0;
wincl.cbWndExtra = 0;
wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;
if (!RegisterClassEx (&wincl))
return 0;
hwnd = CreateWindowEx (
0,
szClassName,
"Windows App",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
544,
375,
HWND_DESKTOP,
NULL,
hThisInstance,
NULL
);
ShowWindow (hwnd, nFunsterStil);
while (GetMessage (&messages, NULL, 0, 0))
{
TranslateMessage(&messages);
DispatchMessage(&messages);
}
}
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;
}
Et voici le message d'erreur que j'ai:
4 C:\BASE DE DONNEES\TPE\main.cpp In file included from main.cpp
24 C:\BASE DE DONNEES\TPE\MoteurCentral.h expected `)' before "hInstance"
28 C:\BASE DE DONNEES\TPE\MoteurCentral.h expected class-name before '(' token
13 C:\BASE DE DONNEES\TPE\MoteurCentral.h an anonymous union cannot have function members
66 C:\BASE DE DONNEES\TPE\MoteurCentral.h abstract declarator `<anonymous class>' used as declaration
66 C:\BASE DE DONNEES\TPE\MoteurCentral.h namespace-scope anonymous aggregates must be static
C:\BASE DE DONNEES\TPE\Makefile.win [Build Error] [main.o] Error 1
Pouvez-vous me dire quel est la cause responsable de cet échec?
Merci d'avance pour qui compte m'aidera.
NAVI