Hisworld.tistory.com
The hisWorld
(140)
hisworld_new
(0)
hisOld
(138)
Android
(7)
Computer Vision
(18)
JAVA
(4)
C/C++
(26)
열혈강의 C
(32)
TCP/IP socket
(12)
WinAPI
(16)
System Programming
(0)
etc
(23)
Plan
(0)
hisWorld
(0)
hiStory
(0)
hiStudy
(0)
hiSnap
(0)
홈
태그
미디어로그
위치로그
방명록
Windows Live Messenger
winapi
Join C
대학생 공모전
The Turing test page
훈스닷넷
C/C++ Reference
WIKI
/
/
블로그 내 검색
Mouse 주석 달기
URUZ-7
2009. 1. 2. 01:24
2009. 1. 2. 01:24
#include <windows.h> LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM); HINSTANCE g_hInst; LPCTSTR lpszClass = TEXT("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_CROSS); WndClass.hIcon=LoadIcon(NULL,IDI_APPLICATION); WndClass.hInstance=hInstance; WndClass.lpfnWndProc=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,NULL,0,0)) { TranslateMessage(&Message); DispatchMessage(&Message); } return (int)Message.wParam; } LRESULT CALLBACK WndProc(HWND hWnd,UINT iMessage,WPARAM wParam,LPARAM lParam) { HDC hdc; //dc핸들 static int x; //x좌표 static int y; //y좌표 static bool bDrawNow=FALSE; //그리기 가능 상태 switch(iMessage) { case WM_LBUTTONDOWN: //왼쪽 버튼 누름 bDrawNow=TRUE; //그리기 상태 "가능" x=LOWORD(lParam); //x좌표 얻음 y=HIWORD(lParam); //y좌표 얻음 return 0; case WM_MOUSEMOVE: //마우스 이동 if(bDrawNow==TRUE) //그리기 "가능" 상태일 경우 { hdc=GetDC(hWnd); //현재 창의 dc를 얻음 MoveToEx(hdc,x,y,NULL); //현좌표를 x,y로 이동 x=LOWORD(lParam); //x좌표를 얻음 y=HIWORD(lParam); //y좌표를 얻음 LineTo(hdc,x,y); //x,y에 선을 그음 ReleaseDC(hWnd,hdc); //GetDC로 얻은 dc를 해제 } return 0; case WM_LBUTTONUP: //왼쪽 버튼을 누르지 않음 bDrawNow=FALSE; //그리기 상태 "불가능" return 0; case WM_DESTROY: PostQuitMessage(0); return 0; } return(DefWindowProc(hWnd,iMessage,wParam,lParam)); }
공유하기
게시글 관리
구독하기
Hisworld.tistory.com
+ Recent posts
Powered by
Tistory
, Designed by
wallel
Rss Feed
and
Twitter
,
Facebook
,
Youtube
,
Google+
티스토리툴바