void TTransRemain::FillDest( TImage<unsigned char> &image, TPoint2D<int> &upCentre, TPoint2D<int> &downCentre, HDC &memHDC, const size_t radius) { CBrush bush; bush.CreateHatchBrush(HS_CROSS, RGB(255,255,255)); CRgn upRgn; upRgn.CreateEllipticRgn( upCentre.x()- radius, upCentre.y()-radius, upCentre.x()+ radius, upCentre.y()+radius); FillRgn(memHDC , upRgn, bush); CRgn downRgn; downRgn.CreateEllipticRgn( downCentre.x()-radius, downCentre.y()-radius, downCentre.x()+radius, downCentre.y()+radius); FillRgn(memHDC,downRgn, bush); CRgn midRgn; POINT midRect[4]; midRect[0].x = upCentre.x()-radius; midRect[0].y = upCentre.y(); midRect[1].x = downCentre.x()-radius; midRect[1].y = downCentre.y(); midRect[2].x = downCentre.x()+radius; midRect[2].y = downCentre.y(); midRect[3].x = upCentre.x()+radius; midRect[3].y = upCentre.y(); midRgn.CreatePolygonRgn(midRect, 4, ALTERNATE); FillRgn(memHDC, midRgn, bush); }
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; }
BOOL CSkinButton::GetRegion() { CMyBitmap bmp; CRgn rgn; rgn.CreateEllipticRgn( 00, 00, 50, 50 ); SetWindowRgn((HRGN)rgn.Detach(), TRUE ); //wyw #if 1 rgn.DeleteObject(); #endif return TRUE; }
//-------------------------------------------------------------------------- // 선택 지점의 좌표 포인트 반환 //-------------------------------------------------------------------------- int GLine::FindSelectPoint(CPoint pt) { int tempThick = (GObject::m_nsThickness > 4 ? GObject::m_nsThickness : 5); // 기본 크기는 5 CRgn rgn; CPoint tempPt = GObject::m_sStartPoint; rgn.CreateEllipticRgn(tempPt.x - tempThick, tempPt.y - tempThick, tempPt.x + tempThick, tempPt.y + tempThick); // 리전 생성 // 시작점이 Rgn 안에 있으며 시작점이 선택 if(rgn.PtInRegion(pt) == TRUE) { return 0; } tempPt = GObject::m_sEndPoint; rgn.DeleteObject(); rgn.CreateEllipticRgn(tempPt.x - tempThick, tempPt.y - tempThick, tempPt.x + tempThick, tempPt.y + tempThick); // 리전 생성 // 끝점이 선택된 경우 if(rgn.PtInRegion(pt) == TRUE) { return 4; } return -1; }
//************************************************************************************ void CBCGPRadialMenu::SetRgn() { if (m_pRadialMenuObject != NULL) { CRect rect; GetClientRect(rect); int cx = rect.Width(); int cy = rect.Height(); CRgn rgn; rgn.CreateEllipticRgn(0, 0, cx, cy); if (!m_pRadialMenuObject->m_bHasCenterButton) { double rx = INTERNAL_PART * cx; double ry = INTERNAL_PART * cy; int x1 = (int)(.5 + .5 * cx - rx); int x2 = (int)(.5 + .5 * cx + rx); int y1 = (int)(.5 +.5 * cy - ry); int y2 = (int)(.5 + .5 * cy + ry); CRgn rgnCenter; rgnCenter.CreateEllipticRgn(x1, y1, x2, y2); rgn.CombineRgn(&rgn, &rgnCenter, RGN_XOR); } SetWindowRgn(rgn, FALSE); } else { SetWindowRgn(NULL, FALSE); } }
// @pymethod int|PyCRgn|CreateEllipticRgn|Initializes a region to an ellipse // Return Values: success or failure flag (BOOL) PyObject * PyCRgn::create_elliptic_rgn(PyObject *self, PyObject *args) { CRgn *pRgn = PyCRgn::GetRgn(self); if (!pRgn) return NULL; int x1,y1,x2,y2; if (!PyArg_ParseTuple(args,"(iiii):CreateEllipticRgn", &x1,&y1, &x2,&y2)) return NULL; BOOL ok=pRgn->CreateEllipticRgn(x1,y1,x2,y2); return Py_BuildValue("i",ok); }
long CEllipse::HitTest(long x, long y) { if(m_locked){ return TK_NONE; } if(m_lStatus!=ST_NOMAL) return TK_NONE; CRect rtTemp; POINT pt; pt.x=x; pt.y=y; rtTemp.SetRect(m_lx1-DELTA,m_ly1-DELTA,m_lx1+DELTA,m_ly1+DELTA); if(rtTemp.PtInRect(pt)) return TK_LT; rtTemp.SetRect(m_lx1-DELTA,m_ly2-DELTA,m_lx1+DELTA,m_ly2+DELTA); if(rtTemp.PtInRect(pt)) return TK_LB; rtTemp.SetRect(m_lx2-DELTA,m_ly1-DELTA,m_lx2+DELTA,m_ly1+DELTA); if(rtTemp.PtInRect(pt)) return TK_RT; rtTemp.SetRect(m_lx2-DELTA,m_ly2-DELTA,m_lx2+DELTA,m_ly2+DELTA); if(rtTemp.PtInRect(pt)) return TK_RB; rtTemp.SetRect((m_lx1+m_lx2)/2-DELTA,m_ly1-DELTA,(m_lx1+m_lx2)/2+DELTA,m_ly1+DELTA); if(rtTemp.PtInRect(pt)) return TK_TM; rtTemp.SetRect((m_lx1+m_lx2)/2-DELTA,m_ly2-DELTA,(m_lx1+m_lx2)/2+DELTA,m_ly2+DELTA); if(rtTemp.PtInRect(pt)) return TK_BM; rtTemp.SetRect(m_lx1-DELTA,(m_ly1+m_ly2)/2-DELTA,m_lx1+DELTA,(m_ly1+m_ly2)/2+DELTA); if(rtTemp.PtInRect(pt)) return TK_LM; rtTemp.SetRect(m_lx2-DELTA,(m_ly1+m_ly2)/2-DELTA,m_lx2+DELTA,(m_ly1+m_ly2)/2+DELTA); if(rtTemp.PtInRect(pt)) return TK_RM; CRgn rgnTmp; if(rgnTmp.CreateEllipticRgn(m_lx1,m_ly1,m_lx2,m_ly2)){ if(rgnTmp.PtInRegion(pt)) return TK_MOV; } return TK_NONE; }
HBITMAP CLiveList::CreateDragImage(CListCtrl* pList, const CPoint& ptMouse, CPoint& ptMiddle) { ASSERT_VALID( pList ); CRect rcClient, rcOne, rcAll( 32000, 32000, -32000, -32000 ); int nIndex; if ( pList->GetSelectedCount() == 0 ) return NULL; pList->SetFocus(); pList->GetClientRect( &rcClient ); for ( nIndex = -1 ; ( nIndex = pList->GetNextItem( nIndex, LVNI_SELECTED ) ) >= 0 ; ) { pList->GetItemRect( nIndex, rcOne, LVIR_BOUNDS ); if ( rcOne.IntersectRect( &rcClient, &rcOne ) ) { rcAll.left = min( rcAll.left, rcOne.left ); rcAll.top = min( rcAll.top, rcOne.top ); rcAll.right = max( rcAll.right, rcOne.right ); rcAll.bottom = max( rcAll.bottom, rcOne.bottom ); } pList->SetItemState( nIndex, 0, LVIS_FOCUSED ); } BOOL bClipped = rcAll.Height() > MAX_DRAG_SIZE; if ( bClipped ) { rcAll.left = max( rcAll.left, ptMouse.x - MAX_DRAG_SIZE_2 ); rcAll.right = max( rcAll.right, ptMouse.x + MAX_DRAG_SIZE_2 ); rcAll.top = max( rcAll.top, ptMouse.y - MAX_DRAG_SIZE_2 ); rcAll.bottom = max( rcAll.bottom, ptMouse.y + MAX_DRAG_SIZE_2 ); } CClientDC dcClient( pList ); CBitmap bmAll, bmDrag; CDC dcAll, dcDrag; if ( ! dcAll.CreateCompatibleDC( &dcClient ) ) return NULL; if ( ! bmAll.CreateCompatibleBitmap( &dcClient, rcClient.Width(), rcClient.Height() ) ) return NULL; if ( ! dcDrag.CreateCompatibleDC( &dcClient ) ) return NULL; if ( ! bmDrag.CreateCompatibleBitmap( &dcClient, rcAll.Width(), rcAll.Height() ) ) return NULL; CBitmap *pOldAll = dcAll.SelectObject( &bmAll ); dcAll.FillSolidRect( &rcClient, DRAG_COLOR_KEY ); COLORREF crBack = pList->GetBkColor(); pList->SetBkColor( DRAG_COLOR_KEY ); pList->SendMessage( WM_PAINT, (WPARAM)dcAll.GetSafeHdc() ); pList->SetBkColor( crBack ); CBitmap *pOldDrag = dcDrag.SelectObject( &bmDrag ); dcDrag.FillSolidRect( 0, 0, rcAll.Width(), rcAll.Height(), DRAG_COLOR_KEY ); CRgn pRgn; ptMiddle.SetPoint( ptMouse.x - rcAll.left, ptMouse.y - rcAll.top ); if ( bClipped ) { pRgn.CreateEllipticRgn( ptMiddle.x - MAX_DRAG_SIZE_2, ptMiddle.y - MAX_DRAG_SIZE_2, ptMiddle.x + MAX_DRAG_SIZE_2, ptMiddle.y + MAX_DRAG_SIZE_2 ); dcDrag.SelectClipRgn( &pRgn ); } for ( nIndex = -1 ; ( nIndex = pList->GetNextItem( nIndex, LVNI_SELECTED ) ) >= 0 ; ) { pList->GetItemRect( nIndex, rcOne, LVIR_BOUNDS ); if ( rcOne.IntersectRect( &rcAll, &rcOne ) ) { dcDrag.BitBlt( rcOne.left - rcAll.left, rcOne.top - rcAll.top, rcOne.Width(), rcOne.Height(), &dcAll, rcOne.left, rcOne.top, SRCCOPY ); } } dcDrag.SelectObject( pOldDrag ); dcAll.SelectObject( pOldAll ); dcDrag.DeleteDC(); bmAll.DeleteObject(); dcAll.DeleteDC(); return (HBITMAP) bmDrag.Detach (); }
long CArc::HitTest(long x, long y) { if(m_locked){ return TK_NONE; } if(m_lStatus!=ST_NOMAL) return TK_NONE; CRect rtTemp; POINT pt; pt.x=x; pt.y=y; rtTemp.SetRect(m_lx1-DELTA,m_ly1-DELTA,m_lx1+DELTA,m_ly1+DELTA); if(rtTemp.PtInRect(pt)) return TK_LT; rtTemp.SetRect(m_lx1-DELTA,m_ly2-DELTA,m_lx1+DELTA,m_ly2+DELTA); if(rtTemp.PtInRect(pt)) return TK_LB; rtTemp.SetRect(m_lx2-DELTA,m_ly1-DELTA,m_lx2+DELTA,m_ly1+DELTA); if(rtTemp.PtInRect(pt)) return TK_RT; rtTemp.SetRect(m_lx2-DELTA,m_ly2-DELTA,m_lx2+DELTA,m_ly2+DELTA); if(rtTemp.PtInRect(pt)) return TK_RB; rtTemp.SetRect((m_lx1+m_lx2)/2-DELTA,m_ly1-DELTA,(m_lx1+m_lx2)/2+DELTA,m_ly1+DELTA); if(rtTemp.PtInRect(pt)) return TK_TM; rtTemp.SetRect((m_lx1+m_lx2)/2-DELTA,m_ly2-DELTA,(m_lx1+m_lx2)/2+DELTA,m_ly2+DELTA); if(rtTemp.PtInRect(pt)) return TK_BM; rtTemp.SetRect(m_lx1-DELTA,(m_ly1+m_ly2)/2-DELTA,m_lx1+DELTA,(m_ly1+m_ly2)/2+DELTA); if(rtTemp.PtInRect(pt)) return TK_LM; rtTemp.SetRect(m_lx2-DELTA,(m_ly1+m_ly2)/2-DELTA,m_lx2+DELTA,(m_ly1+m_ly2)/2+DELTA); if(rtTemp.PtInRect(pt)) return TK_RM; rtTemp.SetRect(m_lx3-DELTA,m_ly3-DELTA,m_lx3+DELTA,m_ly3+DELTA); if(rtTemp.PtInRect(pt)) return TK_SP; rtTemp.SetRect(m_lx4-DELTA,m_ly4-DELTA,m_lx4+DELTA,m_ly4+DELTA); if(rtTemp.PtInRect(pt)) return TK_EP; long x1,y1,x2,y2; if(m_lx1<=m_lx2){ x1=m_lx1; x2=m_lx2; }else{ x1=m_lx2; x2=m_lx1; } if(m_ly1<m_ly2){ y1=m_ly1; y2=m_ly2; }else{ y1=m_ly2; y2=m_ly1; } CRgn rgnTmp; if(rgnTmp.CreateEllipticRgn(x1-DELTA,y1-DELTA,x2+DELTA,y2+DELTA)){ if(!rgnTmp.PtInRegion(pt)) return TK_NONE; x1=x1+DELTA; y1=y1+DELTA; x2=x2-DELTA; y2=y2-DELTA; if(x1<x2 && y1<y2){ CRgn rgnTmp; if(rgnTmp.CreateEllipticRgn(x1,y1,x2,y2)){ if(rgnTmp.PtInRegion(pt)) return TK_NONE; }else{ return TK_NONE; } } double dx=(double)x-((double)m_lx1+(double)m_lx2)/2; double dy=-(double)y+((double)m_ly1+(double)m_ly2)/2; double dxs=(double)m_lx3-((double)m_lx1+(double)m_lx2)/2; double dys=-(double)m_ly3+((double)m_ly1+(double)m_ly2)/2; double dxe=(double)m_lx4-((double)m_lx1+(double)m_lx2)/2; double dye=-(double)m_ly4+((double)m_ly1+(double)m_ly2)/2; double sa=GetAngle(dxs,dys); double ea=GetAngle(dxe,dye); double pa=GetAngle(dx,dy); if(SPE(sa,pa,ea)) return TK_MOV; } return TK_NONE; }
void CAutoPanParameters::CreateWindowRegion(CRgn& rgn, CWnd* /*pParentWnd*/) const { rgn.CreateEllipticRgn(2, 2, 31, 31); }
HBITMAP CLibraryAlbumView::CreateDragImage(const CPoint& ptMouse, CPoint& ptMiddle) { CRect rcClient, rcOne, rcAll( 32000, 32000, -32000, -32000 ); GetClientRect( &rcClient ); for ( POSITION pos = m_pSelTrack.GetHeadPosition() ; pos ; ) { CLibraryAlbumTrack* pTrack = m_pSelTrack.GetNext( pos ); GetItemRect( pTrack, &rcOne ); if ( rcOne.IntersectRect( &rcClient, &rcOne ) ) { rcAll.left = min( rcAll.left, rcOne.left ); rcAll.top = min( rcAll.top, rcOne.top ); rcAll.right = max( rcAll.right, rcOne.right ); rcAll.bottom = max( rcAll.bottom, rcOne.bottom ); } } BOOL bClipped = rcAll.Height() > MAX_DRAG_SIZE; if ( bClipped ) { rcAll.left = max( rcAll.left, ptMouse.x - MAX_DRAG_SIZE_2 ); rcAll.right = max( rcAll.right, ptMouse.x + MAX_DRAG_SIZE_2 ); rcAll.top = max( rcAll.top, ptMouse.y - MAX_DRAG_SIZE_2 ); rcAll.bottom = max( rcAll.bottom, ptMouse.y + MAX_DRAG_SIZE_2 ); } CClientDC dcClient( this ); CBitmap bmDrag; CDC dcDrag; if ( ! dcDrag.CreateCompatibleDC( &dcClient ) ) return NULL; if ( ! bmDrag.CreateCompatibleBitmap( &dcClient, rcAll.Width(), rcAll.Height() ) ) return NULL; CBitmap *pOldDrag = dcDrag.SelectObject( &bmDrag ); dcDrag.FillSolidRect( 0, 0, rcAll.Width(), rcAll.Height(), DRAG_COLOR_KEY ); CRgn pRgn; ptMiddle.SetPoint( ptMouse.x - rcAll.left, ptMouse.y - rcAll.top ); if ( bClipped ) { pRgn.CreateEllipticRgn( ptMiddle.x - MAX_DRAG_SIZE_2, ptMiddle.y - MAX_DRAG_SIZE_2, ptMiddle.x + MAX_DRAG_SIZE_2, ptMiddle.y + MAX_DRAG_SIZE_2 ); dcDrag.SelectClipRgn( &pRgn ); } CDC* pBuffer = CoolInterface.GetBuffer( dcClient, m_szTrack ); CRect rcBuffer( 0, 0, m_szTrack.cx, m_szTrack.cy ); CFont* pOldFont = (CFont*)pBuffer->SelectObject( &CoolInterface.m_fntNormal ); for ( POSITION pos = m_pSelTrack.GetHeadPosition() ; pos ; ) { CLibraryAlbumTrack* pTrack = m_pSelTrack.GetNext( pos ); GetItemRect( pTrack, &rcOne ); CRect rcDummy; if ( rcDummy.IntersectRect( &rcAll, &rcOne ) ) { pBuffer->FillSolidRect( &rcBuffer, DRAG_COLOR_KEY ); pTrack->Paint( this, pBuffer, rcBuffer, -1 ); dcDrag.BitBlt( rcOne.left - rcAll.left, rcOne.top - rcAll.top, m_szTrack.cx, m_szTrack.cy, pBuffer, 0, 0, SRCCOPY ); } } pBuffer->SelectObject( pOldFont ); dcDrag.SelectObject( pOldDrag ); dcDrag.DeleteDC(); return (HBITMAP) bmDrag.Detach(); }
BOOL CclockDlg::OnInitDialog() { CDialog::OnInitDialog(); // 设置此对话框的图标。当应用程序主窗口不是对话框时,框架将自动 // 执行此操作 //SetIcon(m_hIcon, TRUE); // 设置大图标 //SetIcon(m_hIcon, FALSE); // 设置小图标 // TODO: 在此添加额外的初始化代码 //设置程序运行时不在任务栏的运行区显示图标 SetWindowLong(this->m_hWnd,GWL_EXSTYLE,WS_EX_TOOLWINDOW); //设置控制时针走动的触发器为每秒一次,即引发WM_TIMER消息的频率是每秒一次。 m_timer = this->SetTimer(1, 1000, NULL); /////////////////////////////////////////////////////////////// CRgn rgn; CRect rc; GetClientRect(&rc); rgn.CreateEllipticRgn(rc.left,rc.top,rc.right,rc.bottom); SetWindowRgn(rgn,TRUE); rgn.DeleteObject(); ////////////////////////////////////////////////////////////// CBitmap bm; bm.LoadBitmap(IDB_BITMAP1); // IDB_BITMAP1为BITMAP资源ID,可以指定bitmap图片的路径 m_brush.CreatePatternBrush(&bm); //SoundTime(); //sndPlaySoundA("AM.wav",SND_ASYNC); //将对话框的句柄传递到CWinSunApp类中。sunxin // ((CclockApp*)AfxGetApp())->m_hwndDlg=m_hWnd; DWORD dwParam; pThread=AfxBeginThread(ThreadProc,&dwParam,THREAD_PRIORITY_HIGHEST,0,CREATE_SUSPENDED,0); if(pThread==NULL) AfxMessageBox("创建线程错误!"); DWORD dwParam2; pThread2=AfxBeginThread(ThreadProc2,&dwParam2,THREAD_PRIORITY_HIGHEST,0,CREATE_SUSPENDED,0); if(pThread2==NULL) AfxMessageBox("创建线程错误!"); DWORD dwParam3; pThread3=AfxBeginThread(ThreadProc3,&dwParam3,THREAD_PRIORITY_HIGHEST,0,CREATE_SUSPENDED,0); if(pThread3==NULL) AfxMessageBox("创建线程错误!"); int temp=AfxGetApp()->GetProfileInt("Sound","hoursound",0); if(temp==1) hoursound=true; else hoursound=false; temp=AfxGetApp()->GetProfileInt("Sound","halfhoursound",0); if(temp==1) halfhoursound=true; else halfhoursound=false; ringnum=AfxGetApp()->GetProfileIntA("ring","ringnum",0); CString time; CString temps; for(int i=0;i<ringnum;i++) { temps.Format("ring%d",i+1); time=AfxGetApp()->GetProfileStringA("ring",temps); mytimearray[i].hour=(time[0]-48)*10+time[1]-48; mytimearray[i].minute=(time[3]-48)*10+time[4]-48; mytimearray[i].second=(time[6]-48)*10+time[7]-48; } tasknum=AfxGetApp()->GetProfileIntA("task","tasknum",0); CString taskdate; CString tasktime; for(int i=0;i<tasknum;i++) { temps.Format("taskdate%d",i+1); taskdate=AfxGetApp()->GetProfileStringA("taskdate",temps); temps.Format("tasktime%d",i+1); tasktime=AfxGetApp()->GetProfileStringA("tasktime",temps); mytaskarray[i].year=(taskdate[0]-48)*1000+(taskdate[1]-48)*100+(taskdate[2]-48)*10+taskdate[3]-48; mytaskarray[i].month=(taskdate[5]-48)*10+taskdate[6]-48; mytaskarray[i].day=(taskdate[8]-48)*10+taskdate[9]-48; mytaskarray[i].hour=(tasktime[0]-48)*10+tasktime[1]-48; mytaskarray[i].minute=(tasktime[3]-48)*10+tasktime[4]-48; mytaskarray[i].second=(tasktime[6]-48)*10+tasktime[7]-48; temps.Format("task%d",i+1); mytaskarray[i].typle=AfxGetApp()->GetProfileIntA("task",temps,0); } return TRUE; // 除非将焦点设置到控件,否则返回 TRUE }
void CRoundButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) { ASSERT(lpDrawItemStruct != NULL); CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC); CRect rect = lpDrawItemStruct->rcItem; UINT state = lpDrawItemStruct->itemState; UINT nStyle = GetStyle(); int nRadius = m_nRadius; int nSavedDC = pDC->SaveDC(); pDC->SelectStockObject(NULL_BRUSH); pDC->FillSolidRect(rect, ::GetSysColor(COLOR_BTNFACE)); // Draw the focus circle around the button if ((state & ODS_FOCUS) && m_bDrawDashedFocusCircle) DrawCircle(pDC, m_ptCentre, nRadius--, RGB(0,0,0)); // Draw the raised/sunken edges of the button (unless flat) if (nStyle & BS_FLAT) { DrawCircle(pDC, m_ptCentre, nRadius--, RGB(0,0,0)); DrawCircle(pDC, m_ptCentre, nRadius--, ::GetSysColor(COLOR_3DHIGHLIGHT)); } else { if ((state & ODS_SELECTED)) { DrawCircle(pDC, m_ptCentre, nRadius--, ::GetSysColor(COLOR_3DDKSHADOW), ::GetSysColor(COLOR_3DHIGHLIGHT)); DrawCircle(pDC, m_ptCentre, nRadius--, ::GetSysColor(COLOR_3DSHADOW), ::GetSysColor(COLOR_3DLIGHT)); } else { DrawCircle(pDC, m_ptCentre, nRadius--, ::GetSysColor(COLOR_3DHIGHLIGHT), ::GetSysColor(COLOR_3DDKSHADOW)); DrawCircle(pDC, m_ptCentre, nRadius--, ::GetSysColor(COLOR_3DLIGHT), ::GetSysColor(COLOR_3DSHADOW)); } } // draw the text if there is any CString strText; GetWindowText(strText); if (!strText.IsEmpty()) { CRgn rgn; rgn.CreateEllipticRgn(m_ptCentre.x-nRadius, m_ptCentre.y-nRadius, m_ptCentre.x+nRadius, m_ptCentre.y+nRadius); pDC->SelectClipRgn(&rgn); CSize Extent = pDC->GetTextExtent(strText); CPoint pt = CPoint( m_ptCentre.x - Extent.cx/2, m_ptCentre.x - Extent.cy/2 ); if (state & ODS_SELECTED) pt.Offset(1,1); pDC->SetBkMode(TRANSPARENT); if (state & ODS_DISABLED) pDC->DrawState(pt, Extent, strText, DSS_DISABLED, TRUE, 0, (HBRUSH)NULL); else pDC->TextOut(pt.x, pt.y, strText); pDC->SelectClipRgn(NULL); rgn.DeleteObject(); } // Draw the focus circle on the inside of the button if ((state & ODS_FOCUS) && m_bDrawDashedFocusCircle) DrawCircle(pDC, m_ptCentre, nRadius-2, RGB(0,0,0), TRUE); pDC->RestoreDC(nSavedDC); }
HBITMAP CLibraryTileView::CreateDragImage(const CPoint& ptMouse, CPoint& ptMiddle) { ASSUME_LOCK( Library.m_pSection ); CRect rcClient, rcOne, rcAll( 32000, 32000, -32000, -32000 ); GetClientRect( &rcClient ); for ( std::list< iterator >::iterator pTile = m_oSelTile.begin(); pTile != m_oSelTile.end(); ++pTile ) { GetItemRect( *pTile, &rcOne ); if ( rcOne.IntersectRect( &rcClient, &rcOne ) ) { rcAll.left = min( rcAll.left, rcOne.left ); rcAll.top = min( rcAll.top, rcOne.top ); rcAll.right = max( rcAll.right, rcOne.right ); rcAll.bottom = max( rcAll.bottom, rcOne.bottom ); } } const bool bClipped = rcAll.Height() > MAX_DRAG_SIZE; if ( bClipped ) { rcAll.left = max( rcAll.left, ptMouse.x - MAX_DRAG_SIZE_2 ); rcAll.right = max( rcAll.right, ptMouse.x + MAX_DRAG_SIZE_2 ); rcAll.top = max( rcAll.top, ptMouse.y - MAX_DRAG_SIZE_2 ); rcAll.bottom = max( rcAll.bottom, ptMouse.y + MAX_DRAG_SIZE_2 ); } CClientDC dcClient( this ); CDC dcMem, dcDrag; CBitmap bmDrag; if ( ! dcMem.CreateCompatibleDC( &dcClient ) ) return NULL; if ( ! dcDrag.CreateCompatibleDC( &dcClient ) ) return NULL; if ( ! bmDrag.CreateCompatibleBitmap( &dcClient, rcAll.Width(), rcAll.Height() ) ) return NULL; CBitmap *pOldDrag = dcDrag.SelectObject( &bmDrag ); dcDrag.FillSolidRect( 0, 0, rcAll.Width(), rcAll.Height(), DRAG_COLOR_KEY ); ptMiddle.SetPoint( ptMouse.x - rcAll.left, ptMouse.y - rcAll.top ); CRgn pRgn; if ( bClipped ) { pRgn.CreateEllipticRgn( ptMiddle.x - MAX_DRAG_SIZE_2, ptMiddle.y - MAX_DRAG_SIZE_2, ptMiddle.x + MAX_DRAG_SIZE_2, ptMiddle.y + MAX_DRAG_SIZE_2 ); dcDrag.SelectClipRgn( &pRgn ); } CDC* pBuffer = CoolInterface.GetBuffer( dcClient, m_szBlock ); CRect rcBuffer( 0, 0, m_szBlock.cx, m_szBlock.cy ); CFont* pOldFont = (CFont*)pBuffer->SelectObject( &CoolInterface.m_fntNormal ); for ( std::list< iterator >::iterator pTile = m_oSelTile.begin(); pTile != m_oSelTile.end(); ++pTile ) { GetItemRect( *pTile, &rcOne ); CRect rcDummy; if ( rcDummy.IntersectRect( &rcAll, &rcOne ) ) { pBuffer->FillSolidRect( &rcBuffer, DRAG_COLOR_KEY ); (**pTile)->Paint( pBuffer, rcBuffer, &dcMem, (*pTile) == m_pFocus ); dcDrag.BitBlt( rcOne.left - rcAll.left, rcOne.top - rcAll.top, m_szBlock.cx, m_szBlock.cy, pBuffer, 0, 0, SRCCOPY ); } } pBuffer->SelectObject( pOldFont ); dcDrag.SelectObject( pOldDrag ); dcDrag.DeleteDC(); return (HBITMAP) bmDrag.Detach(); }