Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Accessing clipboard in a console app. 1

Status
Not open for further replies.

GMX

Programmer
Mar 21, 2003
33
US
Is it possible? If yes then which header do I need?
 
Dunno, did you try it and get some errors or something? What are they?

-pete
 
(I'm using Microsoft Visual C++ .NET BETA)
I have an object, when it's constructed I want it to check if the right data is copied in the clipboard and then put into an array of chars. Here's the constructor:

CTarget::CTarget(void)
{
if ( IsClipboardFormatAvailable(CF_TEXT) )
{
if( IsGTreport( GetClipboardData(CF_TEXT) ) )
{
this->report = GetClipboardData(CF_TEXT);
cout << this->report;
}
else
{
cout << &quot;Paste GT report:&quot; << endl;
cin >> this->report;
}
}
else
{
cout << &quot;Paste GT report:&quot; << endl;
cin >> this->report;
}
}

When compiled:

Target.cpp : error C2065: 'CF_TEXT' : undeclared identifier
Target.cpp : error C3861: 'IsClipboardFormatAvailable': identifier not found, even with argument-dependent lookup
Target.cpp : error C3861: 'IsGTreport': identifier not found, even with argument-dependent lookup
Target.cpp : error C3861: 'GetClipboardData': identifier not found, even with argument-dependent lookup
Target.cpp : error C3861: 'CF_TEXT': identifier not found, even with argument-dependent lookup
Target.cpp : error C3861: 'GetClipboardData': identifier not found, even with argument-dependent lookup
Target.cpp : error C3861: 'CF_TEXT': identifier not found, even with argument-dependent lookup

Obviously missing a header file.

If you &quot;Go to Defenition&quot; it takes you to winuser.h
So I include it... and:

e:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinUser.h(42) : error C2146: syntax error : missing ';' before identifier 'HDWP'
e:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinUser.h(42) : error C2501: 'HDWP' : missing storage-class or type specifiers
e:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinUser.h(43) : error C2146: syntax error : missing ';' before identifier 'MENUTEMPLATEA'
e:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinUser.h(43) : error C2501: 'MENUTEMPLATEA' : missing storage-class or type specifiers
e:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinUser.h(48) : error C2146: syntax error : missing ';' before identifier 'MENUTEMPLATE'
e:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinUser.h(48) : error C2378: 'MENUTEMPLATEA' : redefinition; symbol cannot be overloaded with a typedef
e:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinUser.h(43) : see declaration of 'MENUTEMPLATEA'
e:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinUser.h(48) : error C2501: 'MENUTEMPLATE' : missing storage-class or type specifiers
e:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinUser.h(50) : error C2146: syntax error : missing ';' before identifier 'LPMENUTEMPLATEA'
e:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinUser.h(50) : error C2501: 'LPMENUTEMPLATEA' : missing storage-class or type specifiers
e:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinUser.h(55) : error C2146: syntax error : missing ';' before identifier 'LPMENUTEMPLATE'
e:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinUser.h(55) : error C2378: 'LPMENUTEMPLATEA' : redefinition; symbol cannot be overloaded with a typedef
e:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinUser.h(50) : see declaration of 'LPMENUTEMPLATEA'
e:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinUser.h(55) : error C2501: 'LPMENUTEMPLATE' : missing storage-class or type specifiers
e:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinUser.h(58) : error C2065: 'CALLBACK' : undeclared identifier
e:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinUser.h(58) : error C2065: 'WNDPROC' : undeclared identifier
e:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinUser.h(58) : error C2501: 'LRESULT' : missing storage-class or type specifiers
e:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinUser.h(58) : fatal error C1903: unable to recover from previous error(s); stopping compilation
 
Hey GMX, i see your new to Tek-Tips, welcome [cheers]

What's your background? It helps if we have some idea where your coming from. Is this your first console app?

Try including <windows.h>

-pete
 
Well I'm a pretty noobish programer. I took Comp Sci 11, so no this isn't my 1st app. including windows.h still gives me:

...\Visual Studio Projects\Read GT Report\Target.cpp(9) : error C2065: 'CF_TEXT' : undeclared identifier
...\Visual Studio Projects\Read GT Report\Target.cpp(9) : error C3861: 'IsClipboardFormatAvailable': identifier not found, even with argument-dependent lookup
...\Visual Studio Projects\Read GT Report\Target.cpp(11) : error C3861: 'GetClipboardData': identifier not found, even with argument-dependent lookup
...\Visual Studio Projects\Read GT Report\Target.cpp(11) : error C3861: 'CF_TEXT': identifier not found, even with argument-dependent lookup
...\Visual Studio Projects\Read GT Report\Target.cpp(13) : error C3861: 'GetClipboardData': identifier not found, even with argument-dependent lookup
...\Visual Studio Projects\Read GT Report\Target.cpp(13) : error C3861: 'CF_TEXT': identifier not found, even with argument-dependent lookup
 
At the top of Target.cpp do you have
Code:
#define WIN32_LEAN_AND_MEAN
#include <windows.h>

That's all it takes for me to be able to call
Code:
IsClipboardFormatAvailable(CF_TEXT);

-pete
 
Thanks a bunch!

I didn't have the

#define WIN32_LEAN_AND_MEAN

correction, didn't know i should have that :p
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top