At the beginning, sorry about my English.
I'm now learning how to build a MFC application in visual studio 2015. I'm using Direct2D to draw lines in a window.
When left button is down, my OnLbuttonDown() function is called:
void CMyProjectNameView::OnLButtonDown(UINT nFlags, CPoint point)
{
startPoint = point; // start point of the line, a gloable variable.
pRenderTarget->BeginDraw();
CView::OnLButtonDown(nFlags, point);
}
When left button is up, my OnLButtonUp() function is called:
void CMyProjectNameView::OnLButtonUp(UINT nFlags, CPoint point)
{
pRenderTarget->DrawLine(startPoint, point, m_pbrush, 1.0f); // draw the line
pRenderTarget->EndDraw();
CView::OnLButtonUp(nFlags, point);
}
So it will draw a line in the window when I drag my mouse, and it works fine yesterday.
The problem is when I run it today, it suddenly become abnormal. The start point coordinates and end point coordinates is two times bigger than before. So When I draw the line, the line shows on the bottom right position compared to the position it supposed to be.
For instance, if I draw a line from (100,100) to (500,500), a line start from (100,100) to (500,500) will appear on screen, but when I click left button of my mouse at (100,100), move it to (500,500) and release left button, a line from (200,200) to (1000,1000) will be drawn.
OnLButtonDown(UINT nFlags, CPoint point)
OnLButtonUp(UINT nFlags, CPoint point)
So basically, these two point above is scaled before they are passed in. Do I accidentally change any configurations? Is there any way to fix this? I am sure I didn't change my code.
SetTransform()- David ThomasCDC::DPToLPandCDC::LPToDPmethods). I have seen a page — d.hatena.ne.jp/sugarontop/20121006 — unfortunately it is not in English, that may have some info for you. - sergiol