1. 程式人生 > >用程式碼操縱剪下板

用程式碼操縱剪下板

  if  (   OpenClipboard()   )   
  {   
                    EmptyClipboard();  
                    //create  some   data   
                    CBitmap  *   junk   =   new  CBitmap();   
                    CClientDC  cdc(this);   
                    CDC  dc;   
                    dc.CreateCompatibleDC(&cdc);  
                    CRect  client(0,0,200,200);   
                    junk->CreateCompatibleBitmap(&cdc,client.Width(),client.Height());  
                    dc.SelectObject(junk);  
      
                    //call  draw   routine   here   that  makes   GDI   calls   
                    DrawImage(&dc,CString("Bitmap"));  
      
                    //put  the   data   on   the  clipboard   
                    SetClipboardData(CF_BITMAP,junk->m_hObject);  
                    CloseClipboard();  
      
                    //copy  has   been   made   on  clipboard   so   we   can  delete   
                    delete  junk;   
  }