Browse files

Fix pen functionality

  • Loading branch information...
1 parent 9f0a385 commit ff97bbb12d108b1211509145517af954f8ae55b0 @romanroibu romanroibu committed Mar 22, 2013
Showing with 14 additions and 1 deletion.
  1. +14 −1 lab#3/app/main.cpp
View
15 lab#3/app/main.cpp
@@ -78,6 +78,8 @@ LRESULT CALLBACK WindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM
static RECT drawingArea = {160, 17, 760, 410};
// Drawing states
+ static POINT startPen;
+
static BOOL drawingLineNow;
static POINT newLine;
@@ -301,6 +303,11 @@ LRESULT CALLBACK WindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM
point = adjustDrawLimits(xMouse, yMouse, drawingArea, stroke_weight);
xMouse = point.x;
yMouse = point.y;
+ // If Pen tool is selected
+ if((wParam == MK_LBUTTON)&&(Button_GetCheck(hwndPenTool) == BST_CHECKED)) {
+ startPen.x = xMouse;
+ startPen.y = yMouse;
+ }
// If Line tool is selected
if((wParam == MK_LBUTTON)&&(Button_GetCheck(hwndLineTool) == BST_CHECKED)) {
newLine.x = xMouse;
@@ -487,7 +494,13 @@ LRESULT CALLBACK WindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM
// If Pen tool is selected
if((wParam == MK_LBUTTON)&&(Button_GetCheck(hwndPenTool) == BST_CHECKED)) {
- SetPixel(hdc, xMouse, yMouse, strokeRGB);
+ strokePen = CreatePen(PS_SOLID, 1, strokeRGB);
+ SelectObject(hdc, strokePen);
+ MoveToEx(hdc, xMouse, yMouse, NULL);
+ LineTo(hdc, startPen.x, startPen.y);
+ DeleteObject(strokePen);
+ startPen.x = xMouse;
+ startPen.y = yMouse;
}
// If Eraser tool is selected
if((wParam == MK_LBUTTON)&&(Button_GetCheck(hwndEraserTool) == BST_CHECKED)) {

0 comments on commit ff97bbb

Please sign in to comment.