Code bouton annuler

cs_kelme Messages postés 22 Date d'inscription lundi 19 mars 2007 Statut Membre Dernière intervention 28 mars 2007 - 28 mars 2007 à 10:51
BruNews Messages postés 21040 Date d'inscription jeudi 23 janvier 2003 Statut Modérateur Dernière intervention 21 août 2019 - 28 mars 2007 à 17:39
Bonjour à tous
j'ai créer un messagebox avec 2 bouton OKCANCEL
messagebox(0,"............",0+MB_OKCANCEL+MB_ICONINFORMATION);
 ShellExecute(0, "open", "C:\\test.doc", 0, 0, SW_SHOWNORMAL);<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /??>

je cherche le code pour annuler ShellExecute et fermer le message box
Avez-vous une idée
Merci d'avance

6 réponses

cs_kelme Messages postés 22 Date d'inscription lundi 19 mars 2007 Statut Membre Dernière intervention 28 mars 2007
28 mars 2007 à 11:56
Re Bonjour
voilà mon problème, ShellExecute çà marche avec les 2 bouton, soit en clic sur Ok, soit sur Annuler.
je cherche le code pour ne pas executer ShellExecute si en clic sur le bouton Annuler.
Merci
0
24Karas Messages postés 233 Date d'inscription jeudi 4 juillet 2002 Statut Membre Dernière intervention 5 juillet 2008
28 mars 2007 à 12:31
test code retour ...  msdn ...

/library/en-us/winui/winui/windowsuserinterface/windowing/dialogboxes/dialogboxreference/dialogboxfunctions/messagebox.asp http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/dialogboxes/dialogboxreference/dialogboxfunctions/messagebox.asp

Return Value

If a message box has a Cancel button, the function returns the IDCANCEL value if either the ESC key is pressed or the Cancel button is selected. If the message box has no Cancel button, pressing ESC has no effect.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

If the function succeeds, the return value is one of the following menu-item values.

IDABORT, Abort button was selected., ----
IDCANCEL, Cancel button was selected., ----
IDCONTINUE, Continue button was selected., ----
IDIGNORE, Ignore button was selected., ----
IDNO, No button was selected., ----
IDOK, OK button was selected., ----
IDRETRY, Retry button was selected., ----
IDTRYAGAIN, Try Again button was selected., ----
IDYES, Yes button was selected.

...

example :

if (MessageBox(hwndDlg, SZNOTFOUND, SZDELETEITEM, MB_OKCANCEL) ==IDOK)
{
// Prompt for a new item name and repeat the command.
}
else
{
// Cancel the command.
}

++
0
cs_kelme Messages postés 22 Date d'inscription lundi 19 mars 2007 Statut Membre Dernière intervention 28 mars 2007
28 mars 2007 à 14:01
Salut 24Karas
Merci pour ta réponse, j'ai pas arrivé a compiler ton exemple, voilà mon code, peut-tu ajouté ton code.

#include <windows.h>


int  WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInst, LPSTR cmdline, int show)


{


    MessageBox(0,"Bonjour tout le monde",0+MB_OKCANCEL+MB_ICONINFORMATION);   
       ShellExecute(0, "open", "C:\\test.doc", 0, 0, SW_SHOWNORMAL);
    ExitProcess(0);
      
}
0
cs_kelme Messages postés 22 Date d'inscription lundi 19 mars 2007 Statut Membre Dernière intervention 28 mars 2007
28 mars 2007 à 15:23
Re Bonjour à tous
pas de réponse, pas d'aide je trouve la programmation en c ou c++ est trés difficile, j'ai essayer tant de fois j'ai pas avancer en 1% en programmation.
comême merci pour tous les forumeurs, je vais retourner sous excel c'est mon niveau.
Merci à toute et à tous.
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
24Karas Messages postés 233 Date d'inscription jeudi 4 juillet 2002 Statut Membre Dernière intervention 5 juillet 2008
28 mars 2007 à 16:24
normal que mon code compile pas, c'est juste un extrait de msdn ...

#include <windows.h> int  WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInst, LPSTR cmdline, int show)

{

   if (MessageBox(0,"Bonjour tout le monde",0+MB_OKCANCEL+MB_ICONINFORMATION) == IDOK)
  {
       ShellExecute(0, "open", "C:\\test.doc", 0, 0, SW_SHOWNORMAL);
  }
    ExitProcess(0);
      
}

devrait être mieux.  j'ai pas testé!
0
BruNews Messages postés 21040 Date d'inscription jeudi 23 janvier 2003 Statut Modérateur Dernière intervention 21 août 2019
28 mars 2007 à 17:39
Jamais de '+' pour mixer des constantes, utiliser le OR:
MB_OKCANCEL | MB_ICONINFORMATION
ExitProcess() n'a rien à faire ici si on utilise le CRT.

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE zero, LPSTR cmdline, int show)
{
  if(MessageBox(0, "TEXTE", "TITRE", MB_OKCANCEL | MB_ICONINFORMATION) == IDOK)
  {
    ShellExecute(0, "open", "C:\\test.doc", 0, 0, SW_SHOWNORMAL);
  }
  return 0;
}

ciao...
BruNews, MVP VC++
0
Rejoignez-nous