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


C++ CClipboardHelper::Open方法代码示例

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


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

示例1: AddClipboardUrlToWindow

bool CCommonAppUtils::AddClipboardUrlToWindow( HWND hWnd )
{
    if (IsClipboardFormatAvailable(CF_UNICODETEXT))
    {
        CClipboardHelper clipboard;
        clipboard.Open(hWnd);
        HGLOBAL hglb = GetClipboardData(CF_UNICODETEXT);
        if (hglb)
        {
            LPCWSTR lpstr = (LPCWSTR)GlobalLock(hglb);
            CString sUrl = lpstr;
            GlobalUnlock(hglb);

            sUrl.Trim();
            CString sLowerCaseUrl = sUrl;
            sLowerCaseUrl.MakeLower();
            // check for illegal chars: they might be allowed in a regular url, e.g. '?',
            // but not in an url to an svn repository!
            if (sLowerCaseUrl.FindOneOf(L"\n\r?;=+$,<>#") >= 0)
                return false;

            if ((sLowerCaseUrl.Find(L"http://")==0) ||
                (sLowerCaseUrl.Find(L"https://")==0) ||
                (sLowerCaseUrl.Find(L"svn://")==0) ||
                (sLowerCaseUrl.Find(L"svn+ssh://")==0) ||
                (sLowerCaseUrl.Find(L"file://")==0))
            {
                ::SetWindowText(hWnd, (LPCTSTR)sUrl);
                return true;
            }
        }
    }
    return false;
}
开发者ID:ch3cooli,项目名称:TSVNUtils,代码行数:34,代码来源:CommonAppUtils.cpp

示例2: WriteDiffToClipboard

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;
}
开发者ID:fatterbetter,项目名称:ZTools,代码行数:30,代码来源:StringUtils.cpp

示例3: WriteAsciiStringToClipboard

bool CStringUtils::WriteAsciiStringToClipboard(const CStringW& sClipdata, HWND hOwningWnd)
{
	CClipboardHelper clipboardHelper;
	if (clipboardHelper.Open(hOwningWnd))
	{
		EmptyClipboard();
		HGLOBAL hClipboardData = CClipboardHelper::GlobalAlloc((sClipdata.GetLength()+1)*sizeof(WCHAR));
		if (hClipboardData)
		{
			WCHAR* pchData = (WCHAR*)GlobalLock(hClipboardData);
			if (pchData)
			{
				_tcscpy_s(pchData, sClipdata.GetLength()+1, (LPCWSTR)sClipdata);
				GlobalUnlock(hClipboardData);
				if (SetClipboardData(CF_UNICODETEXT, hClipboardData))
				{
					// no need to also set CF_TEXT : the OS does this
					// automatically.
					return true;
				}
			}
		}
	}
	return false;
}
开发者ID:fatterbetter,项目名称:ZTools,代码行数:25,代码来源:StringUtils.cpp

示例4: PreTranslateMessage

BOOL CMessageBox::PreTranslateMessage(MSG* pMsg)
{
	if (pMsg->message == WM_KEYDOWN)
	{
		switch (pMsg->wParam)
		{
		case 'C':
		case VK_INSERT:
			{
				if (GetAsyncKeyState(VK_CONTROL)&0x8000)
				{
					CClipboardHelper clipboardHelper;
					if(clipboardHelper.Open(GetSafeHwnd()))
					{
						EmptyClipboard();
						CStringA sClipboard = CStringA(m_sMessage);
						HGLOBAL hClipboardData = CClipboardHelper::GlobalAlloc(sClipboard.GetLength()+1);
						char * pchData = (char*)GlobalLock(hClipboardData);
						if (pchData)
							strcpy_s(pchData, sClipboard.GetLength()+1, (LPCSTR)sClipboard);
						GlobalUnlock(hClipboardData);
						SetClipboardData(CF_TEXT,hClipboardData);
					}
					return TRUE;
				}
			}
			break;
		case VK_ESCAPE:
			{
				switch (m_uType & 0xf)
				{
				case MB_ABORTRETRYIGNORE:
					EndDialog(m_uButton1Ret);
					break;
				case MB_CANCELTRYCONTINUE:
					EndDialog(m_uButton1Ret);
					break;
				case MB_OKCANCEL:
					EndDialog(m_uButton2Ret);
					break;
				case MB_RETRYCANCEL:
					EndDialog(m_uButton2Ret);
					break;
				case MB_YESNO:
					EndDialog(m_uButton2Ret);
					break;
				case MB_YESNOCANCEL:
					EndDialog(m_uButton3Ret);
					break;
				}
			}
			break;
		}
	}

	return __super::PreTranslateMessage(pMsg);
}
开发者ID:chengn,项目名称:TortoiseGit,代码行数:57,代码来源:MessageBox.cpp

示例5: WriteDiffToClipboard

bool CStringUtils::WriteDiffToClipboard(const CStringA& sClipdata, HWND hOwningWnd)
{
	UINT cFormat = RegisterClipboardFormat(_T("TGIT_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) == NULL)
				{
					return false;
				}
				CString sClipdataW = CUnicodeUtils::GetUnicode(sClipdata);
				auto hClipboardDataW = CClipboardHelper::GlobalAlloc(sClipdataW.GetLength()*sizeof(wchar_t) + 1);
				if (hClipboardDataW)
				{
					wchar_t* pchDataW = (wchar_t*)GlobalLock(hClipboardDataW);
					if (pchDataW)
					{
						wcscpy_s(pchDataW, sClipdataW.GetLength() + 1, (LPCWSTR)sClipdataW);
						GlobalUnlock(hClipboardDataW);
						if (SetClipboardData(CF_UNICODETEXT, hClipboardDataW))
						{
							return true;
						}
					}
				}
			}
		}
	}
	return false;
}
开发者ID:hongzuL,项目名称:TortoiseGit,代码行数:45,代码来源:StringUtils.cpp


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