void CWndMapPartsAnimeList::OnPaint() { int x, cx, cy; HDC hDC; CDC DCTmp; CRect rc, rcTmp; CRgn rgn; CPaintDC dc(this); hDC = m_pImgParts->Lock (); DCTmp.Attach (hDC); GetClientRect (rc); rgn.CreateRectRgn (0, 0, rc.Width (), rc.Height ()); dc.SelectClipRgn (&rgn, RGN_COPY); x = GetScrollPos (SB_HORZ); cx = min (rc.Width (), m_pImgParts->Width ()); cy = min (rc.Height (), m_pImgParts->Height ()); dc.FillSolidRect (rc, RGB (128, 128, 128)); dc.BitBlt (0, 0, cx, cy, &DCTmp, x * 16, 0, SRCCOPY); m_pImgParts->Unlock (); DCTmp.Detach (); }
void CStaticMapShadow::OnPaint() { int x, y, cy; HDC hDC; CDC DCTmp; CRect rc, rcTmp; CRgn rgn; CPaintDC dc(this); hDC = m_pImgShadow->Lock (); DCTmp.Attach (hDC); GetWindowRect (rc); rgn.CreateRectRgn (0, 0, rc.Width (), rc.Height ()); dc.SelectClipRgn (&rgn, RGN_COPY); ScreenToClient (rc); cy = min (rc.Height (), m_pImgShadow->Height ()); dc.BitBlt (0, 0, m_pImgShadow->Width (), cy, &DCTmp, 0, 0, SRCCOPY); x = m_ptCursor.x * 16; y = (m_ptCursor.y - m_nPos) * 16; cy = y + 15; cy = min (cy, rc.Height ()); rcTmp.SetRect (x, y, x + 15, cy); dc.DrawEdge (rcTmp, EDGE_BUMP, BF_FLAT | BF_RECT); m_pImgShadow->Unlock (); DCTmp.Detach (); }
//绘制窗口边框 void CDBFrame::DrawBorder(CDC *pDC) { CRect rcWindow; GetWindowRect(&rcWindow); rcWindow.OffsetRect(-rcWindow.left, -rcWindow.top); int iCaptionHeight = m_rcSysBorder.top + m_imageCaption.Height(); m_imageBorders[LEFT].Render(pDC, CPoint(0, iCaptionHeight), CSize(m_rcSysBorder.left, rcWindow.Height() - iCaptionHeight)); m_imageBorders[RIGHT].Render(pDC, CPoint(rcWindow.Width() - m_rcSysBorder.right, iCaptionHeight), CSize(m_rcSysBorder.right, rcWindow.Height() - iCaptionHeight)); m_imageBorders[BOTTOM].Render(pDC, CPoint(0, rcWindow.Height() - m_rcSysBorder.bottom), CSize(rcWindow.Width(), m_rcSysBorder.bottom)); CRgn rgn; CRect rcWnd; GetWindowRect(rcWnd); rcWnd.OffsetRect(-rcWnd.left, -rcWnd.top); rgn.CreateRoundRectRgn(rcWnd.left, rcWnd.top, rcWnd.right, rcWnd.bottom, 2,2); CBrush brush; brush.CreateSolidBrush(RGB(171,186,227)); pDC->FrameRgn(&rgn, &brush, 1,1); }
void CInspectorTreeCtrl::OnPaint() { CPaintDC dc(this); CPropertyInspector * parent = static_cast <CPropertyInspector *> (GetParent()); CRect rcClip; dc.GetClipBox( &rcClip ); rcClip.right = getColumnWidth(0); CRgn rgn; rgn.CreateRectRgnIndirect( &rcClip ); dc.SelectClipRgn(&rgn); CWnd::DefWindowProc(WM_PAINT, reinterpret_cast <WPARAM> (dc.m_hDC), 0); // let CTreeCtrl paint as normal rgn.DeleteObject(); rcClip.right += parent->getColumnWidth(1); rgn.CreateRectRgnIndirect( &rcClip ); dc.SelectClipRgn(&rgn); drawValues(dc); rgn.DeleteObject(); }
/// <param name="list">list of points</param> /// <param name="count">number of points</param> /// <param name="width">pen width for drawing line</param> /// <param name="color">pen color</param> /// <param name="fill">polygon fill color</param> void Canvas::DrawPolygon(const rect_t &rect, const rect_t &box, point_t list[], size_t count, meter_t width, color_t color, color_t fill) { CPen pen; CBrush brush; std::vector<POINT> pts; POINT pt = {0}; for (size_t i = 0; i < count; i++) { pt.x = list[i].x - box.x + rect.x; pt.y = list[i].y - box.y + rect.y; pts.push_back(pt); } CRgn region; region.CreateRectRgn(rect.x, rect.y, rect.x + rect.wide, rect.y + rect.high); SelectClipRgn(region); brush.CreateSolidBrush(fill); pen.CreatePen(PS_SOLID, width, color); HPEN hSavePen = SelectPen(pen); HBRUSH hSaveBrush = SelectBrush(brush); Polygon(&pts[0], pts.size()); SelectPen(hSavePen); SelectBrush(hSaveBrush); SelectClipRgn(NULL); }
HBRUSH CIconEditEx::CtlColor(CDC* pDC, UINT nCtlColor) { HBRUSH hbr; hbr = (HBRUSH)m_brBkgnd; // Passing a Handle to the Brush CRect rcClient; GetClientRect(&rcClient); if (m_progressValue > 0.0) { CRect rc; GetRect(&rc); pDC->FillSolidRect(&rc, m_colors[COL_Bk]); GetClientRect(&rc); CRgn rgn; rgn.CreateRectRgn(rc.left, rc.top, rc.right, rc.bottom); pDC->SelectClipRgn(&rgn, RGN_COPY); pDC->FillSolidRect(0, 0, INT(rc.Width() * m_progressValue), rc.Height(), m_colors[COL_Progress]); pDC->SetBkMode(TRANSPARENT); } //if (m_hIcon != NULL) //{ // CRgn rgn; // rgn.CreateRectRgn(cMargin, cMargin, cMargin + m_cx, cMargin + m_cy); // pDC->SelectClipRgn(&rgn, RGN_OR); // INT top = (rcClient.Height() - m_cy) / 2; // ::DrawIconEx(pDC->m_hDC, cMargin, top, m_hIcon, m_cx, m_cy, 0, NULL, DI_NORMAL ); //} //if (m_hClearIcon != NULL) //{ // INT top = (rcClient.Height() - m_cy) / 2; // ::DrawIconEx(pDC->m_hDC, cMargin, top, m_hIcon, m_cx, m_cy, 0, NULL, DI_NORMAL ); //} pDC->SetBkColor(m_colors[COL_Bk]); // Setting the Color of the Text Background to the one passed by the Dialog pDC->SetTextColor(m_colors[COL_Text]); // Setting the Text Color to the one Passed by the Dialog return hbr; }
void CEasySkinManager::OnSize( UINT nType, int cx, int cy ) { CEasySkinDialog::OnSize(nType, cx, cy); //移动准备 HDWP hDwp=BeginDeferWindowPos(64); UINT uFlags=SWP_NOACTIVATE|SWP_NOCOPYBITS|SWP_NOZORDER; if ( m_enWndStyle != en_Wnd_None ) { DeferWindowPos(hDwp,m_btClose,NULL,cx-41,0,0,0,uFlags|SWP_NOSIZE); if ( m_enWndStyle != en_Wnd_CloseBox ) { if( m_enWndStyle != en_Wnd_MinimizeBox ) DeferWindowPos(hDwp,m_btMax,NULL,cx-69,0,0,0,uFlags|SWP_NOSIZE); DeferWindowPos(hDwp,m_btMin,NULL,cx-69-(m_enWndStyle==en_Wnd_Normal?28:0),0,0,0,uFlags|SWP_NOSIZE); } } //结束调整 //LockWindowUpdate(); EndDeferWindowPos(hDwp); //UnlockWindowUpdate(); //设置圆角 CRgn rgn; rgn.CreateRoundRectRgn(0,0,cx,cy,4,4); SetWindowRgn(rgn,FALSE); //更新界面 Invalidate(FALSE); }
// rect must be in logical coordinates BOOL CDrawPoly::Intersects(const CRect& rect) { ASSERT_VALID(this); CRgn rgn; rgn.CreatePolygonRgn(m_points, m_nPoints, ALTERNATE); return rgn.RectInRegion(rect); }
void CResizableLayout::ClipChildWindow(const CResizableLayout::LayoutInfo& layout, CRgn* pRegion) { // obtain window position CRect rect; ::GetWindowRect(layout.hWnd, &rect); ::MapWindowPoints(NULL, GetResizableWnd()->m_hWnd, (LPPOINT)&rect, 2); // use window region if any CRgn rgn; rgn.CreateRectRgn(0,0,0,0); switch (::GetWindowRgn(layout.hWnd, rgn)) { case COMPLEXREGION: case SIMPLEREGION: rgn.OffsetRgn(rect.TopLeft()); break; default: rgn.SetRectRgn(&rect); } // get the clipping property BOOL bClipping = layout.properties.bAskClipping ? LikesClipping(layout) : layout.properties.bCachedLikesClipping; // modify region accordingly if (bClipping) pRegion->CombineRgn(pRegion, &rgn, RGN_DIFF); else pRegion->CombineRgn(pRegion, &rgn, RGN_OR); }
//创建区域 bool CRgnDialog::CreateControlRgn(COLORREF crTrans) { //加载资源 CImageHandle ImageHandle(&m_ImageBack); //创建区域 CRgn RgnControl; m_ImageBack.CreateImageRegion(RgnControl,crTrans); //设置窗口 if (RgnControl.GetSafeHandle()!=NULL) { //移动窗口 SetWindowRgn(RgnControl,TRUE); SetWindowPos(NULL,0,0,m_ImageBack.GetWidth(),m_ImageBack.GetHeight(),SWP_NOMOVE); //删除区域 m_DialogRgn.DeleteObject(); m_DialogRgn.Attach(RgnControl.Detach()); return true; } return false; }
BOOL CTyBase::PointRgn(float x, float y, int Numble, PointStruct *PointList, float blc) { CRgn rgn; int x1,y1,i; CPoint bbcc[MAXPOINTNUM]; if(Numble < 3) return 0;//如果点的数目<3即不是一个区域返回不成功标志 ASSERT(Numble <= MAXPOINTNUM); //将点的坐标转变成屏幕坐标 x1 = (int)(x/blc); y1 = (int)(y/blc); //将封闭区域各点的坐标转成屏幕坐标 for(i = 0;i < Numble;i++) { bbcc[i].x = (int)((PointList[i].x)/blc); bbcc[i].y = (int)((PointList[i].y)/blc); } rgn.CreatePolygonRgn(bbcc,Numble,1);//初试化一个多边形区域 i = (rgn.PtInRegion(x1,y1)!=0); //如果在区域内j=1,否则j=0; rgn.DeleteObject(); //删除定义的rgn对象 return i; }
bool CLine::RInR(LPCRECT lpRect) { if(m_lStatus!=ST_NOMAL) return false; POINT ptTmp[4]; if((m_lx1-m_lx2)*(m_ly1-m_ly2)>=0) { ptTmp[0].x=m_lx1-1; ptTmp[0].y=m_ly1+1; ptTmp[1].x=m_lx1+1; ptTmp[1].y=m_ly1-1; ptTmp[2].x=m_lx2+1; ptTmp[2].y=m_ly2-1; ptTmp[3].x=m_lx2-1; ptTmp[3].y=m_ly2+1; } else { ptTmp[0].x=m_lx1+1; ptTmp[0].y=m_ly1+1; ptTmp[1].x=m_lx1-1; ptTmp[1].y=m_ly1-1; ptTmp[2].x=m_lx2-1; ptTmp[2].y=m_ly2-1; ptTmp[3].x=m_lx2+1; ptTmp[3].y=m_ly2+1; } CRgn rgnTmp; if(rgnTmp.CreatePolygonRgn(ptTmp,4,ALTERNATE)) { if(rgnTmp.RectInRegion(lpRect)) return true; } return false; }
BOOL CBlendSelectWnd::DelItem(int nItem) { if (!m_wndListBox.DeleteItem(nItem)) return FALSE; // Resize int nListBoxHeight = m_wndListBox.GetListHeight(); m_dwHeight = m_dwMargin + m_dwTitleHeight + m_dwMargin + nListBoxHeight + m_dwMargin; CRgn CaptionRegion; CaptionRegion.CreateRoundRectRgn(0, 0, m_dwWidth, m_dwHeight, 10, 10); SetWindowRgn((HRGN)CaptionRegion.m_hObject, TRUE); int cxScreen = GetSystemMetrics(SM_CXSCREEN); int cyScreen = GetSystemMetrics(SM_CYSCREEN); SetWindowPos(NULL, 0, 0, m_dwWidth, m_dwHeight, SWP_NOMOVE | SWP_NOZORDER); // Set List Box Position int nBtnLeft = (m_hIcon == NULL) ? m_dwMargin : (m_dwMargin * 2 + 32); int nBtnWidth = (m_hIcon == NULL) ? (m_dwWidth - 2 * m_dwMargin) : (m_dwWidth - 3 * m_dwMargin - 32); int nButTop = 2 * m_dwMargin + m_dwTitleHeight; m_wndListBox.MoveWindow(nBtnLeft, nButTop, nBtnWidth, nListBoxHeight); Invalidate(); return TRUE; }
void CBCGPPlannerViewMulti::OnPaint (CDC* pDC, const CRect& rectClient) { ASSERT_VALID (pDC); OnDrawClient (pDC, m_rectApps); OnDrawAppointmentsDuration (pDC); if (m_nHeaderAllDayHeight != 0) { CRect rtHeader (m_rectApps); rtHeader.top -= m_nHeaderAllDayHeight; rtHeader.bottom = rtHeader.top + m_nHeaderAllDayHeight; OnDrawHeaderAllDay (pDC, rtHeader); CRgn rgn; rgn.CreateRectRgn (rtHeader.left, rtHeader.top, rtHeader.right, rtHeader.bottom); pDC->SelectClipRgn (&rgn); OnDrawAppointments (pDC, rtHeader); pDC->SelectClipRgn (NULL); } { CRgn rgn; rgn.CreateRectRgn (m_rectApps.left, m_rectApps.top, m_rectApps.right, m_rectApps.bottom); pDC->SelectClipRgn (&rgn); OnDrawAppointments (pDC, m_rectApps); pDC->SelectClipRgn (NULL); } if (!m_rectTimeBar.IsRectEmpty ()) { OnDrawTimeBar (pDC, m_rectTimeBar, IsCurrentTimeVisible ()); } OnDrawUpDownIcons (pDC); if (m_nHeaderHeight != 0) { CRect rtHeader (rectClient); rtHeader.left = m_rectApps.left; rtHeader.bottom = rtHeader.top + m_nHeaderHeight / 2; OnDrawHeader (pDC, rtHeader); rtHeader.top = rtHeader.bottom; rtHeader.bottom = rtHeader.top + m_nHeaderHeight / 2; OnDrawHeaderResource (pDC, rtHeader); } InitToolTipInfo (); }
////////////////////////////////////////////////////////////////////////// // 画透明异形图的函数 // 注:在这里特别感谢CSDN网友: 黄凯飞, ID: hkf314 void CAnimateButton::AlphaBitmap(int nItem) { CDC* pDC = GetDC(); CDC TmpDC; TmpDC.CreateCompatibleDC(pDC); //当然,TmpBmp用来记录画的内容 CBitmap TmpBmp; TmpBmp.CreateCompatibleBitmap(pDC, m_aniBtnWidth, m_aniBtnHeight); TmpDC.SelectObject(&TmpBmp); //把按钮下的背景拷贝过来 TmpDC.BitBlt(0, 0, m_aniBtnWidth, m_aniBtnHeight, pDC, 0, 0, SRCCOPY); //把内存DC中的图像透明地画出来 AlphaBlend(TmpDC.m_hDC, 0, 0, m_aniBtnWidth, m_aniBtnHeight, m_pMemDC->m_hDC, nItem * m_aniBtnWidth, 0, m_aniBtnWidth, m_aniBtnHeight, m_bf); //填充异形图像以外的区域为mask色 CRgn rgn; rgn.CreateRectRgn(0, 0, m_aniBtnWidth, m_aniBtnHeight); rgn.CombineRgn(&rgn, CRgn::FromHandle(m_arBmpRgn[nItem]), RGN_DIFF); // TRACE("CRgn::FromHandle(m_arBmpRgn[nItem]): %d\n", nItem); CBrush maskBrh; maskBrh.CreateSolidBrush(m_clrTrans); TmpDC.FillRgn(&rgn, &maskBrh); // TmpDC.FillRgn(CRgn::FromHandle(m_arBmpRgn[nItem]), &maskBrh); //抠除mask色,直接画出来 ::TransparentBlt(pDC->m_hDC, 0, 0, m_aniBtnWidth, m_aniBtnHeight, TmpDC.m_hDC, 0, 0, m_aniBtnWidth, m_aniBtnHeight, m_clrTrans); // pDC->BitBlt(0, 0, m_aniBtnWidth, m_aniBtnHeight, &TmpDC, 0, 0, SRCCOPY); // pDC->FillRgn(CRgn::FromHandle(m_arBmpRgn[nItem]), &maskBrh); ReleaseDC(pDC); }
BOOL CSkinBtn::OnEraseBkgnd(CDC* pDC) { // TODO: 在此添加消息处理程序代码和/或调用默认值 if(m_bRePain == FALSE) { if(!m_bDCStored) { CRect rect; GetClientRect(&rect); m_memDC.CreateCompatibleDC (pDC); CBitmap btScreen; btScreen.CreateCompatibleBitmap (pDC,rect.Width(),rect.Height()); m_memDC.SelectObject (&btScreen); m_memDC.BitBlt (0,0,rect.Width(),rect.Height(),pDC,0,0,SRCCOPY); m_bDCStored=true; CRgn rgn; rgn.CreateRectRgn (0, 0, rect.Width(), rect.Height()); SetWindowRgn (rgn, TRUE); btScreen.DeleteObject(); } } return TRUE;// CButton::OnEraseBkgnd(pDC);// }
BOOL CSkinButton::GetRegion() { CMyBitmap bmp; /* if ( hRgn ) { dc.SelectClipRgn(NULL); DeleteObject(hRgn); } HRGN hRgn = NULL; if ( m_res->m_bTrans ) { HRGN rgn; rgn = bmp.CreateRgnFromFile(RGB(255,0,255)); //strange, must after ClipRgn //SetWindowPos( NULL, 0, 0, bmp.Width(), bmp.Height(), SWP_NOZORDER | SWP_NOMOVE ); HRGN hRgn = CreateRectRgn(0, 0, 0, 0); SetWindowRgn( rgn, TRUE ); GetWindowRgn(hRgn); ::SelectClipRgn(dc.GetSafeHdc(), hRgn); } */ //DrawImage( bmp ); CRgn rgn; rgn.CreateEllipticRgn( 00, 00, 50, 50 ); SetWindowRgn((HRGN)rgn.Detach(), TRUE ); //SetWindowRgn(bmp.CreateRgnFromFile(RGB(255,0,255)), TRUE ); return TRUE; }
void CResizableLayout::EnumAndClipChildWindow(HWND hWnd, CDC* pDC) { // obtain window position CRect rect; ::GetWindowRect(hWnd, &rect); GetResizableWnd()->ScreenToClient(&rect); pDC->DPtoLP(&rect); // use window region if any CRgn rgn; rgn.CreateRectRgn(0,0,0,0); if (COMPLEXREGION == ::GetWindowRgn(hWnd, rgn)) { rgn.OffsetRgn(rect.TopLeft()); } else { rgn.SetRectRgn(&rect); } // go clipping? if (LikesClipping(hWnd)) pDC->SelectClipRgn(&rgn, RGN_DIFF); else pDC->SelectClipRgn(&rgn, RGN_OR); }
void CClock::DrawTime( CDC *pDc ) { CRect rtClient; GetClientRect(&rtClient); CDC dcTransparent; dcTransparent.CreateCompatibleDC(pDc); CBitmap bitTransParent; bitTransParent.CreateCompatibleBitmap(pDc, rtClient.Width(),rtClient.Height()); dcTransparent.SelectObject(&bitTransParent); // CRect rectReal(ix1, iy1, ix2, iy2); dcTransparent.FillSolidRect(rtClient, RGB(255, 255, 255)); // dcTransparent.Draw3dRect(rectReal, RGB(111, 147, 188), RGB(111, 147, 188)); dcTransparent.BeginPath(); dcTransparent.MoveTo(rtClient.Width()/2, rtClient.Height()/2); dcTransparent.LineTo(rtClient.Width()/2-80, rtClient.Height()/2); float fEnd = 90.0f; dcTransparent.AngleArc(rtClient.Width()/2, rtClient.Height()/2, 120, -180.0f, 270.0f); dcTransparent.LineTo(rtClient.Width()/2, rtClient.Height()/2); dcTransparent.EndPath(); CRgn rgn; rgn.CreateFromPath(&dcTransparent); dcTransparent.FillRgn(&rgn, &CBrush(RGB(188, 199, 216))); //内 dcTransparent.BeginPath(); dcTransparent.MoveTo(rtClient.Width()/2, rtClient.Height()/2); dcTransparent.LineTo(rtClient.Width()/2-40, rtClient.Height()/2); dcTransparent.AngleArc(rtClient.Width()/2, rtClient.Height()/2, 40, -180.0f, 270.0f); dcTransparent.LineTo(rtClient.Width()/2, rtClient.Height()/2); dcTransparent.EndPath(); CRgn rgn1; rgn1.CreateFromPath(&dcTransparent); dcTransparent.FillRgn(&rgn1, &CBrush(RGB(255, 255, 0))); if( ::AlphaBlend == 0 ) { pDc->StretchBlt(0, 0, rtClient.Width(), rtClient.Height(), &dcTransparent, 0, 0, rtClient.Width(), rtClient.Height(), SRCINVERT ); }else{ BLENDFUNCTION bf; memset( &bf, 0, sizeof( bf ) ); bf.SourceConstantAlpha = 0x9f; //半透明 bf.BlendOp = AC_SRC_OVER; ::TransparentBlt(pDc->GetSafeHdc(), 0, 0, rtClient.Width(), rtClient.Height(), dcTransparent.GetSafeHdc( ), 0, 0, rtClient.Width(), rtClient.Height(), RGB(255, 255, 255)); // ::AlphaBlend( memDC.GetSafeHdc(), 0, 0, rtClient.Width(), rtClient.Height(), // dcTransparent.GetSafeHdc( ), 0, 0, rtClient.Width(), rtClient.Height(), bf ); } bitTransParent.DeleteObject(); dcTransparent.DeleteDC(); }
void CFeedIcoItemListCtrl::DrawGroup(CDC & dcMem, const CRect & rectGroup, const CString & strGroupCaption, const CString & strGroupTotals) { CRgn rgnFrame;//画圆角矩形 rgnFrame.CreateRoundRectRgn( rectGroup.left, rectGroup.top, rectGroup.right, rectGroup.bottom, 3, 3 ); if (m_imageRss_GroupBg) { m_imageRss_GroupBg->Draw(dcMem.m_hDC, rectGroup.left, rectGroup.top, rectGroup.Width(), 24); } //CBrush* brushFrame; //brushFrame = new CBrush( GetSysColor(COLOR_GRAYTEXT) ); //dcMem.FrameRgn(&rgnFrame,brushFrame,1,1);//画焦点边框 //delete brushFrame; CRect rectCaption ( rectGroup.left + 7, rectGroup.top + 4, rectGroup.left + 40, rectGroup.bottom - 3 ) ; dcMem.SetTextColor( RGB(0,0,0) ); dcMem.DrawText(strGroupCaption, -1, &rectCaption, DT_SINGLELINE|DT_LEFT/*|DT_CENTER*/ ); CRect rectTotals ( rectCaption.right + 4, rectGroup.top + 5, rectCaption.right + 80, rectGroup.bottom - 3 ) ; CFont * pListFont = GetFont(); CFont* pOld = dcMem.SelectObject(pListFont); dcMem.SetTextColor( RGB(169,47,47) ); dcMem.DrawText(strGroupTotals, -1, &rectTotals, DT_SINGLELINE|DT_LEFT/*|DT_CENTER*/ ); dcMem.SelectObject(pOld); }
void CAnsiWnd::OnPaint() { CPaintDC dc(this); // device context for painting CRect rect; GetClientRect(&rect); CRgn rgn; rgn.CreateRectRgn(rect.left, rect.top, rect.right, rect.bottom); dc.SelectClipRgn(&rgn); int ScrollIndex = GetScrollPos(SB_VERT); POSITION pos = m_strList.FindIndex(ScrollIndex+m_nPageSize); ASSERT(pos); rect.top = rect.bottom-pDoc->m_nYsize; int i = 0; dc.SetBkMode(OPAQUE); CFont* pOldFont = dc.SelectObject(&pDoc->m_fntText); while ( pos && i++ <= m_nPageSize) { CString str = m_strList.GetPrev(pos); if ( dc.RectVisible(&rect) ) DrawWithANSI(&dc, rect, &str, m_nPageSize - i); rect.top -= pDoc->m_nYsize; rect.bottom -= pDoc->m_nYsize; } dc.SelectObject(pOldFont); }
void GPDraw3DFrame( CDC* pDC, CRect& rcDayFrame, LPCRECT pRcClip) { CBrush brush1, brush2; brush1.CreateSolidBrush( RGB(149,149,149)); brush2.CreateSolidBrush( RGB(255,255,255)); if (pRcClip) { pDC->ExcludeClipRect(pRcClip); } pDC->FrameRect(rcDayFrame, &brush1); pDC->SelectObject(&brush2); rcDayFrame.InflateRect(1,1,1,1); pDC->FrameRect(rcDayFrame, &brush2); rcDayFrame.DeflateRect(2,2,2,2); pDC->FrameRect(rcDayFrame, &brush2); if (pRcClip) { CRgn rgn; rgn.CreateRectRgn(pRcClip->left, pRcClip->top, pRcClip->right, pRcClip->bottom); pDC->SelectClipRgn(&rgn, RGN_OR); } }
void CMcLogo::OnPaint() { CPaintDC dc(this); // device context for painting CRect Client; GetClientRect(&Client); dc.SetBoundsRect(Client,DCB_SET); CRgn reg; reg.CreateRectRgnIndirect(Client); dc.SelectClipRgn(®); // CRect rendRect(CPoint((Client.Width()-227)/2,0),CSize(227,36)), // rectLeft(0,0,(Client.Width()-227)/2,36), // rectRight((Client.Width()-227)/2+227,0,Client.Width(),36); CRect rendRect(CPoint(0, 0), CSize(227,36)), rectRight(227, 0, Client.Width(), 36); //dc.FillSolidRect(rectLeft,m_BkgColor); dc.FillSolidRect(rectRight, m_BkgColor); if(m_Image.m_pPict) m_Image.Render(&dc, rendRect, rendRect); else dc.FillSolidRect(rendRect, m_BkgColor); }
void CSmcView::OnDraw(CDC* pDC) { CSmcDoc* pDoc = GetDocument(); CRect rect; GetClientRect(&rect); CRgn rgn; rgn.CreateRectRgn(rect.left, rect.top, rect.right, rect.bottom); pDC->SelectClipRgn(&rgn); int ScrollIndex = GetScrollPos(SB_VERT); POSITION pos = m_strList.FindIndex(ScrollIndex+m_nPageSize); ASSERT(pos); rect.top = rect.bottom-pDoc->m_nYsize; int i = 0; pDC->SetBkMode(OPAQUE); CFont* pOldFont = pDC->SelectObject(&pDoc->m_fntText); while ( pos && i++ <= m_nPageSize) { CString str = m_strList.GetPrev(pos); if ( pDC->RectVisible(&rect) ) DrawWithANSI(pDC, rect, &str, m_nPageSize - i); rect.top -= pDoc->m_nYsize; rect.bottom -= pDoc->m_nYsize; } pDC->SelectObject(pOldFont); }
// **************************************************************************** // // Function Name: RWindowView::ValidateVectorRect( ) // // Description: Validates the given vector rect in this view // // Returns: Nothing // // Exceptions: None // // **************************************************************************** // void RWindowView::ValidateVectorRect( const RRealVectorRect& rect ) { // // Only validate if we have a CWnd if( !GetCWnd() ) return; // Get the bounding rect... RRealVectorRect temp = rect; // Get our transformation... R2dTransform transform; ApplyTransform( transform, FALSE, FALSE ); // Apply it to our bounds... temp *= transform; // Convert the bounds to device units ::LogicalUnitsToDeviceUnits( temp, *this ); // Get the polygon points RRealPoint realPolygon[ 4 ]; temp.GetPolygonPoints( realPolygon ); // Create a polygon region RIntPoint polygon[4]; polygon[0] = realPolygon[0]; polygon[1] = realPolygon[1]; polygon[2] = realPolygon[2]; polygon[3] = realPolygon[3]; CRgn validateArea; validateArea.CreatePolygonRgn( reinterpret_cast<POINT*>( &polygon ), 4, ALTERNATE ); // Validate the region GetCWnd( ).ValidateRgn( &validateArea ); }
int CMovingLrcDlg::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CDialog::OnCreate(lpCreateStruct) == -1) return -1; // TODO: 在此添加您专用的创建代码 MoveWindow(CRect(400,0,800,25)); SetTimer(1,TIMER_INTERVAL,NULL); ipast=0.0f; m_Font.CreateFont( 12, //nHeight //_T("Tahoma")); 14 0, //nWidth 0, //nEscapement 0, //nOrientation FW_NORMAL, //nWeight //FW_MEDIUM, //FW_SEMIBOLD, FALSE, //bItalic FALSE, //bUnderline 0, //cStrikeOut // ANSI_CHARSET, DEFAULT_CHARSET, //nCharSet OUT_DEFAULT_PRECIS, //nOutPrecision CLIP_DEFAULT_PRECIS, //nClipPrecision DEFAULT_QUALITY, //nQuality DEFAULT_PITCH | FF_SWISS, //nPitchAndFamily _T("宋体")); SetWindowPos(&wndTopMost,400,0,0,0,SWP_NOSIZE); CRgn rgn; rgn.CreateRoundRectRgn(0,0,400,25,10,10); SetWindowRgn(rgn,TRUE); ShowWindow(SW_SHOW); UpdateWindow(); return 0; }
void CLabHorizScale::drawScale(CDC *pDC) { int tickLength; CRgn rgn; CRect rect = bounds(); rgn.CreateRectRgn(rect.left, rect.top, rect.right, rect.bottom); pDC->SelectClipRgn(&rgn); for(double x=getTickMin(); x<=maximum(); x=x+tickIncrement()) { double temp = x/(majorTickFrequency()*tickIncrement()); if(temp == ceil(temp)) tickLength = 7; else tickLength = 3; pDC->MoveTo(translateCoordinate(x), rect.top); pDC->LineTo(translateCoordinate(x), rect.top + tickLength); temp = x/(tickMarkFrequency() * tickIncrement()); if(temp == ceil(temp)) { CString tickMarkStr; tickMarkStr.Format("%.*f", precision(), x); pDC->TextOut(translateCoordinate(x) - _parent->getCharWidth() * tickMarkStr.GetLength()/2, rect.top + 7 /* _parent->getCharHeight()*/, tickMarkStr); } } }
void CAnimateButton::PrepareBitmap(HBITMAP hBitmap) { int nStates = 4; //取得图像所处区域及计算各状态按钮窗口区域 m_arBmpRgn.SetSize(nStates); m_arBmpRgn.SetSize(nStates); CRect rcTmp; for(int i = 0; i < nStates; i ++) { m_arBmpRgn[i] = BitmapToRegion(hBitmap, nStates, i); } CBitmap* pBmpWhole = CBitmap::FromHandle(hBitmap); BITMAP bmp; pBmpWhole->GetBitmap(&bmp); m_aniBtnWidth = bmp.bmWidth / nStates; m_aniBtnHeight = bmp.bmHeight; m_pMemDC = new CDC; CDC* pDC = GetDC(); m_pMemDC->CreateCompatibleDC(pDC); m_pMemDC->SelectObject(pBmpWhole); ReleaseDC(pDC); CRgn RgnWnd; RgnWnd.CreateRectRgn(0, 0, m_aniBtnWidth, m_aniBtnHeight); SetWindowRgn(HRGN(RgnWnd), FALSE); //调整大小(这样在DrawItem里面才可能限定画的范围) SetWindowPos(NULL, 0, 0, m_aniBtnWidth, m_aniBtnHeight, SWP_NOMOVE); }
BOOL CResizableLayout::EnumAndClipChildWindow(HWND hWnd, LPARAM lParam) { CResizableLayout* pThis = (CResizableLayout*)lParam; // only direct children if (::GetParent(hWnd) != pThis->GetResizableWnd()->GetSafeHwnd()) return TRUE; if (!::IsWindowVisible(hWnd)) return TRUE; // skip invisible windows // go clipping? if (!pThis->LikesClipping(hWnd)) return TRUE; // obtain window position CRect rect; ::GetWindowRect(hWnd, &rect); pThis->GetResizableWnd()->ScreenToClient(&rect); // use window region if any CRgn rgn; rgn.CreateRectRgn(0,0,0,0); if (COMPLEXREGION == ::GetWindowRgn(hWnd, rgn)) { rgn.OffsetRgn(rect.TopLeft()); pThis->m_pClipDC->SelectClipRgn(&rgn, RGN_DIFF); } else { pThis->m_pClipDC->ExcludeClipRect(&rect); } return TRUE; }
BOOL CIBALoginDlg::OnInitDialog() { CIBADialog::OnInitDialog(); LoadImage(); SetEditFont(); InitOperatorsCombo(); GetDlgItem(IDC_COMBO_CASHIER)->SetFont(&m_Font); //设置登入框的位置 if (m_nLoginType == 0) {//被覆盖窗体依然处于最顶端,但失去激活 SetWindowPos(&CWnd::wndTopMost, 0, 0, 318, 242, SWP_NOMOVE); GetDlgItem(IDC_EDIT_PWD)->SetFocus(); } else {//不做原设置,只移动新窗体 SetWindowPos(NULL, 0, 0, 318, 242, SWP_NOMOVE); m_cboOperators.SetFocus(); } CRgn MyRgn; MyRgn.CreateRoundRectRgn(0, 0, 318, 242, 12, 12); SetWindowRgn(MyRgn, FALSE); //{ 2011/09/05-8201-gxx: m_btnEnmergency.ShowWindow(FALSE); WINDOWPLACEMENT wp; m_btnEnmergency.GetWindowPlacement(&wp); CString strAllCheckOut; m_btnEnmergency.GetWindowText(strAllCheckOut); m_btnAllCheckOut.Create( strAllCheckOut, WS_VISIBLE|WS_CHILD|SS_NOTIFY,wp.rcNormalPosition,this,IDC_BUTTON_ENMERGENCY); m_btnAllCheckOut.SetFont(&m_FontSmallBold); m_btnAllCheckOut.SetBkColor(RGB(245, 236, 216)); m_btnAllCheckOut.SetLinkColor(RGB(218,186,129)); m_btnAllCheckOut.SetHoverColor(RGB(235, 207, 156)); m_btnAllCheckOut.SetVisitedColor(RGB(218, 186, 129)); m_btnAllCheckOut.SetTransparent(FALSE); m_btnAllCheckOut.ShowWindow(CIBAConfig::GetInstance()->GetEnmergencyVisible()); //} //m_btnEnmergency.ShowWindow(CIBAConfig::GetInstance()->GetEnmergencyVisible()); //如果没有设置网吧ID或者识别码 if (CNetBarConfig::GetInstance()->GetNetBarId() == 0 || CNetBarConfig::GetInstance()->GetNetBarKey().GetLength() < 16) { CDlgNetbarConfig dlg; if (dlg.DoModal() == IDOK) { CNetBarConfig::GetInstance()->LoadFromDB(); } } return FALSE; // return TRUE unless you set the focus to a control // 异常: OCX 属性页应返回 FALSE }