Condividi tramite


Procedura: memorizzare testo negli appunti (C++/CLI)

Nell'esempio di codice riportato di seguito viene utilizzato l'oggetto Clipboard definito nello spazio dei nomi System.Windows.Forms per memorizzare una stringa. In questo oggetto vengono fornite due funzioni membro: SetDataObject e GetDataObject. I dati vengono archiviati negli Appunti inviando un qualsiasi oggetto derivato da Object a SetDataObject.

Esempio

// store_clipboard.cpp
// compile with: /clr
#using <System.dll>
#using <System.Drawing.dll>
#using <System.Windows.Forms.dll>

using namespace System;
using namespace System::Windows::Forms;

[STAThread] int main()
{
   String^ str = "This text is copied into the Clipboard.";

   // Use 'true' as the second argument if
   // the data is to remain in the clipboard
   // after the program terminates.
   Clipboard::SetDataObject(str, true);

   Console::WriteLine("Added text to the Clipboard.");

   return 0;
}

Vedere anche

Attività

Procedura: recuperare testo dagli Appunti (C++/CLI)

Altre risorse

Operazioni Windows (C++/CLI)

.Guida per programmatori .NET