Hey, I have yet another problem(I bet you guys have written more of this program then me :-D .) This problem is really bothering me though. I have been trying to fix it for several weeks but it just wont draw the line.
This is the code that is exicuted when the user presses Ok on a dialog box. It's not throwing me errors when running so the infomation from the dialog box is good.
Code:
EndDialog (hDlg, 0) ;
drawinghdc = GetDC(hwnd) ;
rise = GetDlgItemInt(hDlg, 102, &risecheck, TRUE) ; //collect infomation
run = GetDlgItemInt(hDlg, 103, &runcheck, TRUE) ;
yintercept = GetDlgItemInt(hDlg, 104, &yinterceptcheck, TRUE) ;
if(risecheck == FALSE){ //check for completed infomation collection
MessageBox(hwnd, "Rise was not collected correctly", "Error on collection of data", MB_OK) ;
}
if(runcheck == FALSE){
MessageBox(hwnd, "Run was not collected correctly", "Error on collection of data", MB_OK) ;
}
if(yinterceptcheck == FALSE){
MessageBox(hwnd, "yintercept was not collected correctly", "Error on collection of data", MB_OK) ;
}
rise = rise * yspace ; //to set to scale
yintercept = yintercept * yspace ;
run = run * xspace ;
ystart = ( rise / run) + yintercept ; //to figure points of line
yend = ( rise / run) * 440 + yintercept ;
xstart = ( rise / run) + yintercept ;
xend = ( rise / run) * 360 + yintercept ;
SelectObject (drawinghdc, GetStockObject (BLACK_PEN)) ; //select pen for line
movecheck = MoveToEx(drawinghdc, xstart, ystart, NULL) ; //draw move to starting point
if ( movecheck == 0){
MessageBox(hwnd, "Move was not completed correctly. Please report this", "MoveToEx was not completed correctly", MB_OK) ;
}
linecheck = LineTo(drawinghdc, xend, yend) ; //draw line to end point
if ( linecheck == 0){
MessageBox (hwnd, "LineTo was not completed correctly. Please report this", "LineTp was not completed correctly", MB_OK) ;
}
BitBlt(memhdc, 0, 0, clientWidth, clientHeight, drawinghdc, 0, 0, SRCCOPY) ;
SendMessage(hwnd, WM_PAINT, 0, 0) ;
ReleaseDC(hwnd, drawinghdc) ;
This is my WM_PAINT response:
Code:
GetUpdateRect(hwnd, &theRect, 0);
if (IsRectEmpty(&theRect))
{
GetClientRect(hwnd,&theRect);
}
hdc = BeginPaint (hwnd, &ps) ;
BitBlt(undohdc, 0, 0, clientWidth, clientHeight, hdc, 0, 0, SRCCOPY) ;
MarksDrawing(memhdc) ;
AxisDrawing(memhdc) ;
BitBlt(hdc, 0, 0, clientWidth, clientHeight, memhdc, 0, 0, SRCCOPY) ;
EndPaint (hwnd, &ps) ;
break ;
The MarksDrawing and Axis drawings work fine so you dont need to see them. I can draw other shapes with out problem.
The code to draw a user defined circle is below to compare:
Code:
EndDialog (hDlg, 0) ;
drawinghdc = GetDC(hwnd) ;
YPointCheck = GetDlgItemText(hDlg,104, ycentst, 10) ; //collect infomation
ycent = atoi(ycentst) ;
XPointCheck = GetDlgItemText(hDlg, 103, xcentst , 10) ;
xcent = atoi(xcentst) ;
rad = GetDlgItemInt(hDlg, 102, &RadCheck, FALSE) ;
if(YPointCheck == 0){ //check for completion
MessageBox(hwnd, "PointY was not collected correctly", "Error on collection of data", MB_OK) ;
}
if(XPointCheck == 0){
MessageBox(hwnd, "PointX was not collected correctly", "Error on collection of data", MB_OK) ;
}
if(RadCheck == FALSE){
MessageBox(hwnd, "Radius was not collected correctly", "Error on collection of data", MB_OK) ;
}
ycenter = ycent * yspace ;
xcenter = xcent * xspace ;
xrad = rad * xspace ;
yrad = rad * yspace ;
if (xcenter > 0){ //to sepates quadrants correctly
xcenter = xcenter + (cxClient/2) ;
}
if (xcenter < 0){
xcenter = xcenter + (cxClient/2) ;
}
if (ycenter > 0){
ycenter = -ycenter + (cyClient/2) ;
}
if (ycenter < 0){
ycenter = -(2 * ycenter) + ycenter + (cyClient/2) ;
}
SelectObject (drawinghdc, GetStockObject (NULL_BRUSH)) ;
SelectObject (drawinghdc, GetStockObject (BLACK_PEN)) ;
Ellipse(drawinghdc, xcenter - xrad, ycenter + yrad, xcenter + xrad, ycenter - yrad) ; // draw point with radius of what you add or sumbtract
BitBlt(memhdc, 0, 0, clientWidth, clientHeight, drawinghdc, 0, 0, SRCCOPY) ;
SendMessage(hwnd, WM_PAINT, 0, 0) ;
ReleaseDC(hwnd, drawinghdc) ;
return TRUE ;
Im sorry I posted so much code but everytime I post people ask for more code so I figured I would give you all the code that could possibly be the problem. I have tried for weeks to get this and have failed. And yes, CyClient, CxClient, xspace, all the HDC s, and yspace are all initilized and set correctly. The Circle code works fine but the line code doesnt draw anything.