Exemplo n.º 1
0
COlePasteSpecialDialog::COlePasteSpecialDialog(DWORD dwFlags,
	COleDataObject* pDataObject, CWnd* pParentWnd) : COleDialog(pParentWnd)
{
	memset(&m_ps, 0, sizeof(m_ps)); // initialize structure to 0/NULL

	// fill in common part
	m_ps.cbStruct = sizeof(m_ps);
	m_ps.dwFlags = dwFlags | PSF_STAYONCLIPBOARDCHANGE;
	if (!afxData.bWin4 && AfxHelpEnabled())
		m_ps.dwFlags |= PSF_SHOWHELP;
	if (_AfxOlePropertiesEnabled())
		m_ps.dwFlags |= PSF_HIDECHANGEICON;
	m_ps.lpfnHook = AfxOleHookProc;
	m_nIDHelp = AFX_IDD_PASTESPECIAL;

	// get LPDATAOBJECT for paste special dialog
	COleDataObject dataObject;
	if (pDataObject == NULL)
	{
		VERIFY(dataObject.AttachClipboard());
		pDataObject = &dataObject;
	}
	ASSERT(pDataObject != NULL);
	m_ps.lpSrcDataObj = pDataObject->GetIDataObject(TRUE);

	// complete initialization
	m_ps.arrPasteEntries = NULL;
	m_ps.cPasteEntries = 0;
	m_ps.arrLinkTypes = m_arrLinkTypes;
	m_ps.cLinkTypes = 0;
}
Exemplo n.º 2
0
bool CMyStatic::CanPaste() const
{
	bool bRet = false;
	COleDataObject DataObj;
	if (DataObj.AttachClipboard())
		bRet = (DropType::DropNothing != GetDropType(&DataObj));
	return bRet;
}
Exemplo n.º 3
0
//-------------------------------------------------------------------//
// Paste()																				//
//-------------------------------------------------------------------//
void OleListCtrl::Paste( 
	PASTEMODE ePasteMode 
) {
	COleDataObject DataObject;

	if ( DataObject.AttachClipboard() )
	{
		// Unarchive the data into the DragData array.
		ExtractDropData( 
			&DataObject
		);

		// This allows us to manipulate the drag data 
		// before we add it as new list items.
		ProcessNewDragData( 
			DROPEFFECT_MOVE	// dropEffect
		);

		// PASTE_REPLACE_ALL, PASTE_TOP default.
		int nUnderCursor = 0;

		switch( ePasteMode )
		{
			case PASTE_BOTTOM:
				nUnderCursor = GetItemCount();
				break;
			case PASTE_REPLACE_ALL:
				DeleteAllItems();
				break;
			case PASTE_AT_SELECTION:
				nUnderCursor = GetNextItem( -1, LVNI_FOCUSED );
				if ( nUnderCursor == -1 )
					nUnderCursor = GetItemCount();
				break;
			default:
				break;
		}

		if (
			AddItemsFromDragData( 
				nUnderCursor,
				false				// bInsertAfter
			)
		) {
			// If we added anything we need to redraw.  This may also
			// e.g. update the caption and icon and mark the list "dirty"
			// in derived classes.
			UpdateAfterDrop( nUnderCursor, true );
		}
		
		// Clear the drag contents, now that we have added them.
		// Don't worry, the clipboard hasn't changed, in case we
		// wanted to add the items again!  :>
		Items.RemoveAll();

	}
}
Exemplo n.º 4
0
void CEx27bView::OnUpdateEditPaste(CCmdUI* pCmdUI) 
{
    // Make sure that object data is available
	COleDataObject dataObject;
	if (dataObject.AttachClipboard() &&
    	dataObject.IsDataAvailable(m_cfEmbedded)) {
        pCmdUI->Enable(TRUE);
    } else {
    	pCmdUI->Enable(FALSE);
    }
}
Exemplo n.º 5
0
void CEx27bView::OnEditPaste() 
{
	CEx27bDoc* pDoc = GetDocument();
	COleDataObject dataObject;
	VERIFY(dataObject.AttachClipboard());
	pDoc->DeleteContents();
	DoPasteObjectDescriptor(&dataObject);
	DoPasteObject(&dataObject);
	SetViewAdvise();
	GetSize();
	pDoc->SetModifiedFlag();
	pDoc->UpdateAllViews(NULL);
}
Exemplo n.º 6
0
//-------------------------------------------------------------------//
// OnUpdatePaste()																	//
//-------------------------------------------------------------------//
// Disable paste if nothing's available.
// Nice of MultiColumnSortListCtrl::DisplayRightClickMenu() to
// force checks for ON_UPDATE_COMMAND_UI's.
//-------------------------------------------------------------------//
void OleListCtrl::OnUpdatePaste(CCmdUI* pCmdUI) 
{
	bool bHaveData = false;

	COleDataObject DataObject;
	if ( DataObject.AttachClipboard() )
	{
		// Do we have OLE data in the DragData array?
		bHaveData = bHaveValidDropData( &DataObject );
	}

	pCmdUI->Enable( bHaveData );
}
Exemplo n.º 7
0
///////////////////////////////////////////////////
// Verify that data you can handle is on the clipboard.
///////////////////////////////////////////////////
BOOL CDragDropMgr::OkToPaste()
{
    COleDataObject obj;

    BOOL bOk = FALSE;

    if (!obj.AttachClipboard())
        return FALSE;
    
    for (int i=0;i < m_nFormats.GetSize() && !bOk;i++)
    {
        UINT nF = m_nFormats.GetAt(i);
        bOk = obj.IsDataAvailable(m_nFormats.GetAt(i));
    }

    return bOk;
}
Exemplo n.º 8
0
void COXMulticlipboardDlg::ClipToPocket(COXClipPocket *pPocket)
{
	//the function opens clipboard and
	//calls virtual ClipObjectToPocket()
	//to make copy of the clipboard data
	ASSERT(pPocket);

	COleDataObject clipobj;

	if (!clipobj.AttachClipboard())
	{
		TRACE0("CMulticlipboardDlg::ClipToPocket : Failed to attach to clipboard\r\n");
		return;
	}

	ClipObjectToPocket(pPocket, &clipobj);
}
Exemplo n.º 9
0
void CHexEdit::OnEditPaste() 
{
	COleDataObject	obj;	
	if (obj.AttachClipboard()) 
	{
		HGLOBAL hmem = NULL;
		if (obj.IsDataAvailable(RegisterClipboardFormat("BinaryData"))) 
		{
			hmem = obj.GetGlobalData(RegisterClipboardFormat("BinaryData"));
		}	
		else if (obj.IsDataAvailable(CF_TEXT)) 
		{
			hmem = obj.GetGlobalData(CF_TEXT);
		}
		if(hmem)
		{
			LPBYTE	p = (BYTE*)::GlobalLock(hmem);
			DWORD	dwSizeMem=::GlobalSize(hmem);
			DWORD	dwSizeSel=GetSelLength();
			DWORD	dwLen =dwSizeMem>dwSizeSel?dwSizeSel:dwSizeMem;
			int		insert;
			
			NormalizeSel();
			if(m_selStart == 0xffffffff)
			{
				if(m_currentMode == EDIT_LOW)
					m_currentAddress++;
				insert = m_currentAddress;
				SelInsert(m_currentAddress, dwLen);
			}
			else
			{
				insert = m_selStart;
				SelDelete(m_selStart,m_selStart+dwLen-1);
				SelInsert(insert, dwLen);
			}
			memcpy(m_pData+insert, p, dwLen);
			
			m_currentAddress = insert+dwLen;
//			RepositionCaret(m_currentAddress);
			ResetPos();
			Invalidate(FALSE);
			::GlobalUnlock(hmem);
		}
	}
}
Exemplo n.º 10
0
void CHexEdit::OnEditPaste() 
{
	COleDataObject	obj;	
	if (obj.AttachClipboard()) 
	{
		HGLOBAL hmem = NULL;
		if (obj.IsDataAvailable(RegisterClipboardFormat(L"BinaryData"))) 
		{
			hmem = obj.GetGlobalData(RegisterClipboardFormat(L"BinaryData"));
		}	
		else if (obj.IsDataAvailable(CF_TEXT)) 
		{
			hmem = obj.GetGlobalData(CF_TEXT);
		}
		if(hmem)
		{
			LPBYTE	p = (BYTE*)::GlobalLock(hmem);
			DWORD	dwLen = ::GlobalSize(hmem);
			int		insert;
			int		oa = m_currentAddress;
			
			NormalizeSel();
			if(m_selStart == 0xffffffff)
			{
				if(m_currentMode == EDIT_LOW)
					m_currentAddress++;
				insert = m_currentAddress;
				SelInsert(m_currentAddress, dwLen);
			}
			else
			{
				insert = m_selStart;
				SelDelete(m_selStart, m_selEnd);
				SelInsert(insert, dwLen);
				SetSel(-1, -1);
			}

			memcpy(m_pData+insert, p, dwLen);

			m_currentAddress = oa;
			RedrawWindow();
			::GlobalUnlock(hmem);
		}
	}
}
Exemplo n.º 11
0
void CHexEdit::OnContextMenu(CWnd*, CPoint point)
{
    // by latelee
	#if 0
	// CG: This block was added by the Pop-up Menu component
	{
		if (point.x == -1 && point.y == -1)
		{
			//keystroke invocation
			CRect rect;
			GetClientRect(rect);
			ClientToScreen(rect);
			
			point = rect.TopLeft();
			point.Offset(5, 5);
		}
		
		CMenu menu;
		VERIFY(menu.LoadMenu(CG_IDR_POPUP_HEX_EDIT));
		
		CMenu* pPopup = menu.GetSubMenu(0);
		ASSERT(pPopup != NULL);
		
		pPopup->EnableMenuItem(ID_EDIT_UNDO, MF_GRAYED|MF_DISABLED|MF_BYCOMMAND);
		if(!IsSelected())
		{
			pPopup->EnableMenuItem(ID_EDIT_CLEAR, MF_GRAYED|MF_DISABLED|MF_BYCOMMAND);
			pPopup->EnableMenuItem(ID_EDIT_CUT, MF_GRAYED|MF_DISABLED|MF_BYCOMMAND);
			pPopup->EnableMenuItem(ID_EDIT_COPY, MF_GRAYED|MF_DISABLED|MF_BYCOMMAND);
		}
		{
			COleDataObject	obj;	
			if (obj.AttachClipboard()) 
			{
				if(!obj.IsDataAvailable(CF_TEXT) && !obj.IsDataAvailable(RegisterClipboardFormat("BinaryData")))
					pPopup->EnableMenuItem(ID_EDIT_PASTE, MF_GRAYED|MF_DISABLED|MF_BYCOMMAND);
			}
		}
		
		pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y,
			this);
	}
    #endif
}
Exemplo n.º 12
0
	bool zstringEx::tools_getClipboardText()
	{    
		COleDataObject obj;

		if (obj.AttachClipboard()) 
		{
				if (obj.IsDataAvailable(CF_TEXT)) 
				{
					HGLOBAL hmem = obj.GetGlobalData(CF_TEXT);                  
					CMemFile sf((BYTE*) ::GlobalLock(hmem), (UINT)::GlobalSize(hmem));
					mem_data.mem_resizenull((UINT)::GlobalSize(hmem));
					sf.Read(mem_data.mem_string, (UINT)::GlobalSize(hmem));
					::GlobalUnlock(hmem);
					sf.Close();	
					return true;
				}
		}
		return false;
	}
Exemplo n.º 13
0
void CUIDesignerView::OnEditPaste()
{
	COleDataObject dataObject;
	dataObject.AttachClipboard();

	if(dataObject.IsDataAvailable(m_cfUI))
	{
		CFile* pFile = dataObject.GetFileData(m_cfUI);
		if (pFile == NULL)
			return;

		int len = (int)pFile->GetLength();
		char* pstrXML  = new char[len];
		pFile->Read(pstrXML, len);

		PasteUI(StringConvertor::Utf8ToWide(pstrXML));

		delete[] pstrXML;
		delete pFile;
	}
}
Exemplo n.º 14
0
void kGUISystemWin::Paste(kGUIString *s)
{
	COleDataObject	obj;

	if (obj.AttachClipboard())
	{
#if 0
		if (obj.IsDataAvailable(CF_UNICODETEXT))
		{
			HGLOBAL hmem = obj.GetGlobalData(CF_UNICODETEXT);
			CMemFile sf((BYTE*) ::GlobalLock(hmem),(UINT) ::GlobalSize(hmem));
			CString buffer;

			LPSTR str = buffer.GetBufferSetLength((int)::GlobalSize(hmem));
			sf.Read(str,(UINT) ::GlobalSize(hmem));
			::GlobalUnlock(hmem);

			s->SetEncoding(ENCODING_UTF8);
			s->SetString(buffer);
		}
		else if (obj.IsDataAvailable(CF_TEXT))
#else
		if (obj.IsDataAvailable(CF_TEXT))
#endif
		{
			HGLOBAL hmem = obj.GetGlobalData(CF_TEXT);
			CMemFile sf((BYTE*) ::GlobalLock(hmem),(UINT) ::GlobalSize(hmem));
			CString buffer;

			LPSTR str = buffer.GetBufferSetLength((int)::GlobalSize(hmem));
			sf.Read(str,(UINT) ::GlobalSize(hmem));
			::GlobalUnlock(hmem);

//			s->SetEncoding(ENCODING_UTF8);
			s->SetEncoding(ENCODING_8BIT);
			s->SetString(buffer);
		}
	}
}
Exemplo n.º 15
0
///////////////////////////////////////////////////
// Verify that data you can handle is on the clipboard
// or in the drop buffer data object.
//
// If checking the clipboard, set pDataObject to NULL.
///////////////////////////////////////////////////
CString CDragDropMgr::AvailableDataType(COleDataObject* pDataObject)
{
    COleDataObject obj;

    //Assume caller is checking the clipboard
    //because no OLE data object was passed in
    if (pDataObject == NULL)
    {
        pDataObject = &obj;

        if (!obj.AttachClipboard())
            return "";
    }
    
    CString csFormat = "";
    
    for (int i=0;i < m_nFormats.GetSize() && csFormat.IsEmpty();i++)
    {
        if (pDataObject->IsDataAvailable(m_nFormats.GetAt(i)))
            csFormat = m_csFormats.GetAt(i);
    }

    return csFormat;
}
Exemplo n.º 16
0
void CEditEx::OnContextMenu(CWnd* pWnd, CPoint point)
{
	if (point.x == -1 && point.y == -1)
	{
		//keystroke invocation
		CRect rect;
		GetClientRect(rect);
		ClientToScreen(rect);

		point = rect.TopLeft();
		point.Offset(5, 5);
	}

	CMenu menu;
	VERIFY(menu.LoadMenu(RIGHTBUTTON));

	CMenu* pPopup = menu.GetSubMenu(0);
	ASSERT(pPopup != NULL);

	//pPopup->EnableMenuItem(ID_EDIT_UNDO, MF_GRAYED|MF_DISABLED|MF_BYCOMMAND);
	//pPopup->EnableMenuItem(ID_EDIT_CLEAR, MF_GRAYED|MF_DISABLED|MF_BYCOMMAND);
	//pPopup->EnableMenuItem(ID_EDIT_CUT, MF_GRAYED|MF_DISABLED|MF_BYCOMMAND);
	//pPopup->EnableMenuItem(ID_EDIT_COPY, MF_GRAYED|MF_DISABLED|MF_BYCOMMAND);
	
	COleDataObject	obj;	
	if (obj.AttachClipboard()) 
	{
		if(!obj.IsDataAvailable(CF_TEXT) && !obj.IsDataAvailable(RegisterClipboardFormat(L"BinaryData")))
				pPopup->EnableMenuItem(ID_EDIT_PASTE, MF_GRAYED|MF_DISABLED|MF_BYCOMMAND);
	}
	

	pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y,
		this);
    return;
}
Exemplo n.º 17
0
////////////////////////////////////////////////////////
//This function loads data from the clipboard
//or drag/drop into a local object of the proper
//type for use.
//
//If pasting from clipboard, pDataObject should be NULL.
//
//You usually call this function from:
//
//1) Your view class's OnDrop() method when a drag-
//   drop operation ends, to load the data for use.
//
//2) Your view (or document) class's OnEditPaste()
//   method when doing a paste from the clipboard.
////////////////////////////////////////////////////////
BOOL CDragDropMgr::DoDrop(
                   CObject*        pO,
                   COleDataObject* pDataObject,
                   LPCTSTR         lpstrFormat)
{
//	try
	{
		UINT format = ::RegisterClipboardFormat(lpstrFormat);

		COleDataObject* pObj = NULL;

		// If from clipboard, then there is no
		// data object passed in, so use a local copy
		if (pDataObject == NULL)
			pObj = new COleDataObject();

 		else
			pObj = pDataObject;

		// Make sure basic data is OK
    	if (pObj == NULL)
    	    return FALSE;

		else if (pDataObject == NULL &&
 			!pObj->AttachClipboard())
			return FALSE;

		else if (format == 0 || pO == NULL)
			return FALSE;

		else if (!pObj->IsDataAvailable(format))
			return FALSE;

		FORMATETC fe;

		fe.cfFormat = format;
		fe.tymed    = TYMED_HGLOBAL;
		fe.lindex   = -1;
		fe.dwAspect = DVASPECT_CONTENT;
		fe.ptd      = NULL;

		// Fetch the data from the OLE data object
		HGLOBAL hMem = pObj->GetGlobalData(format,&fe);

		if (hMem == NULL)
			return FALSE;

	//	TRY
		{
			CMemFile mf((BYTE*)::GlobalLock(hMem), ::GlobalSize(hMem));

			CArchive ar(&mf, CArchive::load);
			pO->Serialize(ar); 
			 ar.Close();

			::GlobalUnlock(hMem);

			pObj->Release();

			if (pDataObject == NULL)
				delete pObj;

			return TRUE;
		}

	/*	CATCH_ALL(ce)
		{
			pObj->Release();

			if (pDataObject == NULL)
				delete pObj;

		return FALSE;
		}

		END_CATCH_ALL*/
	}

/*	catch(...)
	{
		CErrorDlg error;
		error.Error("Drag/drop error", "A serious error occured while dropping objects. Please report this to the Construct team.");
		return FALSE;
	}*/

	return TRUE;
}
Exemplo n.º 18
0
////////////////////////////////////////////////////////
//This function loads CF_TEXT data from the clipboard
//or drag/drop into a CStringArray, one line of text
//per array entry. A null in the input text
//denotes a new line.
//
//If pasting from clipboard, pDataObject should be NULL.
//
//You usually call this function from:
//
//1) Your view class's OnDrop() method when a drag-
//   drop operation ends, to load the data for use.
//
//2) Your view (or document) class's OnEditPaste()
//   method when doing a paste from the clipboard.
////////////////////////////////////////////////////////
BOOL CDragDropMgr::GetCFText(
                   CStringArray*   pcsText,
                   COleDataObject* pDataObject)
{
    BOOL bOk = FALSE;

    CString csLine = "";

    COleDataObject* pObj = NULL;

    //If from clipboard, then there is no
    //data object passed in, so use a local copy
    if (pDataObject == NULL)
        pObj = new COleDataObject();

    else
        pObj = pDataObject;

    //Make sure basic data is OK
    if (pObj == NULL)
        return FALSE;

    else if ((pDataObject == NULL &&
              !pObj->AttachClipboard())       ||
              pcsText== NULL                  ||
              !pObj->IsDataAvailable(CF_TEXT))
    {
        pObj->Release();

        if (pDataObject == NULL)
            delete pObj;

        return FALSE;
    }

    //The format etc struct tells how the data
    //should be transferred.
    //Do NOT use the MFC defaults here - they are no good
    FORMATETC fe;

    fe.cfFormat = CF_TEXT;
    fe.tymed    = TYMED_HGLOBAL;
    fe.lindex   = -1;
    fe.dwAspect = DVASPECT_CONTENT;
    fe.ptd      = NULL;

    //Fetch the data from the OLE data object
    HGLOBAL hMem = pObj->GetGlobalData(CF_TEXT,&fe);

    if (hMem != NULL)
    {
        char* pchT = (char*)::GlobalLock(hMem);

        if (pchT != NULL)
        {
            DWORD dwSize = ::GlobalSize(hMem);

            int  i     = 0;
            BOOL bDone = FALSE;

            while (!bDone)
            {
               //Hit a crlf: Add current line
               if (pchT[i+1] == '\n' && pchT[i] == '\r')
               {
                  pcsText->Add(csLine);
                  csLine = "";
                  i += 2;
               }

               //End of the block: Add final line
               else if (pchT[i] == '\0' || i >= DD_MAXCHARS)
               {
                  pcsText->Add(csLine);
                  bDone = TRUE;;
               }

               //Normal character: Add to line being built
               else
               {
                  csLine += pchT[i];
                  i++;
               }
            }

            ::GlobalUnlock(hMem);

            bOk = TRUE;
        }
    }   //hmem not null

    pObj->Release();

    if (pDataObject == NULL)
        delete pObj;

    return bOk;
}
Exemplo n.º 19
0
void CMyStatic::OnEditPaste()
{
	COleDataObject DataObj;
	if (DataObj.AttachClipboard())
		PutOleData(&DataObj, GetDropType(&DataObj));
}
Exemplo n.º 20
0
void SourceEdit::OnConvertPaste(NMHDR* hdr, LRESULT* res)
{
  SCNXConvertPaste* cp = (SCNXConvertPaste*)hdr;
  *res = 0;

  // Get the source of the data
  COleDataObject data;
  if (cp->source)
    data.Attach((LPDATAOBJECT)(cp->source),FALSE);
  else
    data.AttachClipboard();

  // Try to interpret tables and leading white space
  if (data.IsDataAvailable(CF_UNICODETEXT))
  {
    CStringW theText(cp->utext,cp->ulen);
    CStringW newText, line;
    newText.Preallocate(theText.GetLength());

    bool foundTable = false;
    bool inTable = false;

    int charPos = 0, lineCount = 0;
    while (GetNextLine(theText,line,charPos))
    {
      if (inTable)
      {
        CArray<CStringW> tokens;
        TokenizeLine(line,tokens);

        // Separate multiple tokens with tabs: if less than two tokens,
        // we're at the end of the table
        if (tokens.GetSize() > 1)
        {
          line.Empty();
          for (int j = 0; j < tokens.GetSize(); j++)
          {
            if (j > 0)
              line.AppendChar(L'\t');
            line.Append(tokens.GetAt(j));
          }
        }
        else
          inTable = false;
      }
      else
      {
        // Look for the start of a table
        if (line.Left(6).CompareNoCase(L"table ") == 0)
        {
          inTable = true;
          foundTable = true;
        }

        // Replace any leading blocks of 4 spaces
        int i = 0;
        while (i >= 0)
        {
          if (line.Mid(i,4).Compare(L"    ") == 0)
          {
            line.Delete(i,3);
            line.SetAt(i,L'\t');
            i++;
          }
          else
            i = -1;
        }
      }

      if (lineCount > 0)
        newText.AppendChar(L'\n');
      newText.Append(line);
      lineCount++;
    }

    CString newTextUtf = TextFormat::UnicodeToUTF8(newText);
		cp->text = new char[newTextUtf.GetLength() + 1];
    strcpy(cp->text,newTextUtf);
    *res = 1;
  }
}
//********************************************************************************
void CBCGPImageEditDlg::OnBcgToolPaste() 
{
	CBCGPLocalResource locaRes;

	COleDataObject data;
	if (!data.AttachClipboard ())
	{
		AfxMessageBox (IDP_BCGBARRES_CANT_PASTE_BITMAP);
		return;
	}

	if (!data.IsDataAvailable (CF_BITMAP))
	{
		AfxMessageBox (IDP_BCGBARRES_CANT_PASTE_BITMAP);
		return;
	}

	tagSTGMEDIUM dataMedium;
	if (!data.GetData (CF_BITMAP, &dataMedium))
	{
		AfxMessageBox (IDP_BCGBARRES_CANT_PASTE_BITMAP);
		return;
	}

	CBitmap* pBmpClip = CBitmap::FromHandle (dataMedium.hBitmap);
	if (pBmpClip == NULL)
	{
		AfxMessageBox (IDP_BCGBARRES_CANT_PASTE_BITMAP);
		return;
	}

	BITMAP bmp;
	pBmpClip->GetBitmap (&bmp);

	CDC memDCDst;
	CDC memDCSrc;

	memDCSrc.CreateCompatibleDC (NULL);
	memDCDst.CreateCompatibleDC (NULL);
	
	CBitmap* pSrcOldBitmap = memDCSrc.SelectObject (pBmpClip);
	if (pSrcOldBitmap == NULL)
	{
		AfxMessageBox (IDP_BCGBARRES_CANT_PASTE_BITMAP);
		return;
	}

	CBitmap* pDstOldBitmap = memDCDst.SelectObject (m_pBitmap);
	if (pDstOldBitmap == NULL)
	{
		AfxMessageBox (IDP_BCGBARRES_CANT_PASTE_BITMAP);
		
		memDCSrc.SelectObject (pSrcOldBitmap);
		return;
	}

	memDCDst.FillRect (CRect (0, 0, m_sizeImage.cx, m_sizeImage.cy), 
						&globalData.brBtnFace);

	int x = max (0, (m_sizeImage.cx - bmp.bmWidth) / 2);
	int y = max (0, (m_sizeImage.cy - bmp.bmHeight) / 2);

	CBCGPToolBarImages::TransparentBlt (memDCDst.GetSafeHdc (),
		x, y, m_sizeImage.cx, m_sizeImage.cy,
		&memDCSrc, 0, 0, RGB (192, 192, 192));

	memDCDst.SelectObject (pDstOldBitmap);
	memDCSrc.SelectObject (pSrcOldBitmap);

	InvalidateRect (m_rectPreviewImage);
	m_wndLargeDrawArea.Invalidate ();
}
Exemplo n.º 22
0
void CDataView::OnUpdateEditPaste(CCmdUI* pCmdUI) 
{
    // Attach a COleDataObject to the clipboard see if there is any data
    COleDataObject obj;
    pCmdUI->Enable(obj.AttachClipboard() && obj.IsDataAvailable(CF_TEXT)); 
}
Exemplo n.º 23
0
// Called within Copy Thread:
void CCopyThread::OnClipboardChange()
{
	Log(_T("OnClipboardChange - Start"));

	SyncConfig(); // synchronize with the main thread's copy configuration
	
	// if we are told not to copy on change, then we have nothing to do.
	if(!m_LocalConfig.m_bCopyOnChange)
		return;
	
	CClip* pClip = new CClip;

	CClipTypes* pSupportedTypes = m_LocalConfig.m_pSupportedTypes;
	bool bDeleteMemory = false;

	//If we are copying from a Ditto Buffer then save all to the database, so when we paste this it will paste 
	//just like you were using Ctrl-V
	if(theApp.m_CopyBuffer.Active())
	{
		Log(_T("LoadFromClipboard - Copy buffer Active Start"));

		pSupportedTypes = new CClipTypes;
		if(pSupportedTypes)
		{
			bDeleteMemory = true;
			COleDataObject oleData;

			if(oleData.AttachClipboard())
			{
				oleData.BeginEnumFormats();

				FORMATETC format;
				while(oleData.GetNextFormat(&format))
				{
					pSupportedTypes->Add(format.cfFormat);
				}

				oleData.Release();
			}
		}
		else
		{
			pSupportedTypes = m_LocalConfig.m_pSupportedTypes;
		}

		Log(_T("LoadFromClipboard - Copy buffer Active End"));
	}

	Log(_T("LoadFromClipboard - Before"));
	bool bResult = pClip->LoadFromClipboard(pSupportedTypes);
	Log(_T("LoadFromClipboard - After"));

	if(!bResult)
	{
		DWORD delay = CGetSetOptions::GetNoFormatsRetryDelay();
		if(delay > 0)
		{
			Log(StrF(_T("LoadFromClipboard didn't find any clips to save, sleeping %dms, then trying again"), delay));
			Sleep(delay);

			Log(_T("LoadFromClipboard #2 - Before"));
			bResult = pClip->LoadFromClipboard(pSupportedTypes);
			Log(_T("LoadFromClipboard #2 - After"));
		}
		else
		{
			Log(_T("LoadFromClipboard didn't find any clips to save, retry setting is not set, not retrying"));
		}
	}

	if(bDeleteMemory)
	{
		delete pSupportedTypes;
		pSupportedTypes = NULL;
	}
	
	if(!bResult)
	{
		delete pClip;
		return; // error
	}
	
	if(m_LocalConfig.m_bAsyncCopy)
		::PostMessage(m_LocalConfig.m_hClipHandler, WM_CLIPBOARD_COPIED, (WPARAM)pClip, 0);
	else
		::SendMessage(m_LocalConfig.m_hClipHandler, WM_CLIPBOARD_COPIED, (WPARAM)pClip, 0);

	Log(_T("OnClipboardChange - End"));
}