#define MAX_POINTS 1000 LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { int wmId, wmEvent,i,j; PAINTSTRUCT ps; HDC hdc; static POINT pt[MAX_POINTS]; static iCount; switch (message) { case WM_LBUTTONDOWN: iCount=0; InvalidateRect(hWnd,NULL,TRUE); break; case WM_MOUSEMOVE: if(wParam&MK_LBUTTON&&iCount<1000){ pt[iCount].x=LOWORD(lParam); pt[iCount++].y=HIWORD(lParam); hdc=GetDC(hWnd); SetPixel(hdc,LOWORD(lParam),HIWORD(lParam),0); ReleaseDC(hWnd,hdc); } break; case WM_LBUTTONUP: InvalidateRect(hWnd,NULL,TRUE); break; case WM_COMMAND: wmId = LOWORD(wParam); wmEvent = HIWORD(wParam); // Parse the menu selections: switch (wmId) { case IDM_ABOUT: DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About); break; case IDM_EXIT: DestroyWindow(hWnd); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } break; case WM_PAINT: hdc = BeginPaint(hWnd, &ps); // TODO: Add any drawing code here... SetCursor(LoadCursor(NULL,IDC_WAIT)); ShowCursor(TRUE); for(i=0;i<iCount-1;i++){ for(j=i+1;j<iCount;j++){ MoveToEx(hdc,pt[i].x,pt[i].y,NULL); LineTo(hdc,pt[j].x,pt[j].y); } } ShowCursor(FALSE); SetCursor(LoadCursor(NULL,IDC_ARROW)); EndPaint(hWnd, &ps); break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } return 0; }