Soyez le premier à donner votre avis sur cette source.
Vue 9 378 fois - Téléchargée 646 fois
#include <windows.h> LRESULT CALLBACK WinProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { // Déclaration des variables en static: static HWND hedit1,hedit2,hedit3,hok,hquitter; switch(message) { case WM_CREATE: { // Création des contrôles: hedit1=CreateWindowEx(WS_EX_CLIENTEDGE,"edit","",WS_CHILD | WS_VISIBLE | WS_TABSTOP,20,20,100,20,hwnd,0,0,0); hedit2=CreateWindowEx(WS_EX_CLIENTEDGE,"edit","",WS_CHILD | WS_VISIBLE | WS_TABSTOP,20,60,100,20,hwnd,0,0,0); hedit3=CreateWindowEx(WS_EX_CLIENTEDGE,"edit","",WS_CHILD | WS_VISIBLE | WS_TABSTOP,20,100,100,20,hwnd,0,0,0); hok=CreateWindowEx(0,"button","Ok",WS_CHILD | WS_VISIBLE | WS_TABSTOP ,150,40,100,20,hwnd,(HMENU)IDOK,0,0); hquitter=CreateWindowEx(0,"button","Quitter",WS_CHILD | WS_VISIBLE | WS_TABSTOP,150,80,100,20,hwnd,(HMENU)IDCANCEL,0,0); // Changement de la police des contrôles: HFONT font=(HFONT)GetStockObject(DEFAULT_GUI_FONT); HWND child=FindWindowEx(hwnd,0,0,0); do { SendMessage(child,WM_SETFONT,(WPARAM)font,0); child=FindWindowEx(hwnd,child,0,0); }while(child); // Mettre le focus sur le premier EDIT: SetFocus(hedit1); return 0; } case WM_CLOSE: // Détruire la fenêtre: DestroyWindow(hwnd); return 0; case WM_DESTROY: // Forcer la sortie de la boucle des messages: PostQuitMessage(0); return 0; case WM_COMMAND: // Clic sur le bouton Ok ou appui sur la touche ENTREE: if((HWND)lParam==hok) MessageBox(hwnd,"Bouton Ok utilisé","Touche TAB",0); // Clic sur le bouton Quitter ou appui sur la touche ECHAP: if((HWND)lParam==hquitter)SendMessage(hwnd,WM_CLOSE,0,0); return 0; default: break; } // Appeler la procedure par défaut de la fenêtre: return DefWindowProc(hwnd,message, wParam, lParam); } int WINAPI WinMain(HINSTANCE hinst, HINSTANCE hprev, LPSTR cmd, int show) { // Déclaration et initialisation de la structure WNDCLASSEX: WNDCLASSEX wc; ZeroMemory(&wc,sizeof(WNDCLASSEX)); wc.cbSize=sizeof(WNDCLASSEX); wc.hInstance=hinst; wc.lpszClassName="fenetre"; wc.lpfnWndProc=WinProc; wc.hCursor=LoadCursor(0,IDC_ARROW); wc.hIcon=LoadIcon(0,IDI_APPLICATION); wc.hbrBackground=(HBRUSH)GetStockObject(LTGRAY_BRUSH); // Enregistrement de notre classe de fenêtre: RegisterClassEx(&wc); // Création de notre fenêtre: HWND hwnd=CreateWindowEx(0,"fenetre","Utilisation de la touche TAB",WS_SYSMENU | WS_VISIBLE ,0,0,280,170,0,0,hinst,0); // Boucle des messages: MSG msg; while(GetMessage(&msg,0,0,0)) { if(!IsDialogMessage(hwnd,&msg)) { DispatchMessage(&msg); TranslateMessage(&msg); } } // Sortie du programme: return 0; }
18 janv. 2010 à 16:08
8 mars 2008 à 16:43
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.