copying window text....please help! this language is insane.

C

chris kramer

i have an application that allows you to Select some text in a window,
but no option to Copy it to the clipboard (nor does Ctrl-C or
Shift-insert work, or right click etc..) i want to get these values
somehow.

below is the best posted method i have found online.
if anyone can elaborate, as to how to implement such message passing
(as a novice) i would be thrilled. i am using and old visual c++ 4
compiler with
an example program that simply creates instances of notepad-like
windows.
(to test the idea)
i can't find examples on how to implement message handling at the
simplest level. specifically what/where do i insert into a message
map, and where does the code go that 'listens' for this change in
window focus. (or will the below idea even work)
thanks.
chris

"
Assuming that you can get the window handle of the edit control
you are concerned with, I would think that all you need to do is
send a WM_COPY message to that control. That slaps the selected
text onto the clipboard:

SendMessage(hwndEdit,WM_COPY,0,0L);

You should be able to get the edit control's handle by calling
GetFocus() to see which window has the keyboard focus when your
button on the titlebar is pushed. I can see the problem with
this, though...when your application is activated by a button
push, YOUR app will have keyboard focus. To get around this,
you can process the WM_SETFOCUS message in your app to see which
window you are taking the focus FROM. This should be the edit
control with the selected text.
"
 
J

John Harrison

chris kramer said:
i have an application that allows you to Select some text in a window,
but no option to Copy it to the clipboard (nor does Ctrl-C or
Shift-insert work, or right click etc..) i want to get these values
somehow.

What language? You are talking about Win32 API programming not C++. You
would face exactly the same issue if you were using another language like
Pascal or assembly.

Please take this question to a group where is it relevant, like
comp.os.ms-windows.programmer.win32. Your question has no C++ content.

[snip]

John
 
C

chris kramer

john - you are right..
was overwhelmed and slightly drunk when i gave up and made a plea for
help :)
i have gotten closer - i can shut down a window in VB using WM_CLOSE
message.
(i gave up on using visual c++, it is absurdly complex)
WM_COPY doesn't seem to work though. If anyone knows anyone that can
get highlighted text from another window that won't allow direct
copying, i'd love to know how. ([email protected])
sorry about posting to the wrong place.. thank god Visual C++ is not
something the world accepts as a standard. i think it is a complete
nightmare.
 
V

Victor Bazarov

chris kramer said:
john - you are right..
was overwhelmed and slightly drunk when i gave up and made a plea for
help :)
i have gotten closer - i can shut down a window in VB using WM_CLOSE
message.
(i gave up on using visual c++, it is absurdly complex)
WM_COPY doesn't seem to work though. If anyone knows anyone that can
get highlighted text from another window that won't allow direct
copying, i'd love to know how. ([email protected])
sorry about posting to the wrong place.. thank god Visual C++ is not
something the world accepts as a standard. i think it is a complete
nightmare.

Please don't apologise for off-topic, post in the right newsgroup
instead: comp.os.ms-windows.programmer.

Thank you.

V
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,040
Latest member
papereejit

Latest Threads

Top