begin process at 2010 02 10 12:18:24
  Trouver un code source :
 
dans
 
Accueil > Forum > 

Archive C/C++

 > 

Archives

 > 

Au secours

 > 

probleme de compilation (débutant)


Derniers messages déposésPoser une question dans le forum ou lancer une discussion

probleme de compilation (débutant)

lundi 23 mai 2005 à 19:00:28 | probleme de compilation (débutant)

cddvdcopy

je suis débutant, merci de m'éclairer !!

ce code marche :

#include <windows.h>
#define ID_SFC 100
#define ID_RECHERCHE 200
#define ID_EXIT 300
#define ID_PROPOS 400

/* Declare Windows procedure */
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);

/* Make the class name into a global variable */
char szClassName[ ] = "Windows App";

int WINAPI WinMain (HINSTANCE hThisInstance,
HINSTANCE hPrevInstance,
LPSTR lpszArgument,
int nFunsterStil)

{
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 color 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 */
"RepairWinXP", /* Title Text */
WS_OVERLAPPEDWINDOW, /* default window */
CW_USEDEFAULT, /* Windows decides the position */
CW_USEDEFAULT, /* where the window ends up on the screen */
600, /* The programs width */
400, /* 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 */
);
HWND sfc;
HWND recherche;
HWND quitter;
HWND propos;
sfc = CreateWindowEx(0, "BUTTON", NULL, WS_VISIBLE|WS_CHILD , 10,10,
350, 30, hwnd, (HMENU)ID_SFC, hThisInstance, NULL);
recherche = CreateWindowEx(0, "BUTTON", NULL, WS_VISIBLE|WS_CHILD, 370, 10,
210, 30, hwnd, (HMENU)ID_RECHERCHE, hThisInstance, NULL);
propos = CreateWindowEx(0, "BUTTON", NULL, WS_VISIBLE|WS_CHILD , 10, 330,
70, 30,hwnd, (HMENU) ID_PROPOS, hThisInstance, NULL);
quitter= CreateWindowEx(0, "BUTTON", NULL, WS_VISIBLE|WS_CHILD ,90 ,330,
150,30,hwnd, (HMENU) ID_EXIT, hThisInstance , NULL);
SetWindowText(sfc,"Restaurer Les fichiers système et les fichiers d'aide");
SetWindowText(recherche,"Retablir la fonction Rechercher");
SetWindowText(propos, "A propos");
SetWindowText(quitter, "Quitter RepairWinXP");
/* Make the window visible on the screen */
ShowWindow (hwnd, nFunsterStil);
UpdateWindow(sfc);
UpdateWindow(recherche);
UpdateWindow(propos);
UpdateWindow(quitter);
/* 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);
case WM_COMMAND :
switch (LOWORD(wParam))
{
case ID_EXIT :
PostQuitMessage (0);
break;
case ID_PROPOS :
MessageBox(NULL, " Merci d'utiliser RepairWinXP . \n Programme créé par griffin dans le but de vous faciliter WinXp" , "RepairWinXP", MB_OK);
break;
case ID_SFC :
int box1 = MessageBox(NULL, " Voulez-vous vraiment rétablir \n les fichiers systèmes et les fichiers d'aide ? \n Veuillez inserer le CD de Windows XP pour continuer." , "RepairWinXP", MB_YESNO | MB_ICONINFORMATION );
if( box1 == IDYES )
{
ShellExecute(NULL,NULL,"sfc","/scannow",NULL,SW_SHOWNORMAL);
}
break;
}
}
return 0;
}

mais des que je rajoute quelque chose et donc le code devient ca:

#include <windows.h>
#define ID_SFC 100
#define ID_RECHERCHE 200
#define ID_EXIT 300
#define ID_PROPOS 400

/* Declare Windows procedure */
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);

/* Make the class name into a global variable */
char szClassName[ ] = "Windows App";

int WINAPI WinMain (HINSTANCE hThisInstance,
HINSTANCE hPrevInstance,
LPSTR lpszArgument,
int nFunsterStil)

{
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 color 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 */
"RepairWinXP", /* Title Text */
WS_OVERLAPPEDWINDOW, /* default window */
CW_USEDEFAULT, /* Windows decides the position */
CW_USEDEFAULT, /* where the window ends up on the screen */
600, /* The programs width */
400, /* 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 */
);

HWND sfc;
HWND recherche;
HWND quitter;
HWND propos;
sfc = CreateWindowEx(0, "BUTTON", NULL, WS_VISIBLE|WS_CHILD , 10,10,
350, 30, hwnd, (HMENU)ID_SFC, hThisInstance, NULL);
recherche = CreateWindowEx(0, "BUTTON", NULL, WS_VISIBLE|WS_CHILD, 370, 10,
210, 30, hwnd, (HMENU)ID_RECHERCHE, hThisInstance, NULL);
propos = CreateWindowEx(0, "BUTTON", NULL, WS_VISIBLE|WS_CHILD , 10, 330,
70, 30,hwnd, (HMENU) ID_PROPOS, hThisInstance, NULL);
quitter= CreateWindowEx(0, "BUTTON", NULL, WS_VISIBLE|WS_CHILD ,90 ,330,
150,30,hwnd, (HMENU) ID_EXIT, hThisInstance , NULL);

SetWindowText(sfc,"Restaurer Les fichiers système et les fichiers d'aide");
SetWindowText(recherche,"Retablir la fonction Rechercher");
SetWindowText(propos, "A propos");
SetWindowText(quitter, "Quitter RepairWinXP");

/* Make the window visible on the screen */
ShowWindow (hwnd, nFunsterStil);
UpdateWindow(sfc);
UpdateWindow(recherche);
UpdateWindow(propos);
UpdateWindow(quitter);

/* 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);
case WM_COMMAND :
switch (LOWORD(wParam))
{
case ID_EXIT :
PostQuitMessage (0);
break;
case ID_PROPOS :
MessageBox(NULL, " Merci d'utiliser RepairWinXP . \n Programme créé par griffin dans le but de vous faciliter WinXp" , "RepairWinXP", MB_OK);
break;
case ID_SFC :
int box1 = MessageBox(NULL, " Voulez-vous vraiment rétablir \n les fichiers systèmes et les fichiers d'aide ? \n Veuillez inserer le CD de Windows XP pour continuer." , "RepairWinXP", MB_YESNO | MB_ICONINFORMATION );
if( box1 == IDYES )
{
ShellExecute(NULL,NULL,"sfc","/scannow",NULL,SW_SHOWNORMAL);
}
break;
case ID_RECHERCHE :
int box = MessageBox(NULL, " Voulez-vous vraiment rétablir la fonction Rechercher ?" , "RepairWinXP", MB_YESNO | MB_ICONINFORMATION );
if( box == IDYES )
{
ShellExecute(NULL,NULL,"regsvr32","%systemroot%\\srchasst\\srchui.dll",NULL,SW_SHOWNORMAL);
}
break;
}
}
return 0;
}


merci de vous pencher dessus
lundi 23 mai 2005 à 19:04:59 | oups

cddvdcopy

excusez moi mais j'ai oublier de préciser que le 2eme code ne voulait pas se compiler


lundi 23 mai 2005 à 19:12:05 | Re : probleme de compilation (débutant)

DeAtHCrAsH

Dis nous exactement qu'elle est le bout de code que tu as ajouté ca sera plus simple parceque la ca fait beaucoup a lire.

Shell
lundi 23 mai 2005 à 19:20:04 | Re : probleme de compilation (débutant)

cddvdcopy

voila le code que jai rajouté

case ID_RECHERCHE :
int box = MessageBox(NULL, " Voulez-vous vraiment rétablir la fonction Rechercher ?" , "RepairWinXP", MB_YESNO | MB_ICONINFORMATION );
if( box == IDYES )
{
ShellExecute(NULL,NULL,"regsvr32","%systemroot%\\srchasst\\srchui.dll",NULL,SW_SHOWNORMAL);
}
break;


juste apres :

case ID_SFC :
int box1 = MessageBox(NULL, " Voulez-vous vraiment rétablir \n les fichiers systèmes et les fichiers d'aide ? \n Veuillez inserer le CD de Windows XP pour continuer." , "RepairWinXP", MB_YESNO | MB_ICONINFORMATION );
if( box1 == IDYES )
{
ShellExecute(NULL,NULL,"sfc","/scannow",NULL,SW_SHOWNORMAL);
}
break;


lundi 23 mai 2005 à 19:48:23 | Re : probleme de compilation (débutant)

DeAtHCrAsH

Réponse acceptée !
Yep,
Bon je t'explique tes erreurs:
box1 et box ne doivent pas être déclarées dans les case.
Mets les soit en globales, soit au debut de ta fonction, juste avant le premier switch.

Sinon voila le code corrigé et indenté correctement:

#include <windows.h>

#define ID_SFC 100

#define ID_RECHERCHE 200

#define ID_EXIT 300

#define ID_PROPOS 400

/* Declare Windows procedure */

LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);

/* Make the class name into a global variable */

char szClassName[ ] = "Windows App";

int WINAPI WinMain (HINSTANCE hThisInstance,

HINSTANCE hPrevInstance,

LPSTR lpszArgument,

int nFunsterStil)

{

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 color 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 */

"RepairWinXP", /* Title Text */

WS_OVERLAPPEDWINDOW, /* default window */

CW_USEDEFAULT, /* Windows decides the position */

CW_USEDEFAULT, /* where the window ends up on the screen */

600, /* The programs width */

400, /* 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 */

);

HWND sfc;

HWND recherche;

HWND quitter;

HWND propos;

sfc = CreateWindowEx(0, "BUTTON", NULL, WS_VISIBLE|WS_CHILD , 10,10,

350, 30, hwnd, (HMENU)ID_SFC, hThisInstance, NULL);

recherche = CreateWindowEx(0, "BUTTON", NULL, WS_VISIBLE|WS_CHILD, 370, 10,

210, 30, hwnd, (HMENU)ID_RECHERCHE, hThisInstance, NULL);

propos = CreateWindowEx(0, "BUTTON", NULL, WS_VISIBLE|WS_CHILD , 10, 330,

70, 30,hwnd, (HMENU) ID_PROPOS, hThisInstance, NULL);

quitter= CreateWindowEx(0, "BUTTON", NULL, WS_VISIBLE|WS_CHILD ,90 ,330,

150,30,hwnd, (HMENU) ID_EXIT, hThisInstance , NULL);

SetWindowText(sfc,"Restaurer Les fichiers système et les fichiers d'aide");

SetWindowText(recherche,"Retablir la fonction Rechercher");

SetWindowText(propos, "A propos");

SetWindowText(quitter, "Quitter RepairWinXP");

/* Make the window visible on the screen */

ShowWindow (hwnd, nFunsterStil);

UpdateWindow(sfc);

UpdateWindow(recherche);

UpdateWindow(propos);

UpdateWindow(quitter);

/* 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)

{

int box, box1;

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);

case WM_COMMAND :

switch (LOWORD(wParam))

{

case ID_EXIT :

PostQuitMessage (0);

break;

case ID_PROPOS :

MessageBox(NULL, " Merci d'utiliser RepairWinXP . \n Programme créé par griffin dans le but de vous faciliter WinXp" , "RepairWinXP", MB_OK);

break;

case ID_SFC :

box1 = MessageBox(NULL, " Voulez-vous vraiment rétablir \n les fichiers systèmes et les fichiers d'aide ? \n Veuillez inserer le CD de Windows XP pour continuer." , "RepairWinXP", MB_YESNO | MB_ICONINFORMATION );

if( box1 == IDYES )

{

ShellExecute(NULL,NULL,"sfc","/scannow",NULL,SW_SHOWNORMAL);

}

break;

case ID_RECHERCHE :

box = MessageBox(NULL, " Voulez-vous vraiment rétablir la fonction Rechercher ?" , "RepairWinXP", MB_YESNO | MB_ICONINFORMATION );

if( box == IDYES )

{

ShellExecute(NULL,NULL,"regsvr32","%systemroot%\\srchasst\\srchui.dll",NULL,SW_SHOWNORMAL);

}

break;

}

break;

}

return 0;

}


Shell
lundi 23 mai 2005 à 19:59:25 | merci

cddvdcopy

encore merci pour ta réponse qui marche et pour ta rapidité
lundi 23 mai 2005 à 20:02:44 | Re : probleme de compilation (débutant)


Cette discussion est classée dans : messages, id, wincl, hwnd, window


Répondre à ce message

Sujets en rapport avec ce message

Je debute: [ par phpman ] Bonjour,je debute avec devc++, quand je creer un nouveau projet il me génère le code d'une form windows:#include /* Declare Windows procedure */LRESUL Problème d'initailisation objet IDirect3DDevice9 [ par olivierpot2 ] Bonjour à tous,je débutes en c++ directx et j'avoue que j'ai un peu (beaucoup) de mal...Dans le code suivant je n'arrives pas à initilalisé la variabl siouplait la charite pour un pov newbie [ par seichettmorru ] je compile, ca marcheje lance ca me dit "impossible de communiquer avec la carte"j'ai une geforce ti+directx 8.vous etes mon dernier recours:#include Application [ par Arnauti ] Bonjour, je suis nul et j'ai presque jamais fait de C/C++. Enfin, si quelque truc sous dos. Mais j'aimerais créé une aplication mais pas sous dos. Al insertion d'une phrase [ par chinois57 ] ou doige mettre une phrase du style sa va#include /*  Declare Windows procedure  */LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM); /*  tjr aide applications windows [ par chinois57 ] je suis desoler de denouveau vous enbeteer avec sa mais je ne comprend pas comment afficher un message dans une fenetre windows applicatios j'utilise C++ windows [ par notour ] bonjourj'ai réalyser un programme de cryptage de texte sous page DOS mais pour des raison pratique je souh couleur fond appli win32 [ par fredsor ] Salu a vous,Je créé une appli win32 sous devc++ en C.Je créé la fenetre avec CreateWindow, et j'aimerais que le fond soit blanc. Or l'appli se met dés probleme bizzare.... [ par lektrosonic ] Bonsoir, j ai code ce client...Code C:#include #include #include #define ID_CONNECT 1#define ID_SEND 2#define WM_SOCKET (WM_APP + 100)<br Traduction en FR programme en fenetre devc++ [ par toto6311 ] [code=cpp]#include /* Declare Windows procedure */ LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM); /* Faites le nom de la class


Nos sponsors


Sondage...

Comparez les prix

CalendriCode

Février 2010
LMMJVSD
1234567
891011121314
15161718192021
22232425262728

Consulter la suite du CalendriCode

 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 0,920 sec (3)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales