4/5 (16 avis)
Vue 5 792 fois - Téléchargée 340 fois
/********* PROMPT ****************/ LRESULT CALLBACK WindowProcedure2 (HWND, UINT, WPARAM, LPARAM); char result[5000+1]; HWND hwndpa;HWND pvalider;HWND pedit; HWND ptext; bool creer=0;HWND hwnd2; int prompt(HWND hwndp,char titre[],char description[],char defaut[]="") { result[0]='\0'; hwndpa=hwndp; MSG messages; if (!creer){WNDCLASSEX wincl;char sClassName[] = "prompt"; wincl.hInstance = NULL;wincl.lpszClassName = sClassName; wincl.lpfnWndProc = WindowProcedure2;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 = reinterpret_cast<HBRUSH>(16); if (!RegisterClassEx (&wincl)){ return 0;} hwnd2 = CreateWindowEx (0,sClassName,titre,WS_SIZEBOX,0,0,450,200,HWND_DESKTOP, NULL,NULL,NULL); if (hwnd2 == NULL){MessageBox(NULL, "Erreur CODE P0.", "Erreur", MB_OK);return 0;} ShowWindow (hwnd2, SW_SHOW);ShowWindow (hwndp, SW_HIDE); /***/ #define ID_PTEXT 100 ptext = CreateWindowEx(0, "STATIC", "", WS_VISIBLE|WS_CHILD|BS_TEXT, 10, 10, 410, 40, hwnd2, (HMENU)ID_PTEXT, NULL, NULL); if (ptext == NULL){MessageBox(hwnd2, "Erreur CODE P1.", "Erreur", MB_OK);return 0;} SetWindowText(ptext,description); #define ID_PEDIT 101 pedit = CreateWindowEx(WS_EX_OVERLAPPEDWINDOW, "EDIT", "", WS_VISIBLE|WS_CHILD|ES_AUTOHSCROLL|ES_NOHIDESEL, 10, 60, 410, 25, hwnd2, (HMENU)ID_PEDIT, NULL, NULL); if (pedit == NULL){MessageBox(hwnd2, "Erreur CODE P2.", "Erreur", MB_OK);return 0;} SetWindowText(pedit,defaut); #define ID_PVALIDER 102 pvalider = CreateWindowEx(0, "BUTTON", "", WS_VISIBLE|WS_CHILD|BS_PUSHBUTTON|BS_NOTIFY|BS_TEXT, 10, 100, 410 , 40, hwnd2, (HMENU)ID_PVALIDER, NULL, NULL); if (pvalider == NULL){MessageBox(hwnd2, "Erreur CODE P3.", "Erreur", MB_OK);return 0;} SetWindowText(pvalider,"Valider"); creer=1; SetFocus(pedit); /***/ } else { ShowWindow (hwnd2, SW_SHOW);ShowWindow (hwndp, SW_HIDE); /***/ SetWindowText(hwnd2,titre); SetWindowText(ptext,description); SetWindowText(pedit,defaut); SetWindowText(pvalider,"Valider"); SetFocus(pedit); /***/ } result[0]='\0'; while (GetMessage (&messages, NULL, 0, 0)){ TranslateMessage(&messages);DispatchMessage(&messages);}return messages.wParam; } LRESULT CALLBACK WindowProcedure2 (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) /* handle the messages */ { case WM_COMMAND: if ((LOWORD(wParam) == ID_PVALIDER) && (HIWORD(wParam) == BN_CLICKED)) { result[0]='\0'; GetDlgItemText(hwnd,ID_PEDIT,result,5001); ShowWindow(hwnd,SW_HIDE);PostQuitMessage(0);ShowWindow(hwndpa,SW_SHOW); } break; case WM_DESTROY : MessageBox(hwnd,"Vous devez d\'abord valider avant de quitter","Erreur",MB_OK|MB_ICONERROR);break; case WM_CLOSE : MessageBox(hwnd,"Vous devez d\'abord valider avant de quitter","Erreur",MB_OK|MB_ICONERROR);break; default: /* for messages that we don't deal with */ return DefWindowProc (hwnd, message, wParam, lParam); } return 0; } /********* FIN DU PROMPT ******************/
13 sept. 2004 à 19:55
Il faut apprendre à professionnaliser tt çà
fait une interface + sobre...
là, c'est carnaval!
sinon, C bien,
voir mm très bien
surtout vu ton age
allé
8/10
Commente nous donc ça ...
ça te permettra de comprendre ton code d'ici 3 ans....
Allé, Bonne prog
++
Nono.
17 juil. 2004 à 21:50
Je suis au collège entre les leçons (et les vacances m'ont bien aidé !!!)
17 juil. 2004 à 09:17
16 juil. 2004 à 19:37
16 juil. 2004 à 11:10
Vous n'êtes pas encore membre ?
inscrivez-vous, c'est gratuit et ça prend moins d'une minute !
Les membres obtiennent plus de réponses que les utilisateurs anonymes.
Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.
Le fait d'être membre vous permet d'avoir des options supplémentaires.