Exemplo n.º 1
0
/*
 * GUI version of mch_init().
 */
    void
mch_init()
{
    extern int _fmode;


    /* Let critical errors result in a failure, not in a dialog box.  Required
     * for the timestamp test to work on removed floppies. */
    SetErrorMode(SEM_FAILCRITICALERRORS);

    _fmode = O_BINARY;		/* we do our own CR-LF translation */

    /* Specify window size.  Is there a place to get the default from? */
    Rows = 25;
    Columns = 80;


    set_option_value((char_u *)"grepprg", 0, (char_u *)"grep -n", 0);

#ifdef FEAT_CLIPBOARD
    clip_init(TRUE);

    /*
     * Vim's own clipboard format recognises whether the text is char, line,
     * or rectangular block.  Only useful for copying between two Vims.
     * "VimClipboard" was used for previous versions, using the first
     * character to specify MCHAR, MLINE or MBLOCK.
     */
    clip_star.format = RegisterClipboardFormat("VimClipboard2");
    clip_star.format_raw = RegisterClipboardFormat("VimRawBytes");
#endif
}
Exemplo n.º 2
0
//----------------------------------------DataObject--------------------------------------------------
CDataObject::CDataObject(DropDataWindow * dataWindow) {
	m_refs = 1;
	m_filedescriptorID = RegisterClipboardFormat(CFSTR_FILEDESCRIPTOR);
	m_filecontentsID = RegisterClipboardFormat(CFSTR_FILECONTENTS);

	m_dataWindow = dataWindow;
}
Exemplo n.º 3
0
void CHexEdit::OnEditCopy() 
{
	COleDataSource*		pSource = new COleDataSource();
	EmptyClipboard();
	if(m_currentMode != EDIT_ASCII)
	{
		int			dwLen = (m_selEnd-m_selStart);
		HGLOBAL		hMemb = ::GlobalAlloc(GMEM_MOVEABLE|GMEM_DDESHARE|GMEM_ZEROINIT, m_selEnd-m_selStart);
		HGLOBAL		hMema = ::GlobalAlloc(GMEM_MOVEABLE|GMEM_DDESHARE|GMEM_ZEROINIT, (dwLen) * 3);

		if (!hMema) 
			return;

		// copy binary
		LPBYTE	p = (BYTE*)::GlobalLock(hMemb);
		memcpy(p, m_pData+m_selStart, dwLen);
		::GlobalUnlock(hMemb);
		
		// copy ascii
		p = (BYTE*)::GlobalLock(hMema);
		for(int	 i = 0; i < dwLen;)
		{
			TOHEX(m_pData[m_selStart+i], p);
			*p++ = ' ';
			i++;
		}

		::GlobalUnlock(hMema);

		pSource->CacheGlobalData(RegisterClipboardFormat(L"BinaryData"), hMemb);	
		pSource->CacheGlobalData(CF_TEXT, hMema);	
	}
	else
	{
		HGLOBAL				hMemb = ::GlobalAlloc(GMEM_MOVEABLE|GMEM_DDESHARE|GMEM_ZEROINIT, m_selEnd-m_selStart);
		HGLOBAL				hMema = ::GlobalAlloc(GMEM_MOVEABLE|GMEM_DDESHARE|GMEM_ZEROINIT, m_selEnd-m_selStart);
		if (!hMemb || !hMema) 
			return;

		// copy binary
		LPBYTE	p = (BYTE*)::GlobalLock(hMemb);
		int		dwLen = m_selEnd-m_selStart;

		memcpy(p, m_pData+m_selStart, dwLen);
		::GlobalUnlock(hMemb);
		
		// copy ascii
		p = (BYTE*)::GlobalLock(hMema);
		memcpy(p, m_pData+m_selStart, dwLen);
		for(int i = 0; i < dwLen; p++, i++)
			if(!isprint(*p))
				*p = '.';
		::GlobalUnlock(hMema);

		pSource->CacheGlobalData(RegisterClipboardFormat(L"BinaryData"), hMemb);	
		pSource->CacheGlobalData(CF_TEXT, hMema);	
	}
	pSource->SetClipboard();
}
Exemplo n.º 4
0
void WINAPI DS_IDLData_InitializeClipboardFormats(void)
{
    if (g_cfDS_HIDA == 0)
    {
        g_cfDS_HDROP = RegisterClipboardFormat(c_szDS_HDrop);
        g_cfDS_HIDA = RegisterClipboardFormat(c_szDS_ShellIDList);
        g_cfDS_OFFSETS = RegisterClipboardFormat(c_szDS_ShellIDListOffset);
    }
}
void TOleApp::InitInstance()
{
	TApplication::InitInstance();

	vcfLink = RegisterClipboardFormat( "ObjectLink" );
	vcfNative = RegisterClipboardFormat( "Native" );
	vcfOwnerLink = RegisterClipboardFormat( "OwnerLink" );
	// comments in owlole.h mention these ole clipboard formats
}
Exemplo n.º 6
0
CMainFrameDropTarget::CMainFrameDropTarget()
{
    m_bDropDataValid = FALSE;

    m_cfHTML = (CLIPFORMAT)RegisterClipboardFormat(_T("HTML Format"));
    ASSERT(m_cfHTML != 0);

    m_cfShellURL = (CLIPFORMAT)RegisterClipboardFormat(CFSTR_SHELLURL);
    ASSERT(m_cfShellURL != 0);
}
Exemplo n.º 7
0
CUserListCtrl::CUserListCtrl()
{
    m_SortAscending=TRUE;
    m_viewType = P4USER_SPEC;
	m_OldDefUser = m_OldCurUser = _T("@");

    m_CF_DEPOT = static_cast<CLIPFORMAT>(RegisterClipboardFormat(LoadStringResource(IDS_DRAGFROMDEPOT)));
	m_CF_USER  = static_cast<CLIPFORMAT>(RegisterClipboardFormat(LoadStringResource(IDS_DRAGFROMUSER)));
	m_caption  = m_captionplain = LoadStringResource(IDS_PERFORCE_USERS);
}
Exemplo n.º 8
0
/*!
	クリップボードに文字列貼り付け
	@param[in]	pDatum	貼り付けたい文字列・ユニかSJIS
	@param[in]	cbSize	文字列の、NULLを含んだバイト数
	@param[in]	dStyle	矩形かとかそういう指定
	@return	HRESULT	終了状態コード
*/
HRESULT DocClipboardDataSet( LPVOID pDatum, INT cbSize, UINT dStyle )
{
	HGLOBAL	hGlobal;
	HANDLE	hClip;
	LPVOID	pBuffer;
	HRESULT	hRslt;
	UINT	ixFormat, ixSqrFmt;

	//	オリジナルフォーマット名を定義しておく
	ixFormat = RegisterClipboardFormat( CLIP_FORMAT );
	ixSqrFmt = RegisterClipboardFormat( CLIP_SQUARE );

	//	クリップするデータは共有メモリに入れる
	hGlobal = GlobalAlloc( GHND, cbSize );
	pBuffer = GlobalLock( hGlobal );
	CopyMemory( pBuffer, pDatum, cbSize );
	GlobalUnlock( hGlobal );

	//	クリップボードオーポン
	OpenClipboard( NULL );

	//	中身を消しちゃう
	EmptyClipboard(  );

	//	共有メモリにブッ込んだデータをクリッペする
	if( dStyle & D_UNI )	hClip = SetClipboardData( CF_UNICODETEXT, hGlobal );
	else					hClip = SetClipboardData( CF_TEXT, hGlobal );

	if( hClip )
	{
		SetClipboardData( ixFormat, hGlobal );
		//	クリッポが上手くいったら、オリジナル名でも記録しておく

		if( dStyle & D_SQUARE  )	//	矩形選択だったら
		{
			SetClipboardData( ixSqrFmt, hGlobal );
		}

		hRslt = S_OK;
	}
	else
	{
		//	登録失敗の場合は、自分で共有メモリを破壊せないかん
		GlobalFree( hGlobal );
		hRslt = E_OUTOFMEMORY;
	}

	//	クリップボード閉じる・閉じたら即CHAINが発生する・函数内で発生させてる?
	CloseClipboard(  );

	TRACE( TEXT("COPY DONE") );

	return hRslt;
}
Exemplo n.º 9
0
UINT Clipboard::RegisterFormat(FAR_CLIPBOARD_FORMAT Format)
{
	switch (Format)
	{
		case FCF_VERTICALBLOCK_OEM:
			return UseInternalClipboard? 0xFEB0 : RegisterClipboardFormat(L"FAR_VerticalBlock");
		case FCF_VERTICALBLOCK_UNICODE:
			return UseInternalClipboard? 0xFEB1 : RegisterClipboardFormat(L"FAR_VerticalBlock_Unicode");
		case FCF_CFSTR_PREFERREDDROPEFFECT:
			return UseInternalClipboard? 0xFEB2 : RegisterClipboardFormat(CFSTR_PREFERREDDROPEFFECT);
	}
	return 0;
}
Exemplo n.º 10
0
CClientListCtrl::CClientListCtrl()
{
	m_SortAscending=TRUE;
	m_LastSortCol=0;
	m_OldClient = GET_P4REGPTR()->GetP4Client();
	m_ClientNew.Empty();
	m_NewClicked = m_NewClient = FALSE;
	m_viewType = P4CLIENT_SPEC;
	m_OldDefClient = m_OldCurClient = _T("@");
	m_PrevNbrCli = -1;

	m_CF_DEPOT = RegisterClipboardFormat(LoadStringResource(IDS_DRAGFROMDEPOT));
	m_CF_CLIENT= RegisterClipboardFormat(LoadStringResource(IDS_DRAGFROMCLIENT));
	m_caption =  m_captionplain = LoadStringResource(IDS_PERFORCE_CLIENTS);
}
Exemplo n.º 11
0
HRESULT STDMETHODCALLTYPE DropHandler::DragEnter(IDataObject* pDataObj, DWORD grfKeyState, POINTL pt, DWORD* pdwEffect)
{
	FORMATETC fmtetc_cf_hdrop = { CF_HDROP, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };
	FORMATETC fmtetc_shellidlist = { static_cast<WORD>(RegisterClipboardFormat(CFSTR_SHELLIDLIST)), NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };
	FORMATETC fmtetc_filedescriptor = { static_cast<WORD>(RegisterClipboardFormat(CFSTR_FILEDESCRIPTOR)), NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };
	if (pDataObj->QueryGetData(&fmtetc_cf_hdrop) == S_OK ||
	    pDataObj->QueryGetData(&fmtetc_shellidlist) == S_OK ||
	    pDataObj->QueryGetData(&fmtetc_filedescriptor) == S_OK)
	{
		*pdwEffect = DROPEFFECT_COPY;
		return S_OK;
	}
	*pdwEffect = DROPEFFECT_NONE;
	return DRAGDROP_S_CANCEL;
}
Exemplo n.º 12
0
void
_gdk_windowing_init (void)
{
  gchar buf[10];

#ifdef HAVE_WINTAB
  if (getenv ("GDK_IGNORE_WINTAB") != NULL)
    _gdk_input_ignore_wintab = TRUE;
  else if (getenv ("GDK_USE_WINTAB") != NULL)
    _gdk_input_ignore_wintab = FALSE;
#endif

  if (gdk_synchronize)
    GdiSetBatchLimit (1);

  _gdk_app_hmodule = GetModuleHandle (NULL);
  _gdk_display_hdc = CreateDC ("DISPLAY", NULL, NULL, NULL);
  _gdk_input_locale = GetKeyboardLayout (0);
  _gdk_input_locale_is_ime = ImmIsIME (_gdk_input_locale);
  GetLocaleInfo (MAKELCID (LOWORD (_gdk_input_locale), SORT_DEFAULT),
		 LOCALE_IDEFAULTANSICODEPAGE,
		 buf, sizeof (buf));
  _gdk_input_codepage = atoi (buf);
  GDK_NOTE (EVENTS, g_print ("input_locale:%p, codepage:%d\n",
			     _gdk_input_locale, _gdk_input_codepage));

  CoInitialize (NULL);

  _cf_rtf = RegisterClipboardFormat ("Rich Text Format");
  _cf_utf8_string = RegisterClipboardFormat ("UTF8_STRING");
  _cf_image_bmp = RegisterClipboardFormat ("image/bmp");

  _gdk_selection_property = gdk_atom_intern ("GDK_SELECTION", FALSE);
  _wm_transient_for = gdk_atom_intern ("WM_TRANSIENT_FOR", FALSE);
  _targets = gdk_atom_intern ("TARGETS", FALSE);
  _save_targets = gdk_atom_intern ("SAVE_TARGETS", FALSE);
  _utf8_string = gdk_atom_intern ("UTF8_STRING", FALSE);
  _text = gdk_atom_intern ("TEXT", FALSE);
  _compound_text = gdk_atom_intern ("COMPOUND_TEXT", FALSE);
  _text_uri_list = gdk_atom_intern ("text/uri-list", FALSE);
  _image_bmp = gdk_atom_intern ("image/bmp", FALSE);

  _local_dnd = gdk_atom_intern ("LocalDndSelection", FALSE);
  _gdk_win32_dropfiles = gdk_atom_intern ("DROPFILES_DND", FALSE);
  _gdk_ole2_dnd = gdk_atom_intern ("OLE2_DND", FALSE);

  _gdk_win32_selection_init ();
}
Exemplo n.º 13
0
PRIVATE scrap_type
convert_format(int type)
{
  switch (type)
    {

    case T('T', 'E', 'X', 'T'):
#if defined(X11_SCRAP)
/* * */
      return XA_STRING;

#elif defined(WIN_SCRAP)
/* * */
      return CF_TEXT;

#endif /* scrap type */

    default:
      {
        char format[sizeof(FORMAT_PREFIX)+8+1];

        sprintf(format, "%s%08lx", FORMAT_PREFIX, (unsigned long)type);

#if defined(X11_SCRAP)
/* * */
        return XInternAtom(SDL_Display, format, False);

#elif defined(WIN_SCRAP)
/* * */
        return RegisterClipboardFormat(format);

#endif /* scrap type */
      }
    }
}
Exemplo n.º 14
0
BOOL CClipboardBackup::Restore()
{
	if( ! m_bFilled )
		return FALSE;

	if( ! ::OpenClipboard(NULL) )
		return FALSE;

	::EmptyClipboard();

	POSITION pos = m_lstData.GetHeadPosition();
	while( pos != NULL )
	{
		ClipboardData & data = m_lstData.GetNext( pos );

		UINT format = data.m_nFormat;

		if( data.m_szFormatName[0] != 0 )
		{
			UINT u = RegisterClipboardFormat( data.m_szFormatName );
			if( u > 0 ) format = u;
		}

		::SetClipboardData( format, data.m_hData );
	}

	::CloseClipboard();

	m_lstData.RemoveAll();
	m_bFilled = FALSE;

	return TRUE;
}
Exemplo n.º 15
0
bool CStringUtils::WriteDiffToClipboard(const CStringA& sClipdata, HWND hOwningWnd)
{
	UINT cFormat = RegisterClipboardFormat(_T("TSVN_UNIFIEDDIFF"));
	if (cFormat == 0)
		return false;
	CClipboardHelper clipboardHelper;
	if (clipboardHelper.Open(hOwningWnd))
	{
		EmptyClipboard();
		HGLOBAL hClipboardData = CClipboardHelper::GlobalAlloc(sClipdata.GetLength()+1);
		if (hClipboardData)
		{
			char* pchData = (char*)GlobalLock(hClipboardData);
			if (pchData)
			{
				strcpy_s(pchData, sClipdata.GetLength()+1, (LPCSTR)sClipdata);
				GlobalUnlock(hClipboardData);
				if (SetClipboardData(cFormat,hClipboardData)==NULL)
				{
					return false;
				}
				if (SetClipboardData(CF_TEXT,hClipboardData))
				{
					return true;
				}
			}
		}
	}
	return false;
}
Exemplo n.º 16
0
void HandleMenuCopy(HWND hDlg,const int *idArray,const int *staticWndArray,const int *editWndArray,const CString &strFile)
{
	if(!OpenClipboard(hDlg))
	{
		AfxMessageBox(_T("clipboard fail!"));
		return;
	}
	EmptyClipboard();
	HGLOBAL hg = GetDlgOutlineText(hDlg,staticWndArray,editWndArray,strFile);
	if(hg == NULL)
	{
		CloseClipboard();
		return;
	}
	SetClipboardData(CF_TTEXT,hg);
	hg = GetDlgOutlineTextSp(hDlg,idArray,editWndArray);
	if(hg == NULL)
	{
		CloseClipboard();
		return;
	}
	UINT cfMp3Infp = RegisterClipboardFormat(CF_MP3INFP);
	SetClipboardData(cfMp3Infp,hg);
	CloseClipboard();
}
Exemplo n.º 17
0
BOOL COpenDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	GroupRadio(IDC_MERGERADIO);

	CheckRadioButton(IDC_MERGERADIO, IDC_APPLYRADIO, IDC_MERGERADIO);

	// turn on auto completion for the edit controls
	HWND hwndEdit;
	GetDlgItem(IDC_BASEFILEEDIT, &hwndEdit);
	if (hwndEdit)
		SHAutoComplete(hwndEdit, SHACF_AUTOSUGGEST_FORCE_ON | SHACF_AUTOAPPEND_FORCE_ON | SHACF_FILESYSTEM);
	GetDlgItem(IDC_THEIRFILEEDIT, &hwndEdit);
	if (hwndEdit)
		SHAutoComplete(hwndEdit, SHACF_AUTOSUGGEST_FORCE_ON | SHACF_AUTOAPPEND_FORCE_ON | SHACF_FILESYSTEM);
	GetDlgItem(IDC_YOURFILEEDIT, &hwndEdit);
	if (hwndEdit)
		SHAutoComplete(hwndEdit, SHACF_AUTOSUGGEST_FORCE_ON | SHACF_AUTOAPPEND_FORCE_ON | SHACF_FILESYSTEM);
	GetDlgItem(IDC_DIFFFILEEDIT, &hwndEdit);
	if (hwndEdit)
		SHAutoComplete(hwndEdit, SHACF_AUTOSUGGEST_FORCE_ON | SHACF_AUTOAPPEND_FORCE_ON | SHACF_FILESYSTEM);
	GetDlgItem(IDC_DIRECTORYEDIT, &hwndEdit);
	if (hwndEdit)
		SHAutoComplete(hwndEdit, SHACF_AUTOSUGGEST_FORCE_ON | SHACF_AUTOAPPEND_FORCE_ON | SHACF_FILESYSTEM);

	m_cFormat = RegisterClipboardFormat(_T("TSVN_UNIFIEDDIFF"));
	m_nextViewer = SetClipboardViewer();

	return TRUE;  // return TRUE unless you set the focus to a control
	// EXCEPTION: OCX Property Pages should return FALSE
}
Exemplo n.º 18
0
void CWordClipboardControl::CopyWord(HWND hWnd,int ID, int type, POINT ptBeg, POINT ptEnd, POINT wordIniPt,int iPenColor, int iBgColor, const vector<char>& tmp,BOOL IsSegment)
{
	UINT format = RegisterClipboardFormat(_T("MY_CUSTOM_FORMAT"));

	::OpenClipboard(hWnd);
	::EmptyClipboard();

	clipObj data;
	data.nObjType   = type;
	data.ptBeg      = ptBeg;
	data.ptEnd      = ptEnd;
	data.iPenWidth  = 1;
	data.iPenColor  = iPenColor;
	data.iFigBg     = iBgColor;

	data.IsSegmentWord = IsSegment;
	data.wordIniPt  = wordIniPt;


	//allocate some global memory
	HGLOBAL clipbuffer;
	clipbuffer = GlobalAlloc(GMEM_DDESHARE, sizeof(clipObj));
	clipObj * buffer = (clipObj*)GlobalLock(clipbuffer);

	//put the data into that memory
	*buffer = data;

	//Put it on the clipboard
	GlobalUnlock(clipbuffer);
	SetClipboardData(format,clipbuffer);


	//allocate some global memory
	int nlen =  (int ) tmp.size();

	HGLOBAL wordClipbuffer;
	wordClipbuffer = GlobalAlloc(GHND | GMEM_SHARE, (nlen+1) );
	char*  wordbuffer = (char*) GlobalLock(wordClipbuffer);
	
	
	for( int i = 0 ; i < nlen ; i ++ )
		*(wordbuffer+i) = tmp[i];
	wordbuffer[nlen] = '\0';

	//Put it on the clipboard
	GlobalUnlock(wordClipbuffer);

	#ifndef UNICODE
	     SetClipboardData(CF_UNICODETEXT,wordClipbuffer);
    #else 
	     SetClipboardData(CF_TEXT ,wordClipbuffer);
    #endif
	
	CloseClipboard();

	//tmp = NULL;
	//reset direction
	_xOffset = -CommonVar::SHIFT_PIXEL;
	_yOffset = -CommonVar::SHIFT_PIXEL;
}
Exemplo n.º 19
0
void DlgContextMenu(HWND hDlg,LPARAM lParam,BOOL isEnable)
{
	HMENU hMenu = LoadMenu(AfxGetResourceHandle(),MAKEINTRESOURCE(IDR_MENU_PROPERTY_CONTEXT));
	HMENU hPopup = GetSubMenu(hMenu,0);
	EnableMenuItem(hPopup,ID_MENU_PASTE,MF_GRAYED);
	EnableMenuItem(hPopup,ID_MENU_COPY,MF_GRAYED);
	if(isEnable)
	{
		EnableMenuItem(hPopup,ID_MENU_COPY,MF_ENABLED);
		if(OpenClipboard(hDlg))
		{
			UINT cfMp3Infp = RegisterClipboardFormat(CF_MP3INFP);
			HANDLE hText = GetClipboardData(cfMp3Infp);
			if(hText)
			{
				EnableMenuItem(hPopup,ID_MENU_PASTE,MF_ENABLED);
				GlobalUnlock(hText);
			}
			CloseClipboard();
		}
	}
	TrackPopupMenu(hPopup,
					TPM_LEFTALIGN|TPM_LEFTBUTTON|TPM_VERTICAL,
					GET_X_LPARAM(lParam),
					GET_Y_LPARAM(lParam),
					0,
					hDlg,
					0);
	DestroyMenu(hMenu);
}
Exemplo n.º 20
0
/*************
 * DESCRIPTION:	constructor
 * INPUT:			-
 * OUTPUT:			-
 *************/
CMatView::CMatView()
{
    SetScrollSizes(MM_TEXT, CSize(0, 0), CSize(MATWIDTH, MATTOTALHEIGHT), CSize(MATWIDTH, MATTOTALHEIGHT));
    nSelectedMaterial = -1;
    m_nIDDrag = RegisterClipboardFormat(_T("MatView"));
    pMatWnd = this;
}
Exemplo n.º 21
0
nglNativeObjectType nglDataTypesRegistry::RegisterDataType(const nglString& rMimeType, nglNativeObjectType Type, nglDataObjectCreatorFunc pCreator)
{
#ifdef _WIN32_
  if (!Type)
    Type = RegisterClipboardFormat((LPCTSTR)(rMimeType.GetChars()));
  if (!Type)
  {
    NGL_LOG(_T("nglNativeObjectTypesRegistry"), NGL_LOG_ERROR, _T("RegisterDragAndDropNativeType: Can't RegisterClipboardFormat(\")%s\")"), rMimeType.GetChars());
  }
#endif
  
  {
    std::map<nglString, nglNativeObjectType>::iterator it = mRegisteredNativeTypes.find(rMimeType);
    
    if (it != mRegisteredNativeTypes.end())
      Type = it->second;
    else
    // dynamically generate a new Type
    {
      if (Type == 'nui3')
      {
        uint32 size = mRegisteredNativeTypes.size(); // use the size (on 24bits, we should not have any overflow:) ) of the map as a unique index
        Type = ('n' << 24) | (size & 0xffffff);
      }

      // LBTODO ?
      mDataObjectCreators[rMimeType] = pCreator;
      mRegisteredNativeTypes[rMimeType] = Type;
    }
  }
  
  return Type;
}
Exemplo n.º 22
0
// get the format ID for a given mimetype
ULONG nsClipboard::GetFormatID(const char *aMimeStr)
{
  if (strcmp(aMimeStr, kTextMime) == 0)
    return CF_TEXT;

  return RegisterClipboardFormat(aMimeStr);
}
Exemplo n.º 23
0
BOOL CClipboardBackup::Restore()
{
	if( ! ::OpenClipboard(NULL) )
		return FALSE;

	::EmptyClipboard();

	POSITION pos = m_lstData.GetHeadPosition();
	while( pos != NULL )
	{
		ClipboardData & data = m_lstData.GetNext( pos );

		UINT format = data.m_nFormat;

		if( data.m_szFormatName[0] != 0 )
		{
			UINT u = RegisterClipboardFormat( data.m_szFormatName );
			if( u > 0 ) format = u;
		}

		HANDLE hMem = ::GlobalAlloc( GMEM_MOVEABLE | GMEM_DDESHARE, data.m_nLength );
		LPVOID pMem = ::GlobalLock( hMem );

		memcpy( pMem, data.m_pData, data.m_nLength );

		::GlobalUnlock( hMem );

		::SetClipboardData( format, hMem );
	}

	::CloseClipboard();
	return TRUE;
}
Exemplo n.º 24
0
int main()
{
	if (!OpenClipboard(NULL))
	{
		std::cout << "Unable to open clipboard" << std::endl;
		return 1;
	}
	EmptyClipboard();
	UINT skypeClipboardFormat = RegisterClipboardFormat(L"SkypeMessageFragment");
	if (skypeClipboardFormat == 0)
	{
		std::cout << "Unable to register clipboard format" << std::endl;
		return 2;
	}
	std::string message;
	std::string author;
	std::string date;
	int y, m, d, h, min = 0;
	std::tm time;
	std::cout << "Enter skype username of author: ";
	std::getline(std::cin, author);
    std::cout << "\nEnter message:\n";
	std::getline(std::cin, message);

	long int secs = static_cast<long int>(std::time(NULL));
	char str[30];
	sprintf_s(str, sizeof(str), "%d", secs);
    std::string txt = "<quote author=\"" + author + "\" timestamp=\"" + str + "\">" + message + "</quote>";
	CopyToClipboard(CF_TEXT, message);
	CopyToClipboard(skypeClipboardFormat, txt);
	CloseClipboard();
	return 0;
}
Exemplo n.º 25
0
HRESULT GitDataObject::SetDropDescription(DROPIMAGETYPE image, LPCTSTR format, LPCTSTR insert)
{
	if (!format || !insert)
		return E_INVALIDARG;

	FORMATETC fetc = { 0 };
	fetc.cfFormat = (CLIPFORMAT)RegisterClipboardFormat(CFSTR_DROPDESCRIPTION);
	fetc.dwAspect = DVASPECT_CONTENT;
	fetc.lindex = -1;
	fetc.tymed = TYMED_HGLOBAL;

	STGMEDIUM medium = { 0 };
	medium.hGlobal = GlobalAlloc(GHND, sizeof(DROPDESCRIPTION));
	if (medium.hGlobal == 0)
		return E_OUTOFMEMORY;

	DROPDESCRIPTION* pDropDescription = (DROPDESCRIPTION*)GlobalLock(medium.hGlobal);
	if (!pDropDescription)
		return E_FAIL;
	StringCchCopy(pDropDescription->szInsert, _countof(pDropDescription->szInsert), insert);
	StringCchCopy(pDropDescription->szMessage, _countof(pDropDescription->szMessage), format);
	pDropDescription->type = image;
	GlobalUnlock(medium.hGlobal);
	return SetData(&fetc, &medium, TRUE);
}
Exemplo n.º 26
0
void CDeviceView::OnInitialUpdate()
{
   CDoc* pDoc = GetDocument();
   pDoc->nIDClipFormat = RegisterClipboardFormat(_T("ScdTgSrcScdTgSrc"));
   ASSERT( pDoc->nIDClipFormat );
   CTreeView::OnInitialUpdate();
}
Exemplo n.º 27
0
QT_BEGIN_NAMESPACE

/*!
    \class QWindowsOleDataObject
    \brief OLE data container

   The following methods are NOT supported for data transfer using the
   clipboard or drag-drop:
   \list
   \li IDataObject::SetData    -- return E_NOTIMPL
   \li IDataObject::DAdvise    -- return OLE_E_ADVISENOTSUPPORTED
   \li ::DUnadvise
   \li ::EnumDAdvise
   \li IDataObject::GetCanonicalFormatEtc -- return E_NOTIMPL
       (NOTE: must set pformatetcOut->ptd = NULL)
   \endlist

    \internal
    \ingroup qt-lighthouse-win
*/

QWindowsOleDataObject::QWindowsOleDataObject(QMimeData *mimeData) :
    m_refs(1), data(mimeData),
    CF_PERFORMEDDROPEFFECT(RegisterClipboardFormat(CFSTR_PERFORMEDDROPEFFECT)),
    performedEffect(DROPEFFECT_NONE)
{
    qCDebug(lcQpaMime) << __FUNCTION__ << mimeData->formats();
}
Exemplo n.º 28
0
HRESULT CDataObject::SetDataInt(LPCWSTR sFmtName, const void* hData, DWORD nDataSize /*= 0*/)
{
	HRESULT hr;

	FORMATETC       fmtetc[] =
	{
		{ (CLIPFORMAT)RegisterClipboardFormat(sFmtName), 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL },
	};
	STGMEDIUM       stgmed[] =
	{
		{ TYMED_HGLOBAL },
	};

	if (nDataSize == 0)
	{
		stgmed[0].hGlobal = (HGLOBAL)hData;
	}
	else
	{
		stgmed[0].hGlobal = GlobalAlloc(GPTR, nDataSize);
		memmove(stgmed[0].hGlobal, hData, nDataSize);
	}

	hr = SetData(fmtetc, stgmed, TRUE);

	return hr;
}
Exemplo n.º 29
0
//-------------------------------------------------------------------//
// bHaveValidDropData()																//
//-------------------------------------------------------------------//
// This routine peeks at the Ole drop data to see if it contains
// any recognizable OLE data.  Useful in OnUpdatePaste()-type
// handlers.
//-------------------------------------------------------------------//
bool OleListCtrl::bHaveValidDropData(
	COleDataObject*	pDropData
) {
	bool bFoundData = false;

	// Get the standard OleDragData CF.
	CLIPFORMAT ClipFormat = RegisterClipboardFormat( cszOleDragData );

	// Get file referring to clipboard data.
	CFile *pFile = pDropData->GetFileData( ClipFormat );

	// If that didn't take, we don't have the format we want.
	// Get the heck outta here!
	if ( pFile != NULL )
	{
		// Connect the file to the archive.
		CArchive DataArchive( pFile, CArchive::load );			
			
		// Note that the drag data array should be empty.
		ASSERT( Items.GetSize() == 0 );

		// Load up the array.
		int nCount;
		DataArchive.Read( &nCount, sizeof( nCount ) );

		bFoundData = ( nCount > 0 );

		// Finish up.
		DataArchive.Close();
		delete pFile;
	
	}

	return bFoundData;
}
Exemplo n.º 30
0
DS_SELECTION_LIST* CShowActiveDirUsers::RetrieveUserSelectionList()
{
	UINT	regClipFormat		= 0;
	HRESULT hr					= S_OK;
	DS_SELECTION_LIST* pSelList = NULL;

	regClipFormat = 
			RegisterClipboardFormat(_T("CFSTR_DSOP_DS_SELECTION_LIST"));
	if ( !regClipFormat )
		return NULL;

	FORMATETC format;
	format.cfFormat = (CLIPFORMAT)regClipFormat;
	format.ptd = NULL;
	format.dwAspect = 
		format.lindex = -1;
	format.tymed = TYMED_HGLOBAL;

	if (m_pDataObject == NULL)
		return NULL;

	hr = m_pDataObject->GetData( &format, &m_stg);


	if ( FAILED(hr) || m_stg.tymed != TYMED_HGLOBAL )
		return NULL;

	pSelList = (DS_SELECTION_LIST*)GlobalLock( m_stg.hGlobal );

	return pSelList;
}