End Google Ads 201810 - BS.net 01 -->
Hi all,
I write a MFC program that will execute a drawing circle in another thread when I click on somewhere in client area and I got it.
My problem is when I click various time (and quickly) it sometime gives me an "Assertion Failed" error.
here is my code:
void CGSimView::OnLButtonDown(UINT nFlags, CPoint point)
{
...
DCPOINT info;
PTPOINT3D currentPoint = pDoc->m_graph.GetNode(point.x,point.y);
if(currentPoint != NULL)
{
this->m_nodeIndex = currentPoint->index;
info.hwnd = this->GetSafeHwnd();
this->GetClientRect(&info.rect);
info.point = currentPoint;
AfxBeginThread(onGetFocus,&info);
}
CView::OnLButtonDown(nFlags, point);
}
UINT onGetFocus(LPVOID param)
{
DCPOINT *info = (DCPOINT*)param;
HDC hdc = GetDC(info->hwnd);
PTPOINT3D p = info->point;
int i, temp;
CRect rect = info->rect;
HPEN hPen, hOldPen;
hPen = CreatePen(PS_SOLID,1,RGB(225,0,0));
hOldPen = (HPEN)SelectObject(hdc, hPen);
for(i=0;ix - temp,p->y - temp,p->x + temp, p->y + temp);
Sleep(10);
}
SelectObject(hdc, hOldPen);
DeleteObject(hPen);
return 0;
}
please help me to solve this.
Thank in advance.
مواقع النشر (المفضلة)