#include
LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,PSTR lpCmdLine,int nShowCmd)
{
static char szAppName[]="Mouse";
WNDCLASS wc;
HWND hwnd;
MSG msg;
wc.style=CS_HREDRAW|CS_
wc.lpfnWndProc=(WNDPROC)
wc.cbClsExtra=0;
wc.cbWndExtra=0;
wc.hInstance=hInstance;
wc.hIcon=LoadIcon(NULL,
wc.hCursor=LoadCursor(
wc.hbrBackground=(
wc.lpszMenuName=NULL;
wc.lpszClassName=
RegisterClass(&wc);
hwnd=CreateWindow(
UpdateWindow(hwnd);
while(GetMessage(&msg,
{
TranslateMessage(&
DispatchMessage(&
}
return msg.wParam;
}
LRESULT CALLBACK WndProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)
{
HDC hdc;
switch(message)
{
case WM_LBUTTONDOWN:
InvalidateRect(
return 0;
case WM_MOUSEMOVE:
if(wParam && MK_LBUTTON)
{
hdc=GetDC(
ReleaseDC(
}
return 0;
case WM_LBUTTONUP:
InvalidateRect(
return 0;
case WM_DESTROY:
PostQuitMessage(0)
return 0;
}
return DefWindowProc(hwnd,message,
}
OUTPUT:
SOURCE CODE:
#include
#define MAXPOINTS 100
LRESULT CALLBACK WndProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam)
{
PAINTSTRUCT ps;
static POINT PT[MAXPOINTS];
int icount=0;
HDC hdc;
HPEN hPen,hPen1;
HBRUSH hbr;
RECT rect;
switch (message)
{
case WM_PAINT:
hdc=BeginPaint(hwnd,&ps);
GetClientRect(hwnd,&rect);
hPen1=CreatePen(PS_SOLID,10,1)
hbr=(HBRUSH)GetStockObject(7);
SelectObject(hdc,hPen1);
Rectangle(hdc,100,120,620,300)
hPen=CreatePen(PS_SOLID,3,1);
SelectObject(hdc,hPen);
hbr=CreateHatchBrush(HS_
SelectObject(hdc,hbr);
Ellipse(hdc,100,120,620,300);
MoveToEx(hdc,100,120,NULL);
LineTo(hdc,165,150);
MoveToEx(hdc,620,120,NULL);
LineTo(hdc,550,150);
MoveToEx(hdc,100,300,NULL);
LineTo(hdc,165,270);
MoveToEx(hdc,620,300,NULL);
LineTo(hdc,550,270);
hbr=CreateHatchBrush(HS_
SelectObject(hdc,hbr);
Rectangle(hdc,165,150,550,270)
DeleteObject(hPen);
DeleteObject(hPen1);
DeleteObject(hbr);
EndPaint(hwnd,&ps);
return 0;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hwnd,message,
}
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,PSTR lpCmdLine,int nShowCmd)
{
static char szAppName[]="MyApp";
WNDCLASS wc;
HWND hwnd;
MSG msg;
wc.style=CS_HREDRAW|CS_
wc.lpfnWndProc=(WNDPROC)
wc.cbClsExtra=0;
wc.cbWndExtra=0;
wc.hInstance=hInstance;
wc.hIcon=LoadIcon(NULL,IDI_
wc.hCursor=LoadCursor(NULL,
wc.hbrBackground=(HBRUSH)
wc.lpszMenuName=NULL;
wc.lpszClassName=szAppName;
RegisterClass(&wc);
hwnd=CreateWindow(szAppName,
UpdateWindow(hwnd);
while(GetMessage(&msg,NULL,0,
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
No comments:
Post a Comment