当前位置: 首页>>代码示例>>C++>>正文


C++ CBrush::CreatePatternBrush方法代码示例

本文整理汇总了C++中CBrush::CreatePatternBrush方法的典型用法代码示例。如果您正苦于以下问题:C++ CBrush::CreatePatternBrush方法的具体用法?C++ CBrush::CreatePatternBrush怎么用?C++ CBrush::CreatePatternBrush使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CBrush的用法示例。


在下文中一共展示了CBrush::CreatePatternBrush方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: OnPaint

    LRESULT OnPaint( HWND hWnd ) 
    {
        CWnd* pWnd = CWnd::FromHandle(hWnd);
        
        CPaintDC	dc(pWnd);
        CString		Text;
        CRect		RC;
        CFont		Font;
        CFont		*pOldFont;
        CBrush		Brush;
        CBrush		*pOldBrush;
        CPoint		PT(2,2);
        
        dc.SetBkMode( TRANSPARENT );
        Font.CreateFont( 12, 0, 0, 0, FW_HEAVY, 0, 0, 0, ANSI_CHARSET, \
            OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, \
            VARIABLE_PITCH | FF_SWISS, "MS Sans Serif" );

        pOldFont = dc.SelectObject( &Font );
        
        if( m_State == bsNormal)
        {
            
            if (m_Style==2)
            {
                CBitmap bmp;
                bmp.LoadBitmap(IDB_BKBUTTON);
                Brush.CreatePatternBrush(&bmp); 
            }
            else
                Brush.CreateSolidBrush( RGB( 200, 200, 200 ) );
            dc.SetTextColor( RGB( 80, 80, 80) );
        }
        else if( m_State == bsDown )
        {
            Brush.CreateSolidBrush( RGB( 160, 160, 160 ) );
            dc.SetTextColor( RGB( 50, 50, 250 ) );
        }
        else if( m_State == bsHot )
        {
            Brush.CreateSolidBrush( RGB( 100, 100, 180 ) );
            dc.SetTextColor( RGB( 250, 250, 0 ) );
        }
        
        pOldBrush = dc.SelectObject( &Brush );
        pWnd->GetClientRect( &RC );
        dc.RoundRect( &RC, PT );
        
        HRGN hRgn = CreateRectRgn( RC.left, RC.top, RC.right, RC.bottom );
        pWnd->SetWindowRgn( hRgn, TRUE );
        DeleteObject( hRgn );
        
        pWnd->GetWindowText(Text );
        dc.DrawText( Text, &RC, DT_CENTER | DT_VCENTER | DT_SINGLELINE );
        
        dc.SelectObject( pOldFont );
        dc.SelectObject( pOldBrush );
        
        return TRUE;
    }
开发者ID:wuzhipeng2014,项目名称:FiveChess,代码行数:60,代码来源:ClientFiveChess.cpp

示例2: AfxDrawDitheredBitmap

void AFXAPI AfxDrawDitheredBitmap(CDC *pDC, int x, int y, const CBitmap &rSrc, COLORREF cr1, COLORREF cr2)
{
    ASSERT(pDC);
    ASSERT_KINDOF(CDC, pDC);

    BITMAP bm;
    CDC dcSrc, dcMask;
    COLORREF cr;
    CBitmap bmpMask, *pOldMask, *pOldSrc;
    CBrush brChecker;
    static const WORD wPat[8] = {0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa};

    if(dcSrc.CreateCompatibleDC(pDC) &&
        dcMask.CreateCompatibleDC(pDC) &&
        const_cast<CBitmap &>(rSrc).GetBitmap(&bm))
    {
        // Create checker brush
        bmpMask.CreateBitmap(8, 8, 1, 1, wPat);
        brChecker.CreatePatternBrush(&bmpMask);
        bmpMask.DeleteObject();

        // Mask
        bmpMask.CreateBitmap(bm.bmWidth, bm.bmHeight, 1, 1, NULL);

        pOldSrc = dcSrc.SelectObject(const_cast<CBitmap *>(&rSrc));
        pOldMask = dcMask.SelectObject(&bmpMask);

        ASSERT(pOldSrc && pOldMask);
        if(!pOldSrc || !pOldMask)
            return;

        // Make the upper left corner pixel of the source a "transparent" color
        cr = dcSrc.SetBkColor(dcSrc.GetPixel(0, 0));
        dcMask.BitBlt(0, 0, bm.bmWidth, bm.bmHeight, &dcSrc, 0, 0, SRCCOPY);
        // Make white pixels of the source "transparent" too
        dcSrc.SetBkColor(RGB(255, 255, 255));
        dcMask.BitBlt(0, 0, bm.bmWidth, bm.bmHeight, &dcSrc, 0, 0, SRCPAINT);
        dcSrc.SetBkColor(cr);

        // Checker the background with white and crBackground
        cr1 = pDC->SetTextColor(cr1);
        cr2 = pDC->SetBkColor(cr2);
        pDC->FillRect(CRect(x, y, x + bm.bmWidth, y + bm.bmHeight), &brChecker);
        pDC->SetTextColor(cr1);
        pDC->SetBkColor(cr2);

        // Blt it
        pDC->BitBlt(x, y, bm.bmWidth, bm.bmHeight, &dcSrc, 0, 0, SRCINVERT);
        pDC->BitBlt(x, y, bm.bmWidth, bm.bmHeight, &dcMask, 0, 0, SRCAND);
        pDC->BitBlt(x, y, bm.bmWidth, bm.bmHeight, &dcSrc, 0, 0, SRCINVERT);

        dcMask.SelectObject(pOldMask);
        dcSrc.SelectObject(pOldSrc);
    }
}
开发者ID:jbeaurain,项目名称:omaha_vs2010,代码行数:55,代码来源:wingdi.cpp

示例3: OnPaint

void CCustomHeader::OnPaint() 
{
    CPaintDC dc(this); 
    
    int ItemCount = GetItemCount();
    CRect cRC;
    GetClientRect(&cRC);

    CBrush brush;
    CBitmap bmp;
    bmp.LoadBitmap(IDB_LISTHEAD);
    brush.CreatePatternBrush(&bmp);
    dc.FillRect(cRC,&brush);

    CPen pen(PS_SOLID,1,RGB(236,233,216));

    for (int i = 0 ; i <ItemCount; i++)
    {
        CRect rc;
        GetItemRect(i,rc);
        rc.DeflateRect(0,0,1,0);

        //绘制分隔条
        dc.SelectObject(&pen);
        dc.MoveTo(rc.right+1,0);
        dc.LineTo(rc.right+1,rc.Height());
        //绘制文本
        char text[100];
        memset(text,0,100);
        CListCtrl* pList =  (CListCtrl*)this->GetParent();
        if (pList != NULL)
        {
                    
            LVCOLUMN col;
            memset(&col,0,sizeof(LVCOLUMN));
            col.mask = LVCF_TEXT;
            col.cchTextMax  = 100;
    
            col.pszText = (LPWSTR)text;
            pList->GetColumn(i,&col);
            dc.SetTextColor(RGB(0,0,0));

            CFont* font = GetFont();
            dc.SelectObject(font);
            dc.SetBkMode(TRANSPARENT);
            CString str ;
            str.Format(_T("%s"),text);
            dc.DrawText(str,rc,DT_CENTER |DT_VCENTER|DT_WORD_ELLIPSIS|DT_SINGLELINE);
        }
    }
    pen.DeleteObject();
    bmp.DeleteObject();
    brush.DeleteObject();
}
开发者ID:dulton,项目名称:nampu,代码行数:54,代码来源:CustomHeader.cpp

示例4: OnPaint

void CTestMFCDlg::OnPaint() 
{
    /*
    if (IsIconic())
    {
        CPaintDC dc(this); // device context for painting

        SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);

        // Center icon in client rectangle
        int cxIcon = GetSystemMetrics(SM_CXICON);
        int cyIcon = GetSystemMetrics(SM_CYICON);
        CRect rect;
        GetClientRect(&rect);
        int x = (rect.Width() - cxIcon + 1) / 2;
        int y = (rect.Height() - cyIcon + 1) / 2;

        // Draw the icon
        dc.DrawIcon(x, y, m_hIcon);
    }
    else
    {
        CDialog::OnPaint();
    }
    */
    CPaintDC dc(this);
    CRect rect;
    CBitmap bmp;
    bmp.LoadBitmap(IDB_BITMAP3);
    BITMAP bmpinfo;
    bmp.GetBitmap(&bmpinfo);
    CDC cdc;
    cdc.CreateCompatibleDC(&dc);
    cdc.SelectObject(bmp);
    CBrush brush;
    brush.CreatePatternBrush(&bmp);

    //GetClientRect(rect);
    GetClientRect(rect);
    dc.StretchBlt(0,0,rect.right,rect.bottom,&cdc,0,0,bmpinfo.bmWidth,bmpinfo.bmHeight,SRCCOPY);
    //dc.FillRect(CRect(0,0,rect.right/2,rect.bottom/2),&brush);
    //dc.FillSolidRect(0,0,rect.right/2,rect.bottom/2,RGB(0,0,255));
    //dc.FillSolidRect(CRect(0,0,rect.right/2,rect.bottom/2),RGB(0,0,255));
    //CDialog::OnPaint();
    /*
    CDialog::OnInitDialog(); 
    CBitmap bmp; 
    bmp.LoadBitmap(IDB_BITMAP1); 
    CBrush brush;
    brush.CreatePatternBrush(&bmp); 
    bmp.DeleteObject(); 
    */
}
开发者ID:YaMiYooo,项目名称:MFC-Examles,代码行数:53,代码来源:TestMFCDlg.cpp

示例5: OnPaint

void CRightChgUserAccView::OnPaint()
{
    CPaintDC dc(this); // device context for painting
    // TODO: 在此处添加消息处理程序代码
    // 不为绘图消息调用 CDialog::OnPaint()
    CBitmap bitmap;
    bitmap.LoadBitmap(IDB_BIT_BKIN);
    CBrush Brush;
    Brush.CreatePatternBrush(&bitmap);
    CBrush* pOldBrush=dc.SelectObject(&Brush);
    dc.FillRect(CRect(0,0,783,659),&Brush);
    dc.SelectObject(pOldBrush);
}
开发者ID:shangdufeng,项目名称:ManangeClient,代码行数:13,代码来源:RightChgUserAccView.cpp

示例6: OnPaint

void COverallDataView::OnPaint() 
{
    CPaintDC dc(this); // device context for painting
    
    if (m_masterSurveyList.GetLegQuery()!=NULL)
    {
        CRect r;
        CBrush brush;
        CBitmap bitmap;
        bitmap.LoadBitmap(IDB_QUESTIONBRUSH);
        brush.CreatePatternBrush(&bitmap);
        GetClientRect(r);
        dc.FillRect(r,&brush);
    }
}
开发者ID:felixcollins,项目名称:onstation,代码行数:15,代码来源:OverallDataView.cpp

示例7: OnPaint

void CRightResetpassView::OnPaint()
{
    CPaintDC dc(this); // device context for painting
    // TODO: 在此处添加消息处理程序代码
    // 不为绘图消息调用 CDialog::OnPaint()
    CPen pen(PS_SOLID,1,RGB(205,231,208));
    CBitmap   bitmap;
    bitmap.LoadBitmap(IDB_BKIN);   
    CBrush   brush;
    brush.CreatePatternBrush(&bitmap);
    CBrush*   pOldBrush   =   dc.SelectObject(&brush);
    CPen* pOldpen=dc.SelectObject(&pen);
    dc.FillRect(CRect(0,0,850,800),&brush);  
    dc.SelectObject(pOldBrush);
    dc.SelectObject(pOldpen);
}
开发者ID:shangdufeng,项目名称:HealthCloud,代码行数:16,代码来源:RightResetpassView.cpp

示例8: OnPaint

void CRightQueExecpView::OnPaint()
{
    CPaintDC dc(this); // device context for painting
    // TODO: 在此处添加消息处理程序代码
    // 不为绘图消息调用 CDialog::OnPaint()
    CBitmap bitmap;
    bitmap.LoadBitmap(IDB_BIT_BKIN);
    CBrush Brush;
    CPen   Pen;
    Pen.CreatePen(PS_SOLID,1,theApp.m_LineColor);
    Brush.CreatePatternBrush(&bitmap);
    CBrush* pOldBrush=dc.SelectObject(&Brush);
    CPen*   pOldPen=dc.SelectObject(&Pen);
    dc.Rectangle(CRect(0,0,726,445));
    dc.SelectObject(pOldBrush);
    dc.SelectObject(pOldPen);
}
开发者ID:shangdufeng,项目名称:ManangeClient,代码行数:17,代码来源:RightQueExecpView.cpp

示例9: OnEraseBkgnd

BOOL CImageEdit::OnEraseBkgnd(CDC* pDC) 
{
    CRect rect;
    GetClientRect(&rect);
    CDC dcMemory;
    BITMAP bmpInfo;

    CBitmap bitmap;
    bitmap.LoadBitmap(IDB_Bitmap_Back);
    bitmap.GetBitmap(&bmpInfo);

    CBrush brush;
    brush.CreatePatternBrush(&bitmap);
    pDC->FillRect(&rect, &brush);

    return TRUE;
//	return CEdit::OnEraseBkgnd(pDC);
}
开发者ID:gawallsibya,项目名称:BIT_MFC-CShap-DotNet,代码行数:18,代码来源:ImageEdit.cpp

示例10: OnMenuPatternBrush

void CWmPaintTestView::OnMenuPatternBrush() 
{
    CDC* pDC = GetDC();
    CBitmap	Bmp;
    CBrush* pNewBrush = new CBrush;
    CBrush* pOldBrush = NULL;

    //비트맵 파일을 로딩한다.
    Bmp.LoadBitmap(IDB_Bitmap_Pattern);
    //비트맵을 가지고 패턴 브러시를 생성한다.
    pNewBrush->CreatePatternBrush(&Bmp);
    pOldBrush = pDC->SelectObject(pNewBrush);
    //비트맵 패턴이 입혀진 네모가 그려진다.
    pDC->Rectangle(CRect(210, 200, 310, 300));

    pDC->SelectObject(pOldBrush);
    delete pNewBrush;

    ReleaseDC(pDC);
}
开发者ID:gawallsibya,项目名称:BIT_MFC-CShap-DotNet,代码行数:20,代码来源:WmPaintTestView.cpp

示例11: OnNcPaint

/////////////////////////////////////////////////////////////////////////////
// COFSNcDlg message handlers
void COFSNcDlg::OnNcPaint( )
{
    //// Творим Что хотим
    CRect rWin,rClient;
    
    GetWindowRect(&rWin);
    GetClientRect(&rClient);
    
    CRect m_CaptionRect;
    m_CaptionRect.left   = BoundaryX;
    m_CaptionRect.top    = BoundaryY;
    m_CaptionRect.right  = rWin.Width()- BoundaryX;
    m_CaptionRect.bottom = CaptionH + BoundaryY;

    ScreenToClient(&rWin);

    CRgn rgnWin,rgnClient,rgnUp,rgnCap;

    rgnUp.CreateRectRgn(0,0,0,0);
    rgnWin.CreateRectRgnIndirect(&rWin);
    rgnClient.CreateRectRgnIndirect(&rClient);
    rgnUp.CombineRgn(&rgnWin,&rgnClient,RGN_DIFF);
    rgnUp.OffsetRgn(CPoint(-rWin.left,-rWin.top));

    rgnCap.CreateRectRgnIndirect(m_CaptionRect);
    
    CWindowDC dc(this);
    dc.SelectClipRgn(&rgnUp,RGN_COPY);
    
    CBrush br;
    if(pBoundaryBMP)
        br.CreatePatternBrush(pBoundaryBMP);
    else
        br.CreateSolidBrush(m_BoundaryColor);

    rgnUp.CombineRgn(&rgnUp,&rgnCap,RGN_DIFF);
    dc.FillRgn(&rgnUp,&br);
    
    DrawCaption(dc,m_CaptionRect);
}
开发者ID:0anion0,项目名称:IBN,代码行数:42,代码来源:OFSNcDlg.cpp

示例12: DisplayInfo

void CScreenDlg::DisplayInfo(){
  if(PtInRect(&LEFT_RECT,m_ptMouse)){  
    m_rectInfo = RIGHT_RECT;
  }else if(PtInRect(&RIGHT_RECT,m_ptMouse)){
    m_rectInfo = LEFT_RECT;
  }
  CClientDC dc(m_hWnd);
  COLORREF color = dc.GetPixel(m_ptMouse);
  CDC dcMem;
  dcMem.CreateCompatibleDC(dc.m_hDC);
  CBitmap bmp;
  bmp.CreateCompatibleBitmap(dc.m_hDC, m_size.cx, m_size.cy);
  HBITMAP pOldBmp = dcMem.SelectBitmap(bmp.m_hBitmap);
  // 0. get the background
  dcMem.BitBlt(0,0,m_size.cx, m_size.cy,m_dcMem.m_hDC, 0,0,SRCCOPY);

  // 1. draw info pane
  CBrush brushBK;  brushBK.CreatePatternBrush(m_bmpInfoBK.m_hBitmap);
  CPen   penBK;  penBK.CreatePen(PS_SOLID,1,INFO_EDGECOLOR);//PS_SOLID,PS_DASHDOT
  HPEN  pOldPen   =  dcMem.SelectPen(penBK.m_hPen);
  HBRUSH  pOldBrush =  dcMem.SelectBrush(brushBK.m_hBrush);

  dcMem.SetBrushOrg(m_rectInfo.left, m_rectInfo.top);
  dcMem.Rectangle(&m_rectInfo);// draw rectangle
  dcMem.SelectBrush(pOldBrush);
  dcMem.MoveTo(m_rectInfo.left, m_rectInfo.top+content_height);
  dcMem.LineTo(m_rectInfo.right, m_rectInfo.top+content_height);
  dcMem.SelectPen(pOldPen);

  // 2.draw the text
  dcMem.SetBkMode(TRANSPARENT);
  dcMem.SetTextColor(INFO_TEXT);
  dcMem.SelectFont(thinfont);
  static WCHAR str1[255]={}, str2[255]={};
  int yoffset=TEXT_OFFSET+m_rectInfo.left;
  static const int fontsize=14;
  if(m_SelectingNow || m_SelectionFinished){
    wsprintf(str1,tstart, m_rectSelect.left, m_rectSelect.top);
    wsprintf(str2,tend, m_rectSelect.right, m_rectSelect.bottom);
    dcMem.TextOut(yoffset, INFO_HEADER_H, str1);
    dcMem.TextOut(yoffset, fontsize + INFO_HEADER_H, str2);
    dcMem.SelectFont(boldfont);
    dcMem.TextOut(yoffset, fontsize*2+5 + INFO_HEADER_H, info_capture);
    dcMem.TextOut(yoffset, fontsize*3+5 + INFO_HEADER_H, info_hotkey);
    dcMem.SelectFont(thinfont);
    dcMem.TextOut(yoffset, fontsize*4+15 + INFO_HEADER_H, info_deselect);
    dcMem.TextOut(yoffset, fontsize*5+15 + INFO_HEADER_H, info_adjust);
  }else{
    wsprintf(str1,tmouse, m_ptMouse.x, m_ptMouse.y);
    wsprintf(str2,tcolor, GetRValue(color),  GetGValue(color),  GetBValue(color));
    dcMem.TextOut(yoffset, INFO_HEADER_H, str1);
    dcMem.TextOut(yoffset, fontsize  + INFO_HEADER_H, str2);
    dcMem.SelectFont(boldfont);
    dcMem.TextOut(yoffset, fontsize*4+5+ INFO_HEADER_H, info_select);
    dcMem.TextOut(yoffset, fontsize*5+5 + INFO_HEADER_H, info_exit);
    dcMem.SelectFont(thinfont);
  }

  // 3. draw the selected region
  if(m_SelectingNow || m_SelectionFinished){
    HPEN pOldPen1 = dcMem.SelectPen(penLine1.m_hPen);
    _6bees_gdi::_6BeeDrawRect(dcMem,m_rectSelect,true,0);

    int width1 =abs(m_rectSelect.right-m_rectSelect.left);
    int height1=abs(m_rectSelect.bottom-m_rectSelect.top);

    realleftx= min(m_rectSelect.left,m_rectSelect.right);
    realtopy = min(m_rectSelect.top,m_rectSelect.bottom);
    realrightx  = max(m_rectSelect.left,m_rectSelect.right);
    realbottomy = max(m_rectSelect.top,m_rectSelect.bottom);

    m_rectSelect.left = realleftx;
    m_rectSelect.top = realtopy;
    m_rectSelect.right = realrightx;
    m_rectSelect.bottom = realbottomy;

    rect_w = abs(m_rectSelect.right-m_rectSelect.left);
    rect_h = abs(m_rectSelect.bottom-m_rectSelect.top);

    if (width1>MINRECT || height1>MINRECT){// if the cap area is too small(smaller than 30x30), we wont draw small rects.
      //draw size of capture area
      static WCHAR str3[20]={};
      wsprintf(str3, tsize, rect_w, rect_h);
      dcMem.SetBkMode(OPAQUE);
      dcMem.SetBkColor(SELECT_RECTCOLOR);
      dcMem.SetTextColor(INFO_TEXT);
      //dcMem.SelectFont(boldfont);
      dcMem.TextOutW(m_rectSelect.left+5, m_rectSelect.top+5, str3);

      RECT r1={realleftx-3,realtopy-3,realleftx+3,realtopy+3};
      _6bees_gdi::_6BeeDrawRect(dcMem,r1,true,0);

      r1.left += width1/2;r1.right += width1/2;  _6bees_gdi::_6BeeDrawRect(dcMem,r1,true,0);
      r1.left += width1/2;r1.right += width1/2;  _6bees_gdi::_6BeeDrawRect(dcMem,r1,true,0);

      r1.top += height1/2;r1.bottom += height1/2;  _6bees_gdi::_6BeeDrawRect(dcMem,r1,true,0);
      r1.top += height1/2;r1.bottom += height1/2;  _6bees_gdi::_6BeeDrawRect(dcMem,r1,true,0);

      r1.left -= width1/2;r1.right -= width1/2;  _6bees_gdi::_6BeeDrawRect(dcMem,r1,true,0);
      r1.left -= width1/2;r1.right -= width1/2;  _6bees_gdi::_6BeeDrawRect(dcMem,r1,true,0);
//.........这里部分代码省略.........
开发者ID:henrywoo,项目名称:ultraie,代码行数:101,代码来源:screendlg.cpp

示例13: DrawItem

void HistogramImg::DrawItem(LPDRAWITEMSTRUCT draw_item_struct)
{
    if (draw_item_struct->itemAction != ODA_DRAWENTIRE)
        return;

    CDC* dc= CDC::FromHandle(draw_item_struct->hDC);

    dc->SetBkMode(OPAQUE);
    COLORREF rgb_back= RGB(255,255,255);

    if (bmp_)
    {
        CRect rect;
        GetClientRect(rect);
        int width= bmp_->GetWidth();
        int height= bmp_->GetHeight();

        if (width > rect.Width())
            width = rect.Width();
        if (height > rect.Height())
            height = rect.Height();
        if (width != bmp_->GetWidth() || height != bmp_->GetHeight())
        {
            double ratio_org= double(bmp_->GetWidth()) / double(bmp_->GetHeight());
            if (double(width) / double(height) > ratio_org)
                width = static_cast<int>(height * ratio_org);
            else
                height = static_cast<int>(width / ratio_org);
        }

        CRect dest_rect= rect;

        if (width < dest_rect.Width())
            dest_rect.left = (dest_rect.Width() - width) / 2;
        else
            dest_rect.left = 0;

        if (height < rect.Height())
            dest_rect.top = (dest_rect.Height() - height) / 2;
        else
            dest_rect.top = 0;

        dest_rect.right = dest_rect.left + width;
        dest_rect.bottom = dest_rect.top + height;

        CRect fill_rect= rect;
        fill_rect.right = dest_rect.left;
        if (fill_rect.Width() > 0)
            dc->FillSolidRect(fill_rect, rgb_back);
        fill_rect.left = dest_rect.right;
        fill_rect.right = rect.right;
        if (fill_rect.Width() > 0)
            dc->FillSolidRect(fill_rect, rgb_back);

        fill_rect = rect;
        fill_rect.bottom = dest_rect.top;
        if (fill_rect.Height() > 0)
            dc->FillSolidRect(fill_rect, rgb_back);
        fill_rect.top = dest_rect.bottom;
        fill_rect.bottom = rect.bottom;
        if (fill_rect.Height() > 0)
            dc->FillSolidRect(fill_rect, rgb_back);

        bmp_->Draw(dc, dest_rect);
        image_rect_ = dest_rect;
    }

    if (!selection_rect_.IsRectEmpty())
    {
        CRect rect= selection_rect_;
        rect.NormalizeRect();
        CBitmap bmp;
        bmp.LoadBitmap(IDB_PATTERN);
        CBrush br;
        br.CreatePatternBrush(&bmp);
        dc->SetBkColor(RGB(255,255,255));
        dc->SetTextColor(RGB(255,0,0));
        dc->FrameRect(rect, &br);
    }
}
开发者ID:mikekov,项目名称:ExifPro,代码行数:80,代码来源:HistogramImg.cpp

示例14: DrawBackground

void CFileManagerDlg::DrawBackground(CDC * pDC)
{
  int xx, ww;
  int iSaved = pDC->SaveDC();

  CRect rt;
  GetClientRect(&rt);

  if (m_bmpBGTop.m_hObject == NULL)
    return;

  BITMAP bmTop, bmBottom;
  BITMAP bmNavBar, bmTitle, bmLogo, bmRBCorner;
  m_bmpBGTop.GetBitmap(&bmTop);
  m_bmpBGBottom.GetBitmap(&bmBottom);
  m_bmpNavBar.GetBitmap(&bmNavBar);
  m_bmpTitle.GetBitmap(&bmTitle);
  m_bmpLogo.GetBitmap(&bmLogo);
  m_bmpRBCorner.GetBitmap(&bmRBCorner);

  // Draw Top
  CBrush brush;
  brush.CreatePatternBrush(&m_bmpBGTop);
  CRect rtTop(rt.left, rt.top, rt.right, bmTop.bmHeight);
  pDC->FillRect(&rtTop, &brush);

  BLENDFUNCTION bf;
  memset(&bf, 0, sizeof(bf));
  bf.BlendOp = AC_SRC_OVER;
  bf.BlendFlags = 0;
  bf.SourceConstantAlpha = 255;
  bf.AlphaFormat = AC_SRC_ALPHA;

  CDC dcMem;
  dcMem.CreateCompatibleDC(pDC);

  /*if (!m_bMaximized)*/ {
    CRect rtItem;
    CWnd *pWnd = GetDlgItem(IDC_PIC_SYSMENU);
    if (pWnd != NULL) {
      pWnd->GetWindowRect(&rtItem);
      ScreenToClient(&rtItem);
      int sz = min(rtItem.Width(), rtItem.Height());
      ::DrawIconEx(*pDC, rtItem.left, rtItem.top, m_hIcon,
        sz, sz, 0, NULL, DI_NORMAL);
    }
    pWnd = GetDlgItem(IDC_PIC_TITLE);
    if (pWnd != NULL) {
      pWnd->GetWindowRect(&rtItem);
      ScreenToClient(&rtItem);
      dcMem.SelectObject(&m_bmpTitle);
      int margin = 2;
      pDC->AlphaBlend(
        rtItem.left, rtItem.top, bmTitle.bmWidth, bmTitle.bmHeight,
        &dcMem, 0, 0, bmTitle.bmWidth, bmTitle.bmHeight, bf);
    }
  }

//   CPoint pntLogo = GetLogoPos();
//   dcMem.SelectObject(&m_bmpLogo);
//   pDC->AlphaBlend(pntLogo.x, pntLogo.y, bmLogo.bmWidth, bmLogo.bmHeight,
//     &dcMem, 0, 0, bmLogo.bmWidth, bmLogo.bmHeight, bf);

  // Draw Navigation Bar
  dcMem.SelectObject(&m_bmpNavBar);
  ww = bmNavBar.bmWidth;
  for (xx = rt.left; xx < rt.right; xx += ww) {
    pDC->BitBlt(xx, rt.top + bmTop.bmHeight, ww, bmNavBar.bmHeight,
      &dcMem, 0, 0, SRCCOPY);
  }

  // Draw Bottom
  dcMem.SelectObject(&m_bmpBGBottom);
  ww = bmBottom.bmWidth;
  for (xx = rt.left; xx < rt.right; xx += ww) {
    pDC->BitBlt(xx, rt.bottom - bmBottom.bmHeight, ww, bmBottom.bmHeight,
      &dcMem, 0, 0, SRCCOPY);
  }

  // Draw Right-Bottom Corner
  dcMem.SelectObject(&m_bmpRBCorner);
  int margin = 2;
  pDC->AlphaBlend(
    rt.right - bmRBCorner.bmWidth - margin,
    rt.bottom - bmRBCorner.bmHeight - margin,
    bmRBCorner.bmWidth, bmRBCorner.bmHeight,
    &dcMem, 0, 0, bmRBCorner.bmWidth, bmRBCorner.bmHeight, bf);

  pDC->RestoreDC(iSaved);
}
开发者ID:StephanBusch,项目名称:EcoZip,代码行数:90,代码来源:FileManagerDlg.cpp

示例15: _OnDraw

void CColorPickerButton::_OnDraw(HDC hdc, RECT *prc, EGACOLOR color)
{
    CDC *pDC = CDC::FromHandle(hdc);
    if (pDC)
    {
        // Figure out the right color - do color 1 for now.
        RGBQUAD color1 = EGA_TO_RGBQUAD(color.color1);
        RGBQUAD color2 = EGA_TO_RGBQUAD(color.color2);

        CBitmap bm;
        if (CreateDCCompatiblePattern(color1, color2, pDC, &bm))
        {
            CBrush brushPat;
            if (brushPat.CreatePatternBrush(&bm))
            {
                CRect rcShrunk(prc->left + 1, prc->top + 1, prc->right - 1, prc->bottom - 1);
                pDC->FillRect(&rcShrunk, &brushPat);
            }
        }
       
        //int cx = RECTWIDTH(*prc) / 2;
        //int cy = RECTHEIGHT(*prc) / 2;
        //RECT rectOverlay = { prc->left + cx, prc->top + cy, prc->right, prc->bottom };
        int iModePrev = pDC->SetBkMode(TRANSPARENT);
        RGBQUAD colorCombine = _Combine(color1, color2);
        RGBQUAD colorTL = _Lighter(colorCombine);
        RGBQUAD colorBR = _Darker(colorCombine);

        // Draw an x maybe
        if (!_bOn)
        {
            /*
            RGBQUAD colorRedder = _Redden(colorCombine);
            CPen penX(PS_SOLID, 1, RGB_TO_COLORREF(colorRedder));
            HGDIOBJ hgdiObjOld = pDC->SelectObject(&penX);
            pDC->MoveTo(prc->left, prc->bottom);
            pDC->LineTo(prc->right, prc->top);
            pDC->MoveTo(prc->left, prc->top);
            pDC->LineTo(prc->right, prc->bottom);
            pDC->SelectObject(hgdiObjOld);*/
        }

        /*
        // Do highlights.
        CPen penTL(PS_SOLID, 2, RGB_TO_COLORREF(colorTL));
        HGDIOBJ hgdiObj = pDC->SelectObject(&penTL);
        pDC->MoveTo(prc->left + 1, prc->bottom - 1);
        pDC->LineTo(prc->left + 1, prc->top + 1);
        pDC->LineTo(prc->right - 1, prc->top + 1);
        CPen penBR(PS_SOLID, 2, RGB_TO_COLORREF(colorBR));
        pDC->SelectObject(&penBR);
        pDC->LineTo(prc->right -1 , prc->bottom - 1);
        pDC->LineTo(prc->left + 1, prc->bottom - 1);
        pDC->SelectObject(hgdiObj);*/

        // Draw some text.
        int iColorPrev = pDC->SetTextColor(_GetTextColor(colorCombine));
        CString text;
        GetWindowText(text);
        pDC->DrawText(text, prc, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
        pDC->SetTextColor(iColorPrev);

        CRect rcPadding(0, 0, 0, 0);
        if (_bOn)
        {
            CRect rcSrc(CPoint(0, 0), g_bitmapHighlight.GetSize());
            g_bitmapHighlight.AlphaBlendSkinParts(hdc, *prc, rcSrc, rcPadding, /*__EXT_BMP_FLAG_PREMULTIPLIED_RGB_CHANNELS |*/ CExtBitmap::__EDM_STRETCH, true, true, 0xFF);
        }
        else
        {
            CRect rcSrc(CPoint(0, 0), g_bitmapHighlightX.GetSize());
            g_bitmapHighlightX.AlphaBlendSkinParts(hdc, *prc, rcSrc, rcPadding, /*__EXT_BMP_FLAG_PREMULTIPLIED_RGB_CHANNELS |*/ CExtBitmap::__EDM_STRETCH, true, true, 0xFF);
        }

        pDC->SetBkMode(iModePrev);
    }
}
开发者ID:OmerMor,项目名称:SciCompanion,代码行数:77,代码来源:ColorButton.cpp


注:本文中的CBrush::CreatePatternBrush方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。