///////////////////////////////////////////////////////////////////////////// // CMultiColorPlotCtrl message handlers void CMultiColorPlotCtrl::OnPaint() { CPaintDC dc(this); // device context for painting // TODO: Add your message handler code here // 获得控件区域 GetClientRect (&m_rectCtrl); // 创建内存 DC CMemDC *pMemDC = new CMemDC(&dc, &m_rectCtrl); CPoint orgBrushOrigin = pMemDC->GetBrushOrg () ; if(m_dcBackground.GetSafeHdc() == NULL || m_pBitmapBackground.m_hObject == NULL) { m_dcBackground.CreateCompatibleDC(&dc); m_pBitmapBackground.CreateCompatibleBitmap(&dc, m_rectCtrl.Width(),m_rectCtrl.Height()) ; m_pBitmapOldBackground = m_dcBackground.SelectObject(&m_pBitmapBackground) ; InitColorPlot(&m_dcBackground); } pMemDC->BitBlt(0, 0, m_rectCtrl.Width(), m_rectCtrl.Height(), &m_dcBackground, 0, 0, SRCCOPY) ; //画曲线背景和网格 DrawBackGroundGrid(pMemDC); //画曲线数据 DrawValue(pMemDC); //画曲线Y刻度 DrawAxisScaleYValue(pMemDC); pMemDC->SetBrushOrg ( orgBrushOrigin.x , orgBrushOrigin.y ) ; delete pMemDC ; // Do not call CStatic::OnPaint() for painting messages }
//控件绘制事件处理方法 void CLedCtrl::OnPaint() { // TODO: Add your message handler code here // Do not call CStatic::OnPaint() for painting messages GetClientRect(&m_recClient); CPaintDC dc(this); CMemDC memDC(&dc, m_recClient); CMemDC* pDC = &memDC; CRect clip; pDC->GetClipBox(&clip); pDC->FillSolidRect(&m_recClient, m_crColorBackground ); for (int nCount = 0; nCount< m_strNumber.GetLength(); nCount++) { if (m_bDrawFadedNotches) Draw( pDC, STCOUNTERALL, nCount ); // Draw the faded bits //CString str = m_strNumber[nCount]; if ( m_strNumber[nCount] == _T('0') ) Draw( pDC, STCOUNTER0, nCount ); else if ( m_strNumber[nCount] == _T('1') ) Draw( pDC, STCOUNTER1, nCount ); else if ( m_strNumber[nCount] == _T('2') ) Draw( pDC, STCOUNTER2, nCount ); else if ( m_strNumber[nCount] == _T('3') ) Draw( pDC, STCOUNTER3, nCount ); else if ( m_strNumber[nCount] == _T('4') ) Draw( pDC, STCOUNTER4, nCount ); else if ( m_strNumber[nCount] == _T('5') ) Draw( pDC, STCOUNTER5, nCount ); else if ( m_strNumber[nCount] == _T('6') ) Draw( pDC, STCOUNTER6, nCount ); else if ( m_strNumber[nCount] == _T('7') ) Draw( pDC, STCOUNTER7, nCount ); else if ( m_strNumber[nCount] == _T('8') ) Draw( pDC, STCOUNTER8, nCount ); else if ( m_strNumber[nCount] == _T('9') ) Draw( pDC, STCOUNTER9, nCount ); else if ( m_strNumber[nCount] == _T('-') ) Draw( pDC, STCOUNTER10, nCount ); else if ( m_strNumber[nCount] == _T(':') ) Draw( pDC, STCOUNTER11, nCount ); } }
void CMSMoneyDemoView::OnDraw(CDC* pDCView) { CMemDC memDC (*pDCView, this); CDC* pDC = &memDC.GetDC (); CRect rectClient; GetClientRect (rectClient); pDC->FillSolidRect (rectClient, RGB (255, 255, 255)); pDC->DrawState (CPoint (20, 20), m_sizeImage, &m_Image, DSS_NORMAL); }
void CScreenViewWnd::OnLButtonDblClk(UINT nFlags, CPoint point) { CDialog::OnLButtonDblClk(nFlags, point); if (!valid_camera(_selectCamera)) { return; } _sync_drawing.Lock(); _frameQueue.clear(); // frame_buffer clear CClientDC dc(this); CMemDC MemDC; MemDC.CreateDC(&dc, &_bmpCanvas); MemDC->FillSolidRect(_rectScreen, RGB(0, 0, 0)); MemDC.DeleteDC(); UINT32 cameraList = 0; if (_fuse1x1Mode == false) { // 1x1 mode setting _fuse1x1Mode = true; setScreenLayout(ScreenFormatter::LAYOUT_1X1, _selectCamera, _rectScreen); // watch for only selected camera cameraList |= 1 << _selectCamera; } else { _fuse1x1Mode = false; setScreenLayout(_countLiveCamera); for (int i = 0; i < _countLiveCamera; ++i) { CameraView& rcamera = _cameraView[i]; if (rcamera.is_visible()) { cameraList |= 1 << i; } } } _sync_drawing.Unlock(); CWnd* lpParent = GetParent(); if (lpParent != NULL && lpParent->GetSafeHwnd()) { lpParent->PostMessage(UM_SCREEN_DBLCLICK, static_cast<WPARAM>(cameraList), static_cast<LPARAM>(MAX_CAMERA_COUNTS)); } Invalidate(FALSE); }
BOOL CScreenViewWnd::OnEraseBkgnd(CDC* pDC) { CRect rctClip; CMemDC MemDC; MemDC.CreateDC(pDC, &_bmpCanvas); pDC->GetClipBox(rctClip); pDC->BitBlt(rctClip.left, rctClip.top, rctClip.Width(), rctClip.Height(), &MemDC, rctClip.left, rctClip.top, SRCCOPY); return TRUE; }
void CScreenViewWnd::OnPaint() { CRect rctClip, rctClient, rctDraw; { CPaintDC dc(this); dc.GetClipBox(rctClip); } GetClientRect(rctClient); rctClip.InflateRect(100, 100); rctDraw.IntersectRect(rctClip, rctClient); ASSERT(_bmpCanvas.GetSafeHandle() != NULL); CDC* pDC = GetDC(); CMemDC MemDC; MemDC.CreateDC(pDC, &_bmpCanvas); _sync_drawing.Lock(); if (_fuse1x1Mode == false) { COLORREF clrBorder; for (int i = 0; i < _countCamera; i++) { if (!_cameraView[i].is_visible()) { continue; } clrBorder = (_selectCamera == i) ? RGB(0, 255, 0) : RGB(255, 255, 255); MemDC->Draw3dRect(_cameraView[i].rect(), clrBorder, clrBorder); } } else { MemDC->Draw3dRect(_cameraView[_selectCamera].rect(), RGB(0, 255, 0), RGB(0, 255, 0)); } _sync_drawing.Unlock(); pDC->BitBlt(rctDraw.left, rctDraw.top, rctDraw.Width(), rctDraw.Height(), &MemDC, rctDraw.left, rctDraw.top, SRCCOPY); ReleaseDC(pDC); pDC = NULL; }
bool CScreenViewWnd::drawReferImage() { CDC* parentDC = GetDC(); CMemDC MemDC; ASSERT(_bmpReferCanvas.m_hObject); MemDC.CreateDC(parentDC, &_bmpReferCanvas); CDC* pDC = &MemDC; pDC->PatBlt(0, 0, _imageWidth, _imageHeight, WHITENESS); if (_shapeManager) { Gdiplus::Graphics graphics(*pDC); _shapeManager->fillAllShapes(&graphics); } return true; }
void CHTMLListCtrl::OnPaint() { //AFX_MANAGE_STATE(AfxGetStaticModuleState()); // device context for painting CPaintDC dc(this); CMemDC* pDC = new CMemDC(&dc); CFont *pOldFont = pDC->SelectObject(&m_font); CRect rcWnd; GetClientRect(&rcWnd); CRect rcItem = rcWnd; rcItem.bottom = 0; int nScrollPos = GetScrollPos(SB_VERT); rcItem.OffsetRect(0,-nScrollPos); POSITION pos = m_listItems.GetHeadPosition(); for(int i = 0;i < m_listItems.GetCount();i++) { HTMLLIST_ITEM *pItem = m_listItems.GetNext(pos); //Create the bounding rect for item rcItem.bottom = rcItem.top + pItem->nHeight; if(i == m_nSelectedItem) { DrawItem(pDC,rcItem,pItem,TRUE); } else { DrawItem(pDC,rcItem,pItem,FALSE); } pItem->rcItem = rcItem; //Move rcItem to next item rcItem.OffsetRect(0,pItem->nHeight); } pDC->SelectObject(pOldFont); SAFE_DELETE(pDC); //SAFE_DELETE(dc); }
void CScreenViewWnd::clearScreen() { _sync_drawing.Lock(); for (int i = 0; i < _countCamera; i++) { _cameraView[i].resetCamera(); } _selectCamera = -1; _countLiveCamera = __min(_countCamera, 16); CDC* pDC = GetDC(); CMemDC MemDC; MemDC.CreateDC(pDC, &_bmpCanvas); MemDC->FillSolidRect(_rectScreen, RGB(0, 0, 0)); MemDC.DeleteDC(); ReleaseDC(pDC); _sync_drawing.Unlock(); Invalidate(TRUE); }
void CKofProgressCtrl::OnPaint() { CPaintDC dc(this); // device context for painting CMemDC memDC (dc, this); CDC* pDC = &memDC.GetDC (); //if (!CMFCVisualManager::GetInstance()->OnFillParentBarBackground (this, pDC)) { afxGlobalData.DrawParentBackground (this, pDC); } CRect rect; GetClientRect (rect); CRect rectProgress = rect; rectProgress.DeflateRect (1, 1); int nMin = 0; int nMax = 0; GetRange (nMin, nMax); CRect rectChunk (0, 0, 0, 0); if (nMax > nMin) { rectChunk = rectProgress; rectChunk.right = rectChunk.left + GetPos () * rectChunk.Width () / (nMax - nMin); rectChunk.DeflateRect (1, 1); } CMFCRibbonProgressBar dummy; CKofStyleHelper::GetInstance()->OnDrawRibbonProgressBar( pDC, &dummy, rectProgress, rectChunk, FALSE); }
void CScreenViewWnd::updateStatus(int camera) { if (GetSafeHwnd() == NULL) { return; } _sync_drawing.Lock(); if (_fuse1x1Mode == true && _selectCamera != camera) { _sync_drawing.Unlock(); return; } if (!_cameraView[camera].is_visible()) { _sync_drawing.Unlock(); return; } int camstatus = getCameraState(camera); CClientDC dc(this); CMemDC MemDC; MemDC.CreateDC(&dc, &_bmpCanvas); const CRect& rctcamera = _cameraView[camera].rect(); if (camstatus != CameraView::ENABLED) { MemDC->FillSolidRect(rctcamera, (camstatus == CameraView::NO_VIDEO) ? RGB(0, 0, 255) : RGB(0, 0, 0)); } CString strStatus = _T(""); switch (camstatus) { case CameraView::NO_VIDEO : strStatus = _T("No Video"); break; case CameraView::NOT_CONNECTED: strStatus = _T("Not Connected"); break; case CameraView::COVERT_LEVEL1 : strStatus = _T("Covert"); break; case CameraView::COVERT_LEVEL2 : strStatus = _T(""); break; } CRect rctosd = rctcamera; rctosd.DeflateRect(5, 2, 5, 3); CFont* lpFontPrev = MemDC->SelectObject(&_fontText); drawText(&MemDC, strStatus, rctosd, DT_CENTER | DT_VCENTER | DT_SINGLELINE); drawText(&MemDC, getCameraTitle(camera), rctosd, DT_LEFT | DT_TOP | DT_SINGLELINE); MemDC->SelectObject(lpFontPrev); MemDC->Draw3dRect(rctcamera, RGB(255, 255, 255), RGB(255, 255, 255)); dc.BitBlt(rctcamera.left, rctcamera.top, rctcamera.Width(), rctcamera.Height(), &MemDC, rctcamera.left, rctcamera.top, SRCCOPY); _sync_drawing.Unlock(); }
void CScreenViewWnd::drawImage(int camera, LPBYTE pImage, const CSize& size, SDK_TIME_T time) { CameraView& rcamView = _cameraView[camera]; _sync_drawing.Lock(); if (!rcamView.is_visible() || !rcamView.is_enable()) { _sync_drawing.Unlock(); return; } _bmpInfohead.biWidth = size.cx; _bmpInfohead.biHeight = size.cy; _bmpInfohead.biSizeImage = size.cx * size.cy * _bmpInfohead.biBitCount >> 3; CDC* pDC = GetDC(); if ((size.cx > 0) && (size.cy > 0)) { CMemDC MemDC; ASSERT(_bmpCanvas.m_hObject); MemDC.CreateDC(pDC, &_bmpCanvas); CRect rctDest = rcamView.rect(); CRect rctImage = rctDest; if (_fuseAspectRatio) { imageAspectRatio(size.cx, size.cy, rctImage, rctImage); if (rcamView.rectImage() != rctImage) { MemDC->FillSolidRect(rctDest, RGB(0, 0, 0)); } else { const int letter_t = rctImage.top - rctDest.top; const int letter_b = rctDest.bottom - rctImage.bottom; const int letter_l = rctImage.left - rctDest.left; const int letter_r = rctDest.right - rctImage.right; if (letter_t > 1 || letter_b > 1 || letter_l > 1 || letter_r > 1) { if (letter_t > 0) { MemDC->FillSolidRect(rctDest.left + 1, rctDest.top, rctDest.Width() - 2, letter_t, RGB(0, 0, 0)); } if (letter_b > 0) { MemDC->FillSolidRect(rctDest.left + 1, rctImage.bottom, rctDest.Width() - 2, letter_b, RGB(0, 0, 0)); } if (letter_l > 0) { MemDC->FillSolidRect(rctDest.left + 1, rctImage.top, letter_l, rctImage.Height(), RGB(0, 0, 0)); } if (letter_r > 0) { MemDC->FillSolidRect(rctImage.right, rctImage.top, letter_r, rctImage.Height(), RGB(0, 0, 0)); } } } } rcamView.setRectImage(rctImage); ::DrawDibDraw(_hDrawDib, MemDC, rctImage.left, rctImage.top, rctImage.Width(), rctImage.Height(), &_bmpInfohead, pImage, 0, 0, size.cx, size.cy, 0); drawReferLines(&MemDC); CRect rctOSD = rctDest; rctOSD.DeflateRect(5, 2, 5, 3); CTime tmFrame(time); CString strTime = (rctOSD.Width() < 140) ? tmFrame.Format(_T("%H:%M:%S")) : tmFrame.Format(_T("%y-%m-%d %H:%M:%S")); CString strTitle = getCameraTitle(camera); /* CFont* lpFontPrev = MemDC->SelectObject(&_fontText); drawText(&MemDC, strTitle, rctOSD, DT_TOP | DT_LEFT | DT_SINGLELINE); drawText(&MemDC, strTime, rctOSD, DT_BOTTOM | DT_CENTER | DT_SINGLELINE); MemDC->SelectObject(lpFontPrev); */ COLORREF clrBorder = (_selectCamera == camera) ? RGB(0, 255, 0) : RGB(255, 255, 255); MemDC->Draw3dRect(rctDest, clrBorder, clrBorder); pDC->BitBlt(rctDest.left, rctDest.top, rctDest.Width(), rctDest.Height(), &MemDC, rctDest.left, rctDest.top, SRCCOPY); } ReleaseDC(pDC); _sync_drawing.Unlock(); }