Sunteți pe pagina 1din 2

#include<windows.

h>
long _stdcall WndProc(HWND,UINT,WPARAM,LPARAM);
int _stdcall WinMain(HINSTANCE hInstance,
HINSTANCE hPrevinstance,
LPSTR lpCmdLine,
int nShowcmd)
{
WNDCLASS wc;
MSG msg;
HWND hwnd;
wc.cbClsExtra=0;
wc.cbWndExtra=0;
wc.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);
wc.hCursor=LoadCursor(NULL,IDC_ARROW);
wc.hIcon=LoadIcon(NULL,IDI_WINLOGO);
wc.hInstance=hInstance;
wc.lpfnWndProc=WndProc;
wc.lpszClassName="MyClass";
wc.style=0;
RegisterClass(&wc);
hwnd=CreateWindow("MyClass","SDK Application",WS_OVERLAPPEDWINDOW,150,10
0,550,380,0,0,hInstance,NULL);
ShowWindow(hwnd,SW_SHOWNORMAL);
while(GetMessage(&msg,NULL,0,0))
DispatchMessage(&msg);
return 0;
}
long _stdcall WndProc(HWND hwnd,UINT msg,
WPARAM wparam,LPARAM lparam)
{
HPEN hp;
HDC hdc;
HBRUSH hbr;
RECT rect;
static int x,y;
switch(msg)
{
case WM_LBUTTONDOWN:
hdc=GetDC(hwnd);
x=LOWORD(lparam);
y=HIWORD(lparam);
x=LOWORD(lparam);
y=HIWORD(lparam);
hp=CreatePen(PS_DOT,1,RGB(100,100,200));
SelectObject(hdc,hbr);
hbr=CreateHatchBrush(rand()%4,RGB(rand(),rand(),rand()));
SelectObject(hdc,hbr);
Rectangle(hdc,x-50,y-50,x+50,y+50);
ReleaseDC(hwnd,hdc);
break;
case WM_RBUTTONDOWN:
GetClientRect(hwnd,&rect);
InvalidateRect(hwnd,&rect,true);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
}
return DefWindowProc(hwnd,msg,wparam,lparam);
}

S-ar putea să vă placă și