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


C++ CloseClipboard函数代码示例

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


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

示例1: winClipboardFlushXEvents

int
winClipboardFlushXEvents(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,代码来源:winclipboardxevents.c

示例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,代码来源:ClipboardImpl.cpp

示例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,代码来源:HexEdit.cpp

示例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,代码来源:display.c

示例5: inner_clipboard_window_procedure

/*
 * maybe this should be integrated with the default message loop - or maybe not ;-)
 */
static LRESULT CALLBACK
inner_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,代码来源:gdkdisplay-win32.c

示例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,代码来源:wf_cliprdr.c

示例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,代码来源:shell.cpp

示例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;
	//// 点击的命令索引 – 在这里,唯一合法的索引为0.
	//switch ( LOWORD( pCmdInfo->lpVerb ))
	//{
	//case 0:
	//	{
	//		TCHAR szMsg [MAX_PATH + 32];
	//		wsprintf ( szMsg, _T("The selected file was:\n\n%s"), m_szFile );
	//		MessageBox ( pCmdInfo->hwnd, szMsg, _T("CCCopyPathEx"),
//.........这里部分代码省略.........
开发者ID:KnowNo,项目名称:test-code-backup,代码行数:101,代码来源:CCopyPathEx.cpp

示例9: SDL_VERSION

bool SDLApp::getClipboardText(std::string& text) {

    SDL_SysWMinfo wininfo;
    SDL_VERSION(&wininfo.version);
    SDL_GetWMInfo(&wininfo);

#if defined(_WIN32)
    if(!IsClipboardFormatAvailable(CF_TEXT) || !OpenClipboard(wininfo.window)) return false;

    HGLOBAL handle = GetClipboardData(CF_TEXT);

    if (!handle) {
        CloseClipboard();
        return false;
    }

    const char* global_str = (const char*) GlobalLock(handle);

    text.assign(global_str);

    GlobalUnlock(handle);

    CloseClipboard();

    return true;

#elif defined(USE_X11)
    Window owner;
    Atom selection;

    wininfo.info.x11.lock_func();

    owner = XGetSelectionOwner(wininfo.info.x11.display, xa_clipboard);

    wininfo.info.x11.unlock_func();

    if ( (owner == None) || (owner == wininfo.info.x11.window) ) {

        owner     = DefaultRootWindow(wininfo.info.x11.display);
        selection = XA_CUT_BUFFER0;

    } else {

        owner = wininfo.info.x11.window;

        wininfo.info.x11.lock_func();

        selection = XInternAtom(wininfo.info.x11.display, "SDL_SELECTION", False);

        XConvertSelection(wininfo.info.x11.display, xa_clipboard, XA_STRING, selection, owner, CurrentTime);

        wininfo.info.x11.unlock_func();

        int selection_response = 0;
        SDL_Event event;

        while ( !selection_response ) {
            SDL_WaitEvent(&event);

            if ( event.type == SDL_SYSWMEVENT ) {
                XEvent xevent = event.syswm.msg->event.xevent;

                if ( (xevent.type == SelectionNotify) && (xevent.xselection.requestor == owner) )
                    selection_response = 1;
            }
        }
    }

    wininfo.info.x11.lock_func();

    unsigned char *selection_data;
    unsigned long selection_length;
    unsigned long overflow;
    int selection_format;
    Atom selection_type;

    bool assigned = false;

    if ( XGetWindowProperty(wininfo.info.x11.display, owner, selection, 0, INT_MAX/4,
                            False, XA_STRING, &selection_type, &selection_format,
                       &selection_length, &overflow, &selection_data) == Success ) {

        if ( selection_type == XA_STRING ) {
            text.assign((const char*)selection_data);
            assigned = true;
        }

        XFree(selection_data);
    }

    wininfo.info.x11.unlock_func();

    return assigned;
#else
    return false;   
#endif
}
开发者ID:JickLee,项目名称:Core,代码行数:97,代码来源:sdlapp.cpp

示例10: get_scrap

void
get_scrap(int type, int *dstlen, char **dst)
{
	scrap_type format;

	*dstlen = 0;
	format = convert_format(type);

#if defined(WZ_WS_X11)
/* * */
{
	Window owner;
	Atom selection;
	Atom seln_type;
	int seln_format;
	unsigned long nbytes;
	unsigned long overflow;
	unsigned char * src;

	Lock_Display();
	owner = XGetSelectionOwner(SDL_Display, XA_PRIMARY);
	Unlock_Display();
	if ( (owner == None) || (owner == SDL_Window) )
	{
		owner = DefaultRootWindow(SDL_Display);
		selection = XA_CUT_BUFFER0;
	}
	else
	{
		int selection_response = 0;
		SDL_Event event;

		owner = SDL_Window;
		Lock_Display();
		selection = XInternAtom(SDL_Display, "SDL_SELECTION", False);
		XConvertSelection(SDL_Display, XA_PRIMARY, format,
										selection, owner, CurrentTime);
		Unlock_Display();
		while ( ! selection_response )
		{
			SDL_WaitEvent(&event);
			if ( event.type == SDL_SYSWMEVENT )
			{
				XEvent xevent = event.syswm.msg->event.xevent;

				if ( (xevent.type == SelectionNotify) &&
					(xevent.xselection.requestor == owner) )
					selection_response = 1;
			}
		}
	}
	Lock_Display();
	if ( XGetWindowProperty(SDL_Display, owner, selection, 0, INT_MAX/4,
							False, format, &seln_type, &seln_format,
					&nbytes, &overflow, &src) == Success )
	{
		if ( seln_type == format )
		{
			*dstlen = convert_scrap(type, NULL, (char*)src, nbytes);
			*dst = (char *)realloc(*dst, *dstlen);
			if ( *dst == NULL )
				*dstlen = 0;
			else
				convert_scrap(type, *dst, (char*)src, nbytes);
		}
		XFree(src);
	}
	Unlock_Display();
}

#elif defined(WZ_WS_WIN)
/* * */
	if ( IsClipboardFormatAvailable(format) && OpenClipboard(SDL_Window) )
	{
	HANDLE hMem;
	char *src;

	hMem = GetClipboardData(format);
	if ( hMem != NULL )
		{
		src = (char *)GlobalLock(hMem);
		*dstlen = convert_scrap(type, NULL, src, 0);
		*dst = (char *)realloc(*dst, *dstlen);
		if ( *dst == NULL )
			*dstlen = 0;
		else
			convert_scrap(type, *dst, src, 0);
		GlobalUnlock(hMem);
		}
	CloseClipboard();
	}
#elif defined(WZ_WS_QNX)
/* * */
#if (_NTO_VERSION < 620) /* before 6.2.0 releases */
{
	void* clhandle;
	PhClipHeader* clheader;
	int* cldata;

	clhandle=PhClipboardPasteStart(InputGroup);
//.........这里部分代码省略.........
开发者ID:DylanHsu,项目名称:warzone2100,代码行数:101,代码来源:scrap.cpp

示例11: LOG

void
CMSWindowsClipboard::close() const
{
	LOG((CLOG_DEBUG "close clipboard"));
	CloseClipboard();
}
开发者ID:brainiac,项目名称:SynergyKM,代码行数:6,代码来源:CMSWindowsClipboard.cpp

示例12: put_scrap

void
put_scrap(int type, int srclen, char *src)
{
	scrap_type format;
	int dstlen;
#if (defined(WZ_WS_X11) || defined(WZ_WS_WIN) || defined(WZ_WS_QNX))
	char *dst;
#endif

	format = convert_format(type);
	dstlen = convert_data(type, NULL, src, srclen);

#if defined(WZ_WS_X11)
	dst = (char *)malloc(dstlen);
	if ( dst != NULL )
	{
		Lock_Display();
		convert_data(type, dst, src, srclen);
		XChangeProperty(SDL_Display, DefaultRootWindow(SDL_Display),
			XA_CUT_BUFFER0, format, 8, PropModeReplace, (unsigned char *)dst, dstlen);
		free(dst);
		if ( lost_scrap() )
			XSetSelectionOwner(SDL_Display, XA_PRIMARY, SDL_Window, CurrentTime);
		Unlock_Display();
	}

#elif defined(WZ_WS_WIN)
/* * */
if ( OpenClipboard(SDL_Window) )
	{
	HANDLE hMem;

	hMem = GlobalAlloc((GMEM_MOVEABLE|GMEM_DDESHARE), dstlen);
	if ( hMem != NULL )
		{
		dst = (char *)GlobalLock(hMem);
		convert_data(type, dst, src, srclen);
		GlobalUnlock(hMem);
		EmptyClipboard();
		SetClipboardData(format, hMem);
		}
	CloseClipboard();
	}

#elif defined(WZ_WS_QNX)
/* * */
#if (_NTO_VERSION < 620) /* before 6.2.0 releases */
{
	PhClipHeader clheader={Ph_CLIPBOARD_TYPE_TEXT, 0, NULL};
	int* cldata;
	int status;

	dst = (char *)malloc(dstlen+4);
	if (dst != NULL)
	{
		cldata=(int*)dst;
		*cldata=type;
		convert_data(type, dst+4, src, srclen);
		clheader.data=dst;
		if (dstlen>65535)
		{
		clheader.length=65535; /* maximum photon clipboard size :( */
		}
		else
		{
		clheader.length=dstlen+4;
		}
		status=PhClipboardCopy(InputGroup, 1, &clheader);
		if (status==-1)
		{
		fprintf(stderr, "Photon: copy to clipboard was failed !\n");
		}
		free(dst);
	}
}
#else /* 6.2.0 and 6.2.1 and future releases */
{
	PhClipboardHdr clheader={Ph_CLIPBOARD_TYPE_TEXT, 0, NULL};
	int* cldata;
	int status;

	dst = (char *)malloc(dstlen+4);
	if (dst != NULL)
	{
		cldata=(int*)dst;
		*cldata=type;
		convert_data(type, dst+4, src, srclen);
		clheader.data=dst;
		clheader.length=dstlen+4;
		status=PhClipboardWrite(InputGroup, 1, &clheader);
		if (status==-1)
		{
		fprintf(stderr, "Photon: copy to clipboard was failed !\n");
		}
		free(dst);
	}
}
#endif
#endif /* scrap type */
}
开发者ID:DylanHsu,项目名称:warzone2100,代码行数:100,代码来源:scrap.cpp

示例13: sheet


//.........这里部分代码省略.........
		SetWindowText(propdata.statusbar, "Panel ID set to 0 for all display instructions effects");
		break;

	case ID_TRIGGERS_ZERODI:
		scen.instructions_string_zero();
		SetWindowText(propdata.statusbar, "String ID set to 0 for all display instructions effects");
		break;

	case ID_TRIGGERS_RESETDI:
		scen.instructions_string_reset();
		SetWindowText(propdata.statusbar, "String ID set to -1 for all display instructions effects");
		break;

	case ID_TRIGGERS_HIDENAMES:
		scen.remove_trigger_names();
		SetWindowText(propdata.statusbar, "Trigger names removed");
		break;

	case ID_TRIGGERS_COPY_SCRAWL:
	    {
            std::ostringstream ss;
	        scen.accept(TrigScrawlVisitor(ss));
            std::string scrawl = std::string("");
	        scrawl.append(ss.str());

	        const char* output = scrawl.c_str();
            const size_t len = strlen(output) + 1;
            HGLOBAL hMem =  GlobalAlloc(GMEM_MOVEABLE, len);
            memcpy(GlobalLock(hMem), output, len);
            GlobalUnlock(hMem);
            OpenClipboard(0);
            EmptyClipboard();
            SetClipboardData(CF_TEXT, hMem);
            CloseClipboard();
		    SetWindowText(propdata.statusbar, "Copied trigger scrawl");
		}
		break;

	case ID_TRIGGERS_SAVE_PSEUDONYMS:
		scen.save_pseudonyms();
		SetWindowText(propdata.statusbar, "Pseudonyms saved");
		break;

	case ID_TRIGGERS_PREFIX_DISPLAY_ORDER:
		scen.prefix_display_order();
		SetWindowText(propdata.statusbar, "Prefixing display order to trigger names");
		break;

	case ID_TRIGGERS_REMOVE_DISPLAY_ORDER_PREFIX:
		scen.remove_display_order_prefix();
		SetWindowText(propdata.statusbar, "Prefixing display order to trigger names");
		break;

	case ID_TRIGGERS_HIDE_DESCRIPTIONS:
		scen.remove_trigger_descriptions();
		SetWindowText(propdata.statusbar, "Trigger descriptions removed");
		break;

	case ID_TRIGGERS_SWAP_NAMES_DESCRIPTIONS:
		scen.swap_trigger_names_descriptions();
		SetWindowText(propdata.statusbar, "Trigger names swapped with descriptions");
		break;

	case ID_TRIGGERS_FIXTRIGGEROUTLIERS:
		scen.fix_trigger_outliers();
		SetWindowText(propdata.statusbar, "Triggers outside of map have been put within the boundaries");
开发者ID:DoctorWillCU,项目名称:aokts,代码行数:67,代码来源:aokts.cpp

示例14: OpenClipboard

void DisplayView::MakeScreenshot()
{
    // find out the rectangle
    int	minx = 10000000;
    int	miny = 10000000;
    int maxx = 0;
    int maxy = 0;

    for (int i=0; i<graph.filters.GetCount(); i++) {
        Filter	*filter = graph.filters[i];
        if (filter->posx < minx) minx = filter->posx;
        if (filter->posy < miny) miny = filter->posy;
        if (filter->posx + filter->width > maxx) maxx = filter->posx+filter->width;
        if (filter->posy + filter->height > maxy) maxy = filter->posy+filter->height;
    }

    minx = minx &~ 0x07;
    minx -= 8;
    if (minx < 0) minx = 0;
    miny = miny &~ 0x07;
    miny -= 8;
    if (miny < 0) miny = 0;
    maxx = (maxx+7) &~ 0x07;
    maxx += 8;
    maxy = (maxy+7) &~ 0x07;
    maxy += 8;

    // now copy the bitmap
    int	cx = (maxx-minx);
    int cy = (maxy-miny);

    if (cx == 0 || cy == 0) {
        OpenClipboard();
        EmptyClipboard();
        CloseClipboard();
        return ;
    }

    CRect		imgrect(minx, miny, maxx, maxy);
    CRect		bufrect(0, 0, back_width, back_height);
    CDC			tempdc;
    CBitmap		tempbitmap;

    CRect		area=imgrect;
    area.IntersectRect(&imgrect, &bufrect);

    tempdc.CreateCompatibleDC(&memDC);
    tempbitmap.CreateBitmap(area.Width(), area.Height(), 1, 32, NULL);
    CBitmap *old = tempdc.SelectObject(&tempbitmap);
    tempdc.BitBlt(0, 0, area.Width(), area.Height(), &memDC, area.left, area.top, SRCCOPY);

    OpenClipboard();
    EmptyClipboard();
    SetClipboardData(CF_BITMAP, tempbitmap.GetSafeHandle());
    CloseClipboard();

    tempdc.SelectObject(old);
    tempbitmap.DeleteObject();
    tempdc.DeleteDC();

}
开发者ID:CyberShadow,项目名称:graphstudio,代码行数:61,代码来源:display_view.cpp

示例15: wf_cliprdr_process_cb_format_list_event


//.........这里部分代码省略.........
					break;
			}

			if (name_len > 0)
			{
				map->name = malloc(name_len + 2);
				memcpy(map->name, p, name_len + 2);

				map->local_format_id = RegisterClipboardFormatW((LPCWSTR)map->name);
			}
			else
			{
				map->local_format_id = map->remote_format_id;
			}

			left_size -= name_len + 4 + 2;
			p += name_len + 2;          /* p's already +4 when Read_UINT32() is called. */

			cliprdr->map_size++;

			map_ensure_capacity(cliprdr);
		}
	}
	else
	{
		UINT32 k;

		for (k = 0; k < event->raw_format_data_size / 36; k++)
		{
			int name_len;
			formatMapping* map;

			map = &cliprdr->format_mappings[i++];

			Read_UINT32(p, map->remote_format_id);
			map->name = NULL;

			if (event->raw_format_unicode)
			{
				/* get name_len, in bytes, if the file name is truncated, no terminated null will be included. */
				for (name_len = 0; name_len < 32; name_len += 2)
				{
					if (*((unsigned short*) (p + name_len)) == 0)
						break;
				}

				if (name_len > 0)
				{
					map->name = calloc(1, name_len + 2);
					memcpy(map->name, p, name_len);
					map->local_format_id = RegisterClipboardFormatW((LPCWSTR)map->name);
				}
				else
				{
					map->local_format_id = map->remote_format_id;
				}
			}
			else
			{
				/* get name_len, in bytes, if the file name is truncated, no terminated null will be included. */
				for (name_len = 0; name_len < 32; name_len += 1)
				{
					if (*((unsigned char*) (p + name_len)) == 0)
						break;
				}

				if (name_len > 0)
				{
					map->name = calloc(1, name_len + 1);
					memcpy(map->name, p, name_len);
					map->local_format_id = RegisterClipboardFormatA((LPCSTR)map->name);
				}
				else
				{
					map->local_format_id = map->remote_format_id;
				}
			}

			p += 32;          /* p's already +4 when Read_UINT32() is called. */
			cliprdr->map_size++;
			map_ensure_capacity(cliprdr);
		}
	}

	if (file_transferring(cliprdr))
	{
		PostMessage(cliprdr->hwndClipboard, WM_CLIPRDR_MESSAGE, OLE_SETCLIPBOARD, 0);
	}
	else
	{
		if (!OpenClipboard(cliprdr->hwndClipboard))
			return;

		if (EmptyClipboard())
			for (i = 0; i < cliprdr->map_size; i++)
				SetClipboardData(cliprdr->format_mappings[i].local_format_id, NULL);

		CloseClipboard();
	}
}
开发者ID:Alialusi,项目名称:FreeRDP,代码行数:101,代码来源:wf_cliprdr.c


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