1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
| #include <windows.h>
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
HWND hWnd;
const HBRUSH hCouleur_Jaune = CreateSolidBrush(RGB(255,255,0));
HBRUSH hBackground = hCouleur_Jaune;
static char szClassName[ ] = "Fenêtre Windows simple";
int WINAPI WinMain(HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpcmdLine, int nCmdShow){
WNDCLASSEX wincl;
wincl.hInstance = hThisInstance;
wincl.lpfnWndProc = WindowProcedure;
wincl.hbrBackground = hBackground;
wincl.style = CS_HREDRAW | CS_VREDRAW;
wincl.lpszClassName = szClassName;
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;
if (RegisterClassEx (&wincl) == false) // On enregistre la classe déclarée avec WNDCLASSEX
return 0 ; // et en cas d'erreur on quitte le programme
hWnd = CreateWindowEx (0, szClassName, "Fenetre simple", WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX, CW_USEDEFAULT, CW_USEDEFAULT, 644, 475, HWND_DESKTOP, NULL, hThisInstance, NULL);
ShowWindow(hWnd, nCmdShow);
MSG messages;
while (GetMessage (&messages, NULL, 0, 0)){
TranslateMessage(&messages);
DispatchMessage(&messages);
}
return messages.wParam;
}
LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam){
switch (message){
case WM_DESTROY:
PostQuitMessage (0); // envoie un message WM_QUIT dans la file d'attente
break;
default:
return DefWindowProc (hwnd, message, wParam, lParam);
}
return 0;
} |