C¾ð¾î´Â ¹«ÇÑÇÑ ¾ð¾îÀÔ´Ï´Ù. Àß ¹è¿ì½Ã¸é ÁÁ½À´Ï´Ù.
-------------------------
#include <windows.h>
LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);
HINSTANCE g_hInst;
LPSTR lpszClass="Mouse";
int APIENTRY WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance
,LPSTR lpszCmdParam,int nCmdShow)
{
HWND hWnd;
MSG Message;
WNDCLASS WndClass;
g_hInst=hInstance;
WndClass.cbClsExtra=0;
WndClass.cbWndExtra=0;
WndClass.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);
WndClass.hCursor=LoadCursor(NULL,IDC_ARROW);
WndClass.hIcon=LoadIcon(NULL,IDI_APPLICATION);
WndClass.hInstance=hInstance;
WndClass.lpfnWndProc=(WNDPROC)WndProc;
WndClass.lpszClassName=lpszClass;
WndClass.lpszMenuName=NULL;
WndClass.style=CS_HREDRAW | CS_VREDRAW;
RegisterClass(&WndClass);
hWnd=CreateWindow(lpszClass,lpszClass,WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,
NULL,(HMENU)NULL,hInstance,NULL);
ShowWindow(hWnd,nCmdShow);
while(GetMessage(&Message,0,0,0)) {
TranslateMessage(&Message);
DispatchMessage(&Message);
}
return Message.wParam;
}
LRESULT CALLBACK WndProc(HWND hWnd,UINT iMessage,WPARAM wParam,LPARAM lParam)
{
HDC hdc;
static int x;
static int y;
static BOOL bnowDraw=FALSE;
switch(iMessage) {
case WM_LBUTTONDOWN:
x=LOWORD(lParam);
y=HIWORD(lParam);
bnowDraw=TRUE;
return 0;
case WM_MOUSEMOVE:
if (bnowDraw==TRUE) {
hdc=GetDC(hWnd);
MoveToEx(hdc,x,y,NULL);
x=LOWORD(lParam);
y=HIWORD(lParam);
LineTo(hdc,x+1,y+2);
LineTo(hdc,x+2,y+3);
LineTo(hdc,x-1,y-2);
LineTo(hdc,x-2,y-3);
LineTo(hdc,y+1,x+2);
LineTo(hdc,y+2,x+3);
LineTo(hdc,y-1,x-2);
LineTo(hdc,y-2,x-3);
LineTo(hdc,x+2,y+1);
LineTo(hdc,x+3,y+2);
LineTo(hdc,x-2,y-1);
LineTo(hdc,x-3,y-2);
LineTo(hdc,y+2,x+1);
LineTo(hdc,y+3,x+2);
LineTo(hdc,y-2,x-1);
LineTo(hdc,y-3,x-2);
ReleaseDC(hWnd,hdc);
}
return 0;
case WM_LBUTTONUP:
bnowDraw=FALSE;
return 0;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
}
return(DefWindowProc(hWnd,iMessage,wParam,lParam));
}
----------------------------------------
»ó´çÈ÷ API Áß ½¬¿î ºÎºÐ¸¸ ´Ù·ç¾ú°í ¸Þ½ÃÁö ºÎºÐµµ ½¬¿î ¸Þ½ÃÁö¸¸
ó¸®ÇÏ¿´½À´Ï´Ù. ¾ó¸¶µçÁö ¼öÁ¤Çؼ ¾Ë¾Æº¸¼¼¿ä. ¿©±â¼ ±×·¡ÇÈ¿¡ °ü·ÃµÈ ¼Ò½º´Â
if (bnowDraw==TRUE) {
hdc=GetDC(hWnd);
MoveToEx(hdc,x,y,NULL);
x=LOWORD(lParam);
y=HIWORD(lParam);
LineTo(hdc,x+1,y+2);
LineTo(hdc,x+2,y+3);
LineTo(hdc,x-1,y-2);
LineTo(hdc,x-2,y-3);
LineTo(hdc,y+1,x+2);
LineTo(hdc,y+2,x+3);
LineTo(hdc,y-1,x-2);
LineTo(hdc,y-2,x-3);
LineTo(hdc,x+2,y+1);
LineTo(hdc,x+3,y+2);
LineTo(hdc,x-2,y-1);
LineTo(hdc,x-3,y-2);
LineTo(hdc,y+2,x+1);
LineTo(hdc,y+3,x+2);
LineTo(hdc,y-2,x-1);
LineTo(hdc,y-3,x-2);
ReleaseDC(hWnd,hdc);
}
return 0;
ÀÌ°ÍÀÌ´Ï±î ¿©±â¸¦ Àß °íÃĺ¸¼¼¿ä. ¼ýÀÚ¸¸ °íÄ¡°Å³ª º¯¼ö¸¦ µû·Î ¸¸µé¾îµµ
±¦Âú½À´Ï´Ù.
±×¸² :
---------
|