CWnd::OpenClipboard
TOC
Collapse the table of content
Expand the table of content
This documentation is archived and is not being maintained.

CWnd::OpenClipboard

Opens the Clipboard.

BOOL OpenClipboard( );

Return Value

Nonzero if the Clipboard is opened via CWnd, or 0 if another application or window has the Clipboard open.

Remarks

Other applications will not be able to modify the Clipboard until the CloseClipboard Windows function is called.

The current CWnd object will not become the owner of the Clipboard until the EmptyClipboard Windows function is called.

Example

//handler for Edit | Copy menu
void CTestDlgView::OnEditCopy() 
{
   if ( !OpenClipboard() )
   {
      AfxMessageBox( "Cannot open the Clipboard" );
      return;
   }
   // Remove the current Clipboard contents  
   if( !EmptyClipboard() )
   {
      AfxMessageBox( "Cannot empty the Clipboard" );
      return;  
   }
   // ...
   // Get the currently selected data, hData handle to 
   // global memory of data
   // ...
   // For the appropriate data formats...
   if ( ::SetClipboardData( CF_??, hData ) == NULL )  
   {
      AfxMessageBox( "Unable to set Clipboard data" );    
      CloseClipboard();
      return;  
   }  
   // ...  
   CloseClipboard();
}

See Also

CWnd Overview | Class Members | Hierarchy Chart | CloseClipboard | EmptyClipboard | OpenClipboard

Show:
© 2016 Microsoft