I am trying to figure out how to make a coordinate plane. I figure it mostly out except for two problems:
1. I cant figure out how to stop the program from drawing the "marks" on the axis. I tried using 2 while statements(one for each axis) inside the while that makes the "marks" but that just put the marks on the top and left sides. Any ideas whats wrong?
2. The second problem is that whenever the user resizes the window it keeps the axis but the "marks" disappear. What can I do to fix this?
The code for the WM_SIZE and WM_PAINT is posted below:
Code:
case WM_SIZE:
cxClient = LOWORD (lParam) ;//to calculate width
cyClient = HIWORD (lParam) ;//to calculate height
return 0 ;
case WM_PAINT:
hdc = BeginPaint (hwnd, &ps) ;
axis = CreatePen (PS_SOLID, 2, 0);
marks = CreatePen (PS_DOT, 1, 0);
SelectObject (hdc, axis);
yaxis=cyClient/2; //to find half the hieght
xaxis=cxClient/2; //to find half the width
MoveToEx(hdc, xaxis, 0, NULL); //to move to top of Y axis
LineTo(hdc, xaxis, cyClient); //to draw y axis
MoveToEx(hdc, 0, yaxis, NULL); //to move to left of X axis
LineTo(hdc, cxClient, yaxis); //to draw X axis
SelectObject (hdc, marks);
xspace=cxClient/10;//to find a point on the Y axis
yspace=cyClient/10;//to find a point on the X axis
while(n<20){
xmarks = xspace * n;
ymarks = yspace * n;
MoveToEx(hdc, xmarks, 0, NULL);//move to starting point of x marks
LineTo(hdc, xmarks, cyClient);//draw x marks
MoveToEx(hdc, 0, ymarks, NULL);//move to starting point of y marks
LineTo(hdc, cxClient, ymarks);//draw y marks
n++;
}
EndPaint (hwnd, &ps) ;
return 0 ;