はじめまして、最近.NET Framework を勉強し始めたのですがとりあえずサンプルをいじっているのですが・・・
ヘルプドキュメント内のサンプルで
ms-help://MS.VSExpressCC.v80/MS.NETFramework.v20.ja/dv_vccore/html/99e77ba0-8573-4030-92d8-de8aa7623ee4.htm
にある「方法 : クリップボードからテキストを取得する」のサンプルがうまくクリップボードからテキストを取得できません!
常に"No data was found in the Clipboard." となります。
ビルドは、問題なく出来るのですが何が原因なのでしょう?
よろしくお願いいたします。
下記がそのサンプルです。
// read_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;
int main( )
{
IDataObject^ data = Clipboard::GetDataObject( );
if (data)
{
if (data->GetDataPresent(DataFormats::Text))
{
String^ text = static_cast<String^>
(data->GetData(DataFormats::Text));
Console::WriteLine(text);
}
else
Console::WriteLine("Nontext data is in the Clipboard.");
}
else
{
Console::WriteLine("No data was found in the Clipboard.");
}
return 0;
}
MSDN(Web)では、なぜかVC++だけClipboard::GetDataObject のサンプルが有りません!
http://msdn.microsoft.com/library/ja/default.asp?url=/library/ja/cpref/html/frlrfSystemWindowsFormsClipboardClassGetDataObjectTopic.asp