I'm trying to create a separate object from my program ('trackerObj.h') which I can use in my main window.
I want to be able to draw a rectangle for each new trackerObj.
For example,
my trackObj class is:Code:void CVisualAuidoView::OnLButtonDown(UINT nFlags, CPoint point) { trackObj *mytrack = new trackObj(); }
Code:#pragma once #include "stdafx.h" class trackObj : public CObject { public: //Construction trackObj(); public: //Attributes CRectTracker m_tracker; protected: CWnd* m_pWnd; public: //Operations void drawMyTracker(int t); public: //Implementation virtual ~trackObj(); }; trackObj::trackObj() { int t = 60; drawMyTracker(t); } trackObj::~trackObj() { } void trackObj::drawMyTracker(int t) { CClientDC dc(m_pWnd); CClientDC* pDC=&dc; pDC->MoveTo(t, 20); pDC->LineTo(60, 122); pDC->LineTo(264, 122); }
The program starts to run, but then gives me a dialog which says:
Could someone give me a hand with drawing from other classes - I can't make an OnDraw method so no idea how to go about this!Code:Unhandled exception at 0x009a1c39 in VisualAuido.exe: 0xC0000005: Access violation reading location 0xcdcdcded.
Cheers
Gareth




Reply With Quote