void DrawBezier(HDC hdc,POINT apt[]){ PolyBezier(hdc,apt,4); MoveToEx(hdc,apt[0].x,apt[0].y,NULL); LineTo(hdc,apt[1].x,apt[1].y); MoveToEx(hdc,apt[2].x,apt[2].y,NULL); LineTo(hdc,apt[3].x,apt[3].y); } LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { static POINT apt[4]; int wmId, wmEvent,cxClient,cyClient; PAINTSTRUCT ps; HDC hdc; switch (message) { case WM_SIZE: cxClient=LOWORD(lParam); cyClient=HIWORD(lParam); apt[0].x=cxClient/4; apt[0].y=cyClient/2; apt[1].x=cxClient/2; apt[1].y=cxClient/4; apt[2].x=cxClient/2; apt[2].y=3*cyClient/4; apt[3].x=3*cxClient/4; apt[3].y=cyClient/2; break; case WM_LBUTTONDOWN: break; case WM_RBUTTONDOWN: break; case WM_MOUSEMOVE: if(wParam&MK_LBUTTON||wParam&MK_RBUTTON){ hdc=GetDC(hWnd); SelectObject(hdc,GetStockObject(WHITE_PEN)); DrawBezier(hdc,apt); if(wParam&MK_LBUTTON){ apt[1].x=LOWORD(lParam); apt[1].y=HIWORD(lParam); } if(wParam&MK_RBUTTON){ apt[2].x=LOWORD(lParam); apt[2].y=HIWORD(lParam); } SelectObject(hdc,GetStockObject(BLACK_PEN)); DrawBezier(hdc,apt); ReleaseDC(hWnd,hdc); } 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... DrawBezier(hdc,apt); EndPaint(hWnd,&ps); break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } return 0; }