2.1.25.59 OpenClipboard


Description

Opens the clipboard for examination and prevents other applications from modifying the clipboard content.

Syntax

BOOL OpenClipboard( HWND hWndNewOwner )

Parameters

hWndNewOwner
[input] Handle to the window to be associated with the open clipboard. If this parameter is NULL, the open clipboard is associated with the current task.

Return

Returns TRUE on successful exit and FALSE on error.

Examples

EX1

int OpenClipboard_ex1()
{
    if(!OpenClipboard(NULL))
        return 0;
    
    if(IsClipboardFormatAvailable(CF_TEXT))
    {
        HANDLE hData = GetClipboardData(CF_TEXT);
        LPCSTR lpData = (LPCSTR)GlobalLock(hData);
        string str = lpData;
        GlobalUnlock(hData);
        out_str(str);
    }
    else
        out_str("No Text in clipboard");
    
    CloseClipboard();
    return 1;
}

Remark

This function opens the clipboard for examination and prevents other applications from modifying the clipboard content. .

OpenClipboard fails if another window has the clipboard open.

An application should call the CloseClipboard function after every successful call to OpenClipboard.

The window identified by the hWndNewOwner parameter does not become the clipboard owner unless the EmptyClipboard function is called.

See Also

CloseClipboard

Header to Include

origin.h

Reference