void DoPaint() { RECT rcClient = { 0 }; ::GetClientRect(m_hWnd, &rcClient); DWORD dwWidth = rcClient.right - rcClient.left; DWORD dwHeight = rcClient.bottom - rcClient.top; HDC hDcPaint = ::GetDC(m_hWnd); HDC hDcBackground = ::CreateCompatibleDC(hDcPaint); COLORREF* pBackgroundBits; HBITMAP hbmpBackground = CreateMyBitmap(hDcPaint, dwWidth, dwHeight, &pBackgroundBits); ::ZeroMemory(pBackgroundBits, dwWidth * dwHeight * 4); HBITMAP hOldBitmap = (HBITMAP)::SelectObject(hDcBackground, hbmpBackground); SetBkMode(hDcBackground, OPAQUE); m_pm.GetRoot()->SetPos(rcClient); m_pm.GetRoot()->DoPaint(hDcBackground, rcClient); PaintArrow(hDcBackground, rcClient); ResetAlpha((BYTE*)pBackgroundBits, dwWidth, dwHeight); RECT rcWnd = { 0 }; ::GetWindowRect(m_hWnd, &rcWnd); BLENDFUNCTION bf = { AC_SRC_OVER, 0, 255, AC_SRC_ALPHA }; POINT ptPos = { rcWnd.left, rcWnd.top }; SIZE sizeWnd = { dwWidth, dwHeight }; POINT ptSrc = { 0, 0 }; UpdateLayeredWindow(m_hWnd, hDcPaint, &ptPos, &sizeWnd, hDcBackground, &ptSrc, 0, &bf, ULW_ALPHA); ::SelectObject(hDcBackground, hOldBitmap); if (hDcBackground != NULL) ::DeleteDC(hDcBackground); if (hbmpBackground != NULL) ::DeleteObject(hbmpBackground); ::ReleaseDC(m_hWnd, hDcPaint); }
void TVizMapContext::PaintLinks(PGks Gks) { int Links = VizMapFrame->GetLinks(); //InfoNotify(TStr::Fmt("Links %d", Links)); TFltRect ZoomRect = GetZoomRect(); for (int LinkN = 0; LinkN < Links; LinkN++) { PVizMapLink Link = VizMapFrame->GetLink(LinkN); //if (!SelPointV.IsInBin(Link->GetSrcPointN()) && // !SelPointV.IsInBin(Link->GetDstPointN())) { continue; } // get link coordinates PVizMapPoint SrcPoint = VizMapFrame->GetPoint(Link->GetSrcPointN()); PVizMapPoint DstPoint = VizMapFrame->GetPoint(Link->GetDstPointN()); const double SrcPointX = SrcPoint->GetPointX(), SrcPointY = SrcPoint->GetPointY(); const double DstPointX = DstPoint->GetPointX(), DstPointY = DstPoint->GetPointY(); //TODO: check if link crosses ZoomRect // get coordinates in pixels const int SrcX = GetScreenCoord(SrcPointX, ZoomRect.GetMnX(), ZoomRect.GetXLen(), Gks->GetWidth()); const int SrcY = GetScreenCoord(SrcPointY, ZoomRect.GetMnY(), ZoomRect.GetYLen(), Gks->GetHeight()); const int DstX = GetScreenCoord(DstPointX, ZoomRect.GetMnX(), ZoomRect.GetXLen(), Gks->GetWidth()); const int DstY = GetScreenCoord(DstPointY, ZoomRect.GetMnY(), ZoomRect.GetYLen(), Gks->GetHeight()); // draw arrow PaintArrow(Gks, SrcX, SrcY, DstX, DstY, 3); } }