cs_JCDjcd
Messages postés
1138
Date d'inscription
mardi 10 juin 2003
Statut
Membre
Dernière intervention
25 janvier 2009
4
29 oct. 2003 à 09:56
//***********************************************
#include <windows.h>
LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);
//***********************************************
int WINAPI WinMain(
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
PSTR szCmdLine,
int iCmdShow
)
{
static char szAppName[] = "ExemplePourArkko";
HWND hwnd;
MSG msg;
WNDCLASSEX wndclass;
wndclass.cbSize = sizeof (wndclass);
wndclass.style = 0;
wndclass.lpfnWndProc = WndProc;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.hInstance = hInstance;
wndclass.hIcon = LoadIcon(NULL,IDI_APPLICATION);
wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wndclass.lpszMenuName = NULL;
wndclass.lpszClassName = szAppName;
wndclass.hIconSm = LoadIcon(NULL,IDI_APPLICATION);
RegisterClassEx(&wndclass);
hwnd = CreateWindow(
szAppName, // nom de la classe
szAppName, // titre de la fenetre
WS_OVERLAPPED | WS_SYSMENU, // style de la fenetre
CW_USEDEFAULT, // position initiale en x
CW_USEDEFAULT, // position initiale en y
512, // largeur initiale
512, // hauteur initiale
NULL, // handle de la fenetre mere
NULL, // handle du menu de la fenetre
hInstance, // handle de l'instance
NULL); // parametres de creation
ShowWindow(hwnd,iCmdShow);
UpdateWindow(hwnd);
while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
LRESULT CALLBACK WndProc(
HWND hwnd,
UINT iMsg,
WPARAM wParam,
LPARAM lParam
)
{
static int cx,cy;
switch (iMsg)
{
case WM_CREATE:
{
return 0;
}
case WM_SIZE:
{
cx = LOWORD(lParam);
cy = HIWORD(lParam);
break;
}
case WM_PAINT:
{
HDC hdc;
PAINTSTRUCT ps;
hdc = BeginPaint(hwnd,&ps);
Rectangle(hdc,cx/4,cy/4,3*cx/4,3*cy/4);
EndPaint(hwnd,&ps);
return 0;
}
case WM_DESTROY:
{
PostQuitMessage (0);
return 0;
}
}
return DefWindowProc(hwnd,iMsg,wParam,lParam);
}