1

I'm currently working on code that I inherited. There is a class (I'll refer to it as logWindow) which inherits from CDialog. Overall the logWindow class creates a window and prints out text.

What I need to do is copy the text that is automatically generated in the window.

I know I need some sort of mouse and keyboard listener, but I'm a little lost on how to do this and how to select text.

I also have working code for a different log window written by the same person. That code has a class (I'll refer to it as copyList) which inherits from CListbox. Unfortunately the code isn't well documented or managed, so it is difficult to figure out which functions are related to copying text and which functions are related to other things such as auto scrolling.

I apologize if this is very unspecific, because of what I'm working on I'm limited in how much I can post. I will update the question with as much information as I can.

  • Welcome to stackoverflow! There is not enough information in the question in order for us to answer. Please refer to the [asking help](http://stackoverflow.com/help/how-to-ask) for a guideline on how to ask your question. – Nasser Al-Shawwa Jul 08 '15 at 12:11
  • Since you have the code, surely it would be better to hook the part of the code that's adding the text to the window. If you can't for whatever reason, then determine what "control" in the dialog is receiving the text... you should be able to read it directly from the dialog's child control. – mark Jul 08 '15 at 12:13
  • Even with the latest edit, it's difficult to answer with specifics since there are not enough details. This might be telling: why do you think you need a mouse/kb listener? – mark Jul 08 '15 at 12:27
  • So what I need to do is be able to select certain text from the log window by highlighting it and then using ctr+c to copy it. I assumed I'd need a mouse/kb listener in order to be able to have the logWindow Class or the copyList class be able to know when something is clicked and selected inside the dialog window. My goal is to write the code to copy from the dialog window myself instead of copying what already exists, because there is usually a better/easier/more readable way to do things than the existing code base that I have. – Elizabeth O'Callaghan Jul 08 '15 at 12:36
  • @ElizabethO'Callaghan don't post long comments about your question, but **edit** your question so people can understand what you want. For now it is almost impossible answer this question because no one understands what the actual problem is. – Jabberwocky Jul 08 '15 at 13:38

1 Answers1

1

you can use GetWindowText or CWnd::GetWindowText to get the text from the control that holds the text, but this will copy all the text inside that control, so you will have to do tinker the text if you want some filtering.

you said you already have a CListBox example working so you know how to iterate over the items.
then you can use this link Clipboard: Using the Windows Clipboard and check how to handle the clipboard.
you could also add a simple button "Send to clipboard" that sends the text to the clipboard

Robson
  • 916
  • 5
  • 22