Hello,
I have a problem. I'm trying to create an application, which shows a rectangle on a grid. The position of the rectangle is subject to coordinates given from GPS simulator. The application is based on a single dialog window which involves a Picture Control. I set a type of that as Owner Draw. Then I created a class CPict, based on CStatic. CPict involves the OnPaint() method. Then I created a control variable of Picture Control. It's a CPict type variable named m_pict. In the class CGPSDlg there is the OnRead() method. To invoke that method, the user have to click a button. My question is: how to refresh the content of the Picture Control in OnRead() method. Here's some code:
Code:void CGPSDlg::OnRead() { CComPort* pComPort = new CComPort(g_sComPort); if (pComPort->Initialize()) { pComPort->Read(m_sResults); m_sLatitude = m_sResults; m_sLatitude.Delete(0,19); m_sLatitude.Delete(2,50); m_nLatitude = atoi(m_sLatitude); pComPort->Terminate(); } else { m_sResults = "Setup failed"; } UpdateData(FALSE); }Code:void CPict::OnPaint() { CPaintDC dc(this); CDC mdc; mdc.CreateCompatibleDC(&dc); CBitmap mBitmap; CBitmap* pOldMap; mBitmap.CreateCompatibleBitmap(&dc,360,180); pOldMap = mdc.SelectObject(&mBitmap); CBrush* pOldBrush; CPen* pOldPen; CBrush aWhiteBrush; aWhiteBrush.CreateSolidBrush(RGB(255,0,0)); CPen BlackPen(PS_SOLID,1,RGB(255,255,255)); pOldPen = mdc.SelectObject(&BlackPen); pOldBrush = mdc.SelectObject(&aWhiteBrush); mdc.SetMapMode(MM_ANISOTROPIC); CGPSDlg m_bridge; y=m_bridge.m_nLatitude; for(int i=1;i<36;i++){ mdc.MoveTo(i*10,0); mdc.LineTo(i*10,180);} for(int i=1;i<18;i++){ mdc.MoveTo(0,i*10); mdc.LineTo(360,i*10);} CString str; str = m_bridge.m_sResults; mdc.Rectangle(10,y-3,16,y+3); mdc.TextOutA(10,10,str); dc.BitBlt(0,0,500,360,&mdc,0,0,SRCCOPY); }




Reply With Quote
