Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
hey. i have bin programming with c++ for quite some time. I know the basics like syntax, funtions etc....
Now i want to know how i can make a program copy some text to the windows clipboard..
i've tried googling for it but i always end up with nothing..
I would think i have to use API's and stuff wich i dont know ANYTHING about. neither do i know anything about MFC.So if anyone are willing to help it would be very nice.
The program i want to make is kind of like a keygen. but i want it to copy the link to the clipboard so that i can just open it and then paste it... without the hassle of [CTRL+C].I know its not that cool or anything... and that its quite unusable but i think its a good way to learn more.
So please help!

I know MFC would probably let you write a program to set a hot button so that when you press it it copy's the text. But MFC is really confusing, especialy if you dont know about OOP and havnt been working in c++ for roughly 6 months ish.
BUT anything is posible :).
If you choose to learn MFC I suggest the book
Programming Windows with MFC by Jeff Prosise.But im sure theres another way to accomplish your task without the use of MFC.
GIMPS

im sure about that too :) but thanks for clearing it up that its possible with mfc :D
and i dont know much about oop. i'm reading: c++ how to program by deitel & deitel.
have read about 300 pages but still nothing about mfc or oop.

Using the clipboard at the lowest level is very difficult...
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/dataexchange/clipboard.asp
I'm sure there are libraries out there to do it for you; for instance, MFC probably does some stuff for you..I don't use it, so I wouldn't know - I just ask gimps ;P -- otherwise, you could look one up onlineHope that helps!
BlueRaja.admin@gmail.com

Here is a tutorial:
//http://netez.com/2xExplorer/shellFAQ/adv_clip.htmlHere is a MFC example using these functions from tutorial:
BOOL SetClipboardText(LPCTSTR pszText)
int GetClipboardText(LPTSTR pszBuf, int nLength)1. Create 2 push button controls
IDC_PUT; // push button control
IDC_GET; // push button control2. Create 3 edit box controls
IDC_EDIT_PUT; // edit box control
IDC_EDIT_GET; // edit box control
IDC_EDIT_STATUS; // edit box control3. Create 3 Member Variables for edit box controls
CString m_get; // string associated with IDC_EDIT_GET edit box
CString m_put; // string associated with IDC_EDIT_PUT edit box
CString m_status; // string associated with IDC_EDIT_STATUS edit box4. Test the program
a. Type text into IDC_EDIT_PUT edit box
b. Click on IDC_PUT push button
c. Status appears in IDC_EDIT_STATUS edit box
d. Click on IDC_GET push button
e. Status appears in IDC_EDIT_STATUS edit box
f. Text from clipboard appears in IDC_EDIT_GET edit box// Function for clicking on IDC_PUT push button
void CTestClipboardDlg::OnPut()
{
BOOL success;
UpdateData(TRUE);
success = SetClipboardText(LPCTSTR(m_put));if (success)
m_status = "Put Success";
else
m_status = "Put Failure";
UpdateData(FALSE);
}// Function for clicking on IDC_GET push button
void CTestClipboardDlg::OnGet()
{
int result;
char buf[80];
int len = 80;
result = GetClipboardText(buf, len);
if (result>0)
{
m_status = "Get Success";
m_get = CString(buf);
}
else
m_status = "Get Failure";
UpdateData(FALSE);
}

thank you all! helped alot. Gonna try mess with the proggie in the weekend :D
again, thanks for the help!

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |