Original Post
Ok so I''m writeing a editor for my game. Basicly it''s a SDI version of Worldcraft.
When writeing the grid moving code I encountered a problem. Here is the source for it.
NOTE: My grid only consists of a X and Z axis right now.
I found that after a certain amount of times I Invalidate the view.. I get...
Warning: Uncaught exception in WindowProc (returning 0).
First-chance exception in VistaEditor.exe (MSVCRTD.DLL): 0xE06D7363: Microsoft C++ Exception.
Then the grid dissapears.
I scrapped the application once before because of this problem. I can''t seem to find the problem
void CVistaEditorView::OnDraw(CDC* pDC)
{
CVistaEditorDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
CPen penGrid(PS_SOLID,1, RGB(0x00,0x00,0x00));
pDC->SelectObject(&penGrid);
//Fix out of View Grids.
pDC->MoveTo(((m_iSizeX / 2) - m_lCenterX), 0);
pDC->LineTo(((m_iSizeX / 2) - m_lCenterX), m_iSizeY);
pDC->MoveTo( 0, ((m_iSizeY / 2) + m_lCenterZ));
pDC->LineTo( m_iSizeX, ((m_iSizeY / 2) + m_lCenterZ));
}
void CVistaEditorView::OnRButtonUp(UINT nFlags, CPoint point)
{
m_bRightDown = false;
CView::OnRButtonUp(nFlags, point);
}
void CVistaEditorView::OnRButtonDown(UINT nFlags, CPoint point)
{
m_bRightDown = true;
CView::OnRButtonDown(nFlags, point);
}
void CVistaEditorView::OnSize(UINT nType, int cx, int cy)
{
m_iSizeX = cx;
m_iSizeY = cy;
CView::OnSize(nType, cx, cy);
}
void CVistaEditorView::OnMouseMove(UINT nFlags, CPoint point)
{
if(m_bLeftDown == true && m_bRightDown == true)
{
m_lCenterX = m_lCenterX + (m_pntMouseLast.x - point.x);
m_lCenterZ = m_lCenterZ - (m_pntMouseLast.y - point.y);
Invalidate(TRUE);
}
m_pntMouseLast = point;
CView::OnMouseMove(nFlags, point);
}
void CVistaEditorView::OnLButtonUp(UINT nFlags, CPoint point)
{
m_bLeftDown = false;
CView::OnLButtonUp(nFlags, point);
}
void CVistaEditorView::OnLButtonDown(UINT nFlags, CPoint point)
{
m_bLeftDown = true;
CView::OnLButtonDown(nFlags, point);
}
|