🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: cn.bbs.comp.program
1 messages
1 total messages Started by Pineapple Tity Thu, 18 Dec 1997 00:00
Re: ��̣�memdc Ϊʲô��������ͼ��
#2485
Author: Pineapple Tity
Date: Thu, 18 Dec 1997 00:00
73 lines
2978 bytes
�ϻ� Sad Song ˵��...
> HDC hMemDC; 
>     hMemDC=::CreateCompatibleDC(hdc); 
> //      HBITMAP hBM=::CreateCompatibleBitmap(dc.m_ps.hdc,rect.right-rect.left,rect.bottom-rect.top); 
> //      HBITMAP hOldBM=(HBITMAP)SelectObject(hMemDC,hBM); 
>      
>     SetBkMode(hMemDC,OPAQUE);  
> //    SetBkMode(hMemDC,TRANSPARENT); 
>     SetBkColor(hMemDC,RGB(255,0,0));  
>         GetClientRect(&rect); 
>   ::FillRect(hMemDC,&rect,(HBRUSH)GetStockObject(BLACK_BRUSH)); 
>   ::BitBlt(hdc,rect.left,rect.top,rect.right-rect.left,rect.bottom-rect.top,hMemDC,0,0,SRCCOPY); 
>    
>   DeleteObject(hMemDC); 
> ���� onpaint����ͼ����hmemdc�л�ͼ��������һ�λ�����Ļ�� 
> ����һ�㷴Ӧ��������ô���°��� 
> ���λ�����ͽ̡� 
>  �����Ӱ 
 
��û��ѡλͼ���ڴ�DC����ȷ�Ĵ������£�
��SDK��
        RECT    rect;
        HDC hdc=pDC->m_hDC;
        GetClientRect(&rect);

        // create display memory DC
        HDC hMemDC=::CreateCompatibleDC(hdc);
        // create new bitmap
        HBITMAP bm=::CreateCompatibleBitmap(hdc,rect.right,rect.bottom);
        // select new bitmap and save old
        HBITMAP hOldBM=(HBITMAP)SelectObject(hMemDC,bm);

   ::FillRect(hMemDC,&rect,(HBRUSH)GetStockObject(BLACK_BRUSH));
   ::BitBlt(hdc,rect.left,rect.top,rect.right-rect.left,
           rect.bottom-rect.top,hMemDC,0,0,SRCCOPY);

   SelectObject(hMemDC,hOldBM);

��MFC��
        CDC             *m_pMemDC;
        CRect   rect;
        GetClientRect(&rect);

// create display memory DC
        m_pMemDC=new CDC;
        m_pMemDC->CreateCompatibleDC(pDC);

// create new bitmap
        CBitmap *pBitmap=new CBitmap;
        pBitmap->CreateCompatibleBitmap(pDC,rect.right,rect.bottom);

// select new bitmap and save old
        CBitmap *pOldBitmap=(CBitmap *)m_pMemDC->SelectObject(pBitmap);

        CBrush  backgroundBrush
                ((COLORREF)::GetSysColor(COLOR_3DFACE));
        CBrush  *pOldBrush=m_pMemDC->SelectObject(&backgroundBrush);
        m_pMemDC->PatBlt(0,0,rect.right,rect.bottom,PATCOPY);

        pDC->BitBlt(rect.left,rect.top,
                rect.Width(),rect.Height(),m_pMemDC,
                rect.left,rect.top,SRCCOPY);

        m_pMemDC->SelectObject(pOldBitmap);
        m_pMemDC->SelectObject(pOldBrush);


��

 ����
--
 * Origin: NJU PowerBBS <bbs.nju.edu.cn>
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads