您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ CloseClipboard函数代码示例

51自学网 2021-06-01 20:11:38
  C++
这篇教程C++ CloseClipboard函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中CloseClipboard函数的典型用法代码示例。如果您正苦于以下问题:C++ CloseClipboard函数的具体用法?C++ CloseClipboard怎么用?C++ CloseClipboard使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

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

示例1: winClipboardFlushXEvents

intwinClipboardFlushXEvents(HWND hwnd,                         int iWindow, Display * pDisplay, Bool fUseUnicode){    static Atom atomLocalProperty;    static Atom atomCompoundText;    static Atom atomUTF8String;    static Atom atomTargets;    static int generation;    if (generation != serverGeneration) {        generation = serverGeneration;        atomLocalProperty = XInternAtom(pDisplay, WIN_LOCAL_PROPERTY, False);        atomUTF8String = XInternAtom(pDisplay, "UTF8_STRING", False);        atomCompoundText = XInternAtom(pDisplay, "COMPOUND_TEXT", False);        atomTargets = XInternAtom(pDisplay, "TARGETS", False);    }    /* Process all pending events */    while (XPending(pDisplay)) {        XTextProperty xtpText = { 0 };        XEvent event;        XSelectionEvent eventSelection;        unsigned long ulReturnBytesLeft;        char *pszReturnData = NULL;        char *pszGlobalData = NULL;        int iReturn;        HGLOBAL hGlobal = NULL;        XICCEncodingStyle xiccesStyle;        int iConvertDataLen = 0;        char *pszConvertData = NULL;        char *pszTextList[2] = { NULL };        int iCount;        char **ppszTextList = NULL;        wchar_t *pwszUnicodeStr = NULL;        int iUnicodeLen = 0;        int iReturnDataLen = 0;        int i;        Bool fAbort = FALSE;        Bool fCloseClipboard = FALSE;        Bool fSetClipboardData = TRUE;        /* Get the next event - will not block because one is ready */        XNextEvent(pDisplay, &event);        /* Branch on the event type */        switch (event.type) {            /*             * SelectionRequest             */        case SelectionRequest:        {            char *pszAtomName = NULL;            winDebug("SelectionRequest - target %d/n",                     event.xselectionrequest.target);            pszAtomName = XGetAtomName(pDisplay,                                       event.xselectionrequest.target);            winDebug("SelectionRequest - Target atom name %s/n", pszAtomName);            XFree(pszAtomName);            pszAtomName = NULL;        }            /* Abort if invalid target type */            if (event.xselectionrequest.target != XA_STRING                && event.xselectionrequest.target != atomUTF8String                && event.xselectionrequest.target != atomCompoundText                && event.xselectionrequest.target != atomTargets) {                /* Abort */                fAbort = TRUE;                goto winClipboardFlushXEvents_SelectionRequest_Done;            }            /* Handle targets type of request */            if (event.xselectionrequest.target == atomTargets) {                Atom atomTargetArr[] = { atomTargets,                    atomCompoundText,                    atomUTF8String,                    XA_STRING                };                /* Try to change the property */                iReturn = XChangeProperty(pDisplay,                                          event.xselectionrequest.requestor,                                          event.xselectionrequest.property,                                          XA_ATOM,                                          32,                                          PropModeReplace,                                          (unsigned char *) atomTargetArr,                                          (sizeof(atomTargetArr)                                           / sizeof(atomTargetArr[0])));                if (iReturn == BadAlloc                    || iReturn == BadAtom                    || iReturn == BadMatch                    || iReturn == BadValue || iReturn == BadWindow) {                    ErrorF("winClipboardFlushXEvents - SelectionRequest - "                           "XChangeProperty failed: %d/n", iReturn);                }//.........这里部分代码省略.........
开发者ID:Agnesa,项目名称:xserver,代码行数:101,


示例2: TVPClipboardGetText

//---------------------------------------------------------------------------bool TVPClipboardGetText(ttstr & text){	if(!OpenClipboard(Application->Handle)) return false;	bool result = false;	try	{		// select CF_UNICODETEXT or CF_TEXT		UINT formats[2] = { CF_UNICODETEXT, CF_TEXT};		int format = GetPriorityClipboardFormat(formats, 2);		if(format == CF_UNICODETEXT)		{			// try to read unicode text			HGLOBAL hglb = (HGLOBAL)GetClipboardData(CF_UNICODETEXT);			if(hglb != NULL)			{				const tjs_char *p = (const tjs_char *)GlobalLock(hglb);				if(p)				{					try					{						text = ttstr(p);						result = true;					}					catch(...)					{						GlobalUnlock(hglb);						throw;					}					GlobalUnlock(hglb);				}			}		}		else if(format == CF_TEXT)		{			// try to read ansi text			HGLOBAL hglb = (HGLOBAL)GetClipboardData(CF_TEXT);			if(hglb != NULL)			{				const char *p = (const char *)GlobalLock(hglb);				if(p)				{					try					{						text = ttstr(p);						result = true;					}					catch(...)					{						GlobalUnlock(hglb);						throw;					}					GlobalUnlock(hglb);				}			}		}	}	catch(...)	{		CloseClipboard();		throw;	}	CloseClipboard();	return result;}
开发者ID:xmoeproject,项目名称:X-moe,代码行数:68,


示例3: GetSel

BOOL CHexEdit::PreTranslateMessage(MSG* pMsg) {	// TODO: Add your specialized code here and/or call the base class	int start,end;	GetSel(start,end);	CString text;	this->GetWindowText(text);	char head=0,second=0;	if(text.GetLength()>0) head=text.GetAt(0);	if(text.GetLength()>1) second=text.GetAt(1);	bool bCut=true;	if (pMsg->message == WM_KEYDOWN)	{		if (pMsg->wParam=='X')		{			if(::GetKeyState(VK_CONTROL) < 0)			{				//Cut				if(second=='X'||second=='x'){						//does not allow cut first char					if(start==0&&end==1)							bCut=false;				}				if(bCut) return CEdit::PreTranslateMessage(pMsg);				else					return TRUE;			}			else return CEdit::PreTranslateMessage(pMsg);		}		else if(pMsg->wParam=='V')		{			if(::GetKeyState(VK_CONTROL)<0)			{				//Paste				bool bPaste=true;				if(!IsClipboardFormatAvailable(CF_TEXT)) bPaste=false;				if(!this->OpenClipboard())					::AfxMessageBox("Cannot open clipboard!");				HGLOBAL   hglb; 				LPTSTR    lptstr; 				hglb=GetClipboardData(CF_TEXT);				if (hglb != NULL) 				{ 					lptstr =(LPTSTR) GlobalLock(hglb);					//Check invalid hex string					if(!this->IsHexConvertableText(lptstr))					{						bPaste=false;					}				}				CloseClipboard();				if(!bPaste) return TRUE;				else					return CEdit::PreTranslateMessage(pMsg);			}			else return CEdit::PreTranslateMessage(pMsg);		}		else if(pMsg->wParam==VK_DELETE)		{			if(second=='X'||second=='x'){					//does not allow delete first char				if(start==0&&end<=1)						bCut=false;			}			if(bCut) return CEdit::PreTranslateMessage(pMsg);			else				return TRUE;		}		else			return CEdit::PreTranslateMessage(pMsg);	}	else if (pMsg->message == WM_CHAR)	{		int c=(int)pMsg->wParam;		if(pMsg->wParam<32)		{			if(pMsg->wParam==8&&(second=='x'||second=='X')&&head=='0'&&end==1) //does not allow to delete '0' before x				return TRUE;			else				return CEdit::PreTranslateMessage(pMsg);//Control code		}		if(second=='x'||second=='X')		{			//does not allow to change head except select includes first and second			if(start<=1&&end<=1) return TRUE;		}		if(start==1&&(c=='X'||c=='x')&&head=='0') {pMsg->wParam='x';return CEdit::PreTranslateMessage(pMsg);}		else if(c>=48&&c<=57||c>='A'&&c<='F') return CEdit::PreTranslateMessage(pMsg);		else if(c>='a'&&c<='f') {pMsg->wParam-=32; return CEdit::PreTranslateMessage(pMsg);}		else return TRUE;	}	else		return CEdit::PreTranslateMessage(pMsg);}
开发者ID:DavidCussans,项目名称:eudaq-old,代码行数:97,


示例4: PyImaging_GrabClipboardWin32

PyObject*PyImaging_GrabClipboardWin32(PyObject* self, PyObject* args){    int clip;    HANDLE handle;    int size;    void* data;    PyObject* result;        int verbose = 0; /* debugging; will be removed in future versions */    if (!PyArg_ParseTuple(args, "|i", &verbose))	return NULL;    clip = OpenClipboard(NULL);    /* FIXME: check error status */        if (verbose) {        UINT format = EnumClipboardFormats(0);        char buffer[200];        char* result;        while (format != 0) {            if (GetClipboardFormatName(format, buffer, sizeof buffer) > 0)                result = buffer;            else                switch (format) {                case CF_BITMAP:                    result = "CF_BITMAP";                    break;                case CF_DIB:                    result = "CF_DIB";                    break;                case CF_DIF:                    result = "CF_DIF";                    break;                case CF_ENHMETAFILE:                    result = "CF_ENHMETAFILE";                    break;                case CF_HDROP:                    result = "CF_HDROP";                    break;                case CF_LOCALE:                    result = "CF_LOCALE";                    break;                case CF_METAFILEPICT:                    result = "CF_METAFILEPICT";                    break;                case CF_OEMTEXT:                    result = "CF_OEMTEXT";                    break;                case CF_OWNERDISPLAY:                    result = "CF_OWNERDISPLAY";                    break;                case CF_PALETTE:                    result = "CF_PALETTE";                    break;                case CF_PENDATA:                    result = "CF_PENDATA";                    break;                case CF_RIFF:                    result = "CF_RIFF";                    break;                case CF_SYLK:                    result = "CF_SYLK";                    break;                case CF_TEXT:                    result = "CF_TEXT";                    break;                case CF_WAVE:                    result = "CF_WAVE";                    break;                case CF_TIFF:                    result = "CF_TIFF";                    break;                case CF_UNICODETEXT:                    result = "CF_UNICODETEXT";                    break;                default:                    sprintf(buffer, "[%d]", format);                    result = buffer;                    break;                }            printf("%s (%d)/n", result, format);            format = EnumClipboardFormats(format);        }    }    handle = GetClipboardData(CF_DIB);    if (!handle) {        /* FIXME: add CF_HDROP support to allow cut-and-paste from           the explorer */        CloseClipboard();        Py_INCREF(Py_None);        return Py_None;    }    size = GlobalSize(handle);    data = GlobalLock(handle);#if 0//.........这里部分代码省略.........
开发者ID:Bouke,项目名称:Pillow,代码行数:101,


示例5: inner_clipboard_window_procedure

/* * maybe this should be integrated with the default message loop - or maybe not ;-) */static LRESULT CALLBACKinner_clipboard_window_procedure (HWND   hwnd,                                  UINT   message,                                  WPARAM wparam,                                  LPARAM lparam){  switch (message)    {    case WM_DESTROY: /* remove us from chain */      {        ChangeClipboardChain (hwnd, _hwnd_next_viewer);        PostQuitMessage (0);        return 0;      }    case WM_CHANGECBCHAIN:      {        HWND hwndRemove = (HWND) wparam; /* handle of window being removed */        HWND hwndNext   = (HWND) lparam; /* handle of next window in chain */        if (hwndRemove == _hwnd_next_viewer)          _hwnd_next_viewer = hwndNext == hwnd ? NULL : hwndNext;        else if (_hwnd_next_viewer != NULL)          return SendMessage (_hwnd_next_viewer, message, wparam, lparam);        return 0;      }    case WM_CLIPBOARDUPDATE:    case WM_DRAWCLIPBOARD:      {        int success;        HWND hwndOwner;#ifdef G_ENABLE_DEBUG        UINT nFormat = 0;#endif        GdkEvent *event;        GdkWindow *owner;        success = OpenClipboard (hwnd);        if (!success)          {            g_warning ("Failed to OpenClipboard on window handle %p", hwnd);            return 0;          }        hwndOwner = GetClipboardOwner ();        owner = gdk_win32_window_lookup_for_display (_gdk_display, hwndOwner);        if (owner == NULL)          owner = gdk_win32_window_foreign_new_for_display (_gdk_display, hwndOwner);        GDK_NOTE (DND, g_print (" drawclipboard owner: %p", hwndOwner));#ifdef G_ENABLE_DEBUG        if (_gdk_debug_flags & GDK_DEBUG_DND)          {            while ((nFormat = EnumClipboardFormats (nFormat)) != 0)              g_print ("%s ", _gdk_win32_cf_to_string (nFormat));          }#endif        GDK_NOTE (DND, g_print (" /n"));        event = gdk_event_new (GDK_OWNER_CHANGE);        event->owner_change.window = gdk_get_default_root_window ();        event->owner_change.owner = owner;        event->owner_change.reason = GDK_OWNER_CHANGE_NEW_OWNER;        event->owner_change.selection = GDK_SELECTION_CLIPBOARD;        event->owner_change.time = _gdk_win32_get_next_tick (0);        event->owner_change.selection_time = GDK_CURRENT_TIME;        _gdk_win32_append_event (event);        CloseClipboard ();        if (_hwnd_next_viewer != NULL)          return SendMessage (_hwnd_next_viewer, message, wparam, lparam);        /* clear error to avoid confusing SetClipboardViewer() return */        SetLastError (0);        return 0;      }    default:      /* Otherwise call DefWindowProcW(). */      GDK_NOTE (EVENTS, g_print (" DefWindowProcW"));      return DefWindowProc (hwnd, message, wparam, lparam);    }}
开发者ID:nvieirafelipe,项目名称:gtk,代码行数:88,


示例6: cliprdr_proc

static LRESULT CALLBACK cliprdr_proc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam){	static cliprdrContext *cliprdr = NULL;	switch (Msg)	{		case WM_CREATE:			cliprdr = (cliprdrContext *)((CREATESTRUCT *)lParam)->lpCreateParams;			cliprdr->hwndNextViewer = SetClipboardViewer(hWnd);			if (cliprdr->hwndNextViewer == NULL && GetLastError() != 0)			{				DEBUG_CLIPRDR("error: SetClipboardViewer failed with 0x%0x.", GetLastError());			}			cliprdr->hwndClipboard = hWnd;			break;		case WM_CLOSE:			ChangeClipboardChain(hWnd, cliprdr->hwndNextViewer);			break;		case WM_CHANGECBCHAIN:			if (cliprdr->hwndNextViewer == (HWND)wParam)			{				cliprdr->hwndNextViewer = (HWND)lParam;			}			else if (cliprdr->hwndNextViewer != NULL)			{				SendMessage(cliprdr->hwndNextViewer, Msg, wParam, lParam);			}			break;		case WM_DRAWCLIPBOARD:			if (cliprdr->channel_initialized)			{				if ((GetClipboardOwner() != cliprdr->hwndClipboard) && (S_FALSE == OleIsCurrentClipboard(cliprdr->data_obj)))				{						if (!cliprdr->hmem)						{							cliprdr->hmem = GlobalFree(cliprdr->hmem);						}						cliprdr_send_format_list(cliprdr);				}			}			if (cliprdr->hwndNextViewer != NULL && cliprdr->hwndNextViewer != hWnd)				SendMessage(cliprdr->hwndNextViewer, Msg, wParam, lParam);			break;		case WM_RENDERALLFORMATS:			/* discard all contexts in clipboard */			if (!OpenClipboard(cliprdr->hwndClipboard))			{				DEBUG_CLIPRDR("OpenClipboard failed with 0x%x", GetLastError());				break;			}			EmptyClipboard();			CloseClipboard();			break;		case WM_RENDERFORMAT:			if (cliprdr_send_data_request(cliprdr, (UINT32)wParam) != 0)			{				DEBUG_CLIPRDR("error: cliprdr_send_data_request failed.");				break;			}			if (SetClipboardData((UINT) wParam, cliprdr->hmem) == NULL)			{				DEBUG_CLIPRDR("SetClipboardData failed with 0x%x", GetLastError());				cliprdr->hmem = GlobalFree(cliprdr->hmem);			}			/* Note: GlobalFree() is not needed when success */			break;		case WM_CLIPRDR_MESSAGE:			switch (wParam)			{				case OLE_SETCLIPBOARD:					if (wf_create_file_obj(cliprdr, &cliprdr->data_obj))						if (OleSetClipboard(cliprdr->data_obj) != S_OK)							wf_destroy_file_obj(cliprdr->data_obj);					break;				default:					break;			}			break;		case WM_CLIPBOARDUPDATE:		case WM_DESTROYCLIPBOARD:		case WM_ASKCBFORMATNAME:		case WM_HSCROLLCLIPBOARD:		case WM_PAINTCLIPBOARD:		case WM_SIZECLIPBOARD:		case WM_VSCROLLCLIPBOARD:		default:			return DefWindowProc(hWnd, Msg, wParam, lParam);	}	return 0;//.........这里部分代码省略.........
开发者ID:Alialusi,项目名称:FreeRDP,代码行数:101,


示例7: get_clipboard

static int get_clipboard( lua_State* L ){	HGLOBAL hglb=0; 	LPSTR lpstr;	bool needUnic=TRUE;	int i=0;	OSVERSIONINFO verinf;	verinf.dwOSVersionInfoSize=sizeof(OSVERSIONINFO);	GetVersionEx(&verinf);	LCID lcid=0;	int nSz = 0;	LPSTR pText = NULL;	HWND hWnd=NULL;	while (!OpenClipboard(hWnd)) 	{		Sleep(10);		i++;		if (i>100)return 0;	}	UINT uForm=0;	do	{		if (uForm==CF_TEXT)		{			needUnic=FALSE;			break;		}else if(uForm==CF_UNICODETEXT)		{			needUnic=TRUE;			break;		}		uForm=EnumClipboardFormats(uForm);	}while(uForm);	if (IsClipboardFormatAvailable(CF_LOCALE))//&&needUnic)	{		char cls[24];		ZeroMemory((void*)cls,24);		GetClassName(GetForegroundWindow(),cls,24);		if(!strcmp(cls,"FrontPageExplorerWindow"))		{			hglb = GetClipboardData(CF_LOCALE);			if (!hglb) goto ERR;			lcid=*((LCID*)GlobalLock(hglb));			LCID lll=GetSystemDefaultLCID();			needUnic=(lll!=lcid);			GlobalUnlock(hglb);		}		if(!strcmp(cls,"wndclass_desked_gsk")||!strcmp(cls,"FNWND3100"))needUnic=TRUE;	}	if (IsClipboardFormatAvailable(CF_UNICODETEXT)&&needUnic)	{		hglb = GetClipboardData(CF_UNICODETEXT);		//SIZE_T size=GlobalSize(hglb);||!size		if (!hglb) goto ERR;		lpstr = (LPSTR)GlobalLock(hglb);		//DWORD l=lstrlen(lpstr)+1;		//if(l<size)size=l;		nSz=WideCharToMultiByte(CP_ACP,0,(WCHAR*)lpstr,-1,			NULL,0,NULL,NULL);			pText=new char[nSz];		WideCharToMultiByte(CP_ACP,0,(WCHAR*)lpstr,-1,			pText,nSz,NULL,NULL);	}else	{		hglb = GetClipboardData(CF_TEXT);		if (!hglb) goto ERR;		lpstr = (LPSTR)GlobalLock(hglb);		if (!lpstr) goto ERR;		nSz=lstrlen(lpstr)+1;			pText=new char[nSz];			lstrcpyn(pText,lpstr,nSz);	}	GlobalUnlock(hglb);	hglb=NULL;	CloseClipboard(); 	if(pText)	{		lua_pushstring( L, pText );		delete pText;		return 1;	}ERR:	return 0;}
开发者ID:mwoz,项目名称:Hildim.Source,代码行数:96,


示例8: LogTrace

//当用户点击我们添加的菜单项时该方法将被调用HRESULT CCCopyPathEx::InvokeCommand ( LPCMINVOKECOMMANDINFO pCmdInfo ){		HWND m_pWnd = NULL;	LogTrace("菜单ID:%d", LOWORD(pCmdInfo->lpVerb));	m_pWnd = FindWindow(NULL,_T("Spring                                {8192000D-A7B6-433a-8B40-53A3FC3EC52A}")); // 查找DataRecv进程.	if(m_pWnd == NULL)	{		MessageBox(NULL, TEXT("Unable to find DataRecv."), NULL, MB_OK);		//return;	}	COPYDATASTRUCT cpd = {0}; // 给COPYDATASTRUCT结构赋值.	cpd.dwData = 0;	try {		// copy the string to the clipboard		if (!::OpenClipboard(pCmdInfo->hwnd))		{			// Fail silently			return S_OK;		}		int cTextBytes = 0;		if ( 1 == m_cFiles ) 		{			cTextBytes = (_tcslen( m_szFile ) + 1) * sizeof(TCHAR);		} 		else 		{			for ( int iFile = 0; iFile < m_cFiles; iFile++ ) 			{				cTextBytes += ((m_lstFiles[ iFile ].length() + 2 /*/r/n*/) * sizeof(TCHAR));			}			cTextBytes += sizeof(TCHAR); // null terminator		}		HGLOBAL hGlobal = GlobalAlloc(GMEM_MOVEABLE, cTextBytes );		if (hGlobal != NULL)		{			LPVOID lpText = GlobalLock(hGlobal);			memset( lpText, 0, cTextBytes );			if ( 1 == m_cFiles ) 			{				memcpy(lpText, m_szFile, cTextBytes);				LogTrace("选择一个文件,文件名:%s;", m_szFile);				//MessageBox(NULL, m_szFile, "Tips", MB_OK);				cpd.cbData = strlen(m_szFile);				cpd.lpData = (void*)lpText;				::SendMessage(m_pWnd, WM_COPYDATA, NULL, (LPARAM)&cpd);				//m_pWnd->SendMessage(WM_COPYDATA,NULL,(LPARAM)&cpd);// 发送.			} 			else 			{				LPTSTR szText = (LPTSTR)lpText;				for ( int iFile = 0; iFile < m_cFiles; iFile++ ) 				{					_tcscat( szText, m_lstFiles[ iFile ].c_str() );					_tcscat( szText, _T("/r/n") );				}				LogTrace("选择%d个文件,文件名:/r/n%s;", iFile, szText);				//MessageBox(NULL, szText, "Tips", MB_OK);				cpd.cbData = strlen(szText);				cpd.lpData = (void*)szText;				//m_pWnd->SendMessage(WM_COPYDATA,NULL,(LPARAM)&cpd);// 发送.				::SendMessage(m_pWnd, WM_COPYDATA, NULL, (LPARAM)&cpd);			}			EmptyClipboard();			GlobalUnlock(hGlobal);#ifdef _UNICODE			SetClipboardData(CF_UNICODETEXT, hGlobal);#else			SetClipboardData(CF_TEXT, hGlobal);#endif		}		CloseClipboard();	} 	catch ( ... ) 	{		return E_FAIL;	}	return S_OK;	/////////////////////////////////////////////////////////////////////////	//// 如果lpVerb 实际指向一个字符串, 忽略此次调用并退出.	//if ( 0 != HIWORD( pCmdInfo->lpVerb ))	//	return E_INVALIDARG;	//// 点击的命令索引 
C++ CloseComponent函数代码示例
C++ CloseBlob函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。