cddvdcopy
Messages postés8Date d'inscriptionsamedi 11 décembre 2004StatutMembreDernière intervention26 mai 2005
-
23 mai 2005 à 19:00
DeAtHCrAsH
Messages postés2670Date d'inscriptionvendredi 25 janvier 2002StatutMembreDernière intervention 6 février 2013
-
23 mai 2005 à 20:02
/* 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 */
);
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:
/* 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 */
);
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;
}
DeAtHCrAsH
Messages postés2670Date d'inscriptionvendredi 25 janvier 2002StatutMembreDernière intervention 6 février 2013 23 mai 2005 à 19:48
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:
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 );
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 );