944,139 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 2173
  • C++ RSS
Oct 13th, 2009
0

Add Text To multiline textbox

Expand Post »
Hey guys i've tryed to find how to do this the best way but it failed. So i want to ask the experts here:

How to add a new line of text to a edit control.
Example: I have alredy some text in the edibox and i want to add some text on the next line.

Thanks in advance:
~Cha0sBG
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
ChaosBG is offline Offline
2 posts
since Oct 2009
Oct 13th, 2009
0
Re: Add Text To multiline textbox
The edit box has to be created with the appropriate style to act as a multi-line text box. Look up the styles - off the top of my head I just don't have them memorized. But if the right style wasn't used at creation time - it just ain't gonna ever be a multi-line edit box.

added later - from Api CreateWindow() docs...

ES_MULTILINE Designates a multiline edit control. The default is single-line edit control.

Here would be what a CreateWindowEx() call to create such an edit control would look like...

C++ Syntax (Toggle Plain Text)
  1. hEdit=
  2. CreateWindowEx
  3. (
  4. WS_EX_CLIENTEDGE,
  5. "edit",
  6. "",
  7. WS_CHILD|WS_VISIBLE|ES_AUTOHSCROLL|ES_MULTILINE|WS_VSCROLL,
  8. 60,80,620,24,
  9. hWnd,
  10. (HMENU)IDC_EDIT,
  11. ghInst,
  12. 0
  13. );
Last edited by Frederick2; Oct 13th, 2009 at 12:04 pm. Reason: add cast
Reputation Points: 244
Solved Threads: 31
Posting Whiz
Frederick2 is offline Offline
330 posts
since Jul 2008
Oct 13th, 2009
0
Re: Add Text To multiline textbox
I just need a way to add text to it but not the

  1. SetDlgItemText

~Cha0sBG
Last edited by ChaosBG; Oct 13th, 2009 at 11:56 am.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
ChaosBG is offline Offline
2 posts
since Oct 2009
Oct 13th, 2009
0
Re: Add Text To multiline textbox
It wouldn't hurt to be clearer in your question then. To add additional text to a text box (multiline or otherwise), you need to retrieve the text already in the text box into a string variable/buffer within your program using GetWindowText() or some such, then concatenate your additional text onto it, then finally replace the entirety of the original text in the text box with the new.
Reputation Points: 244
Solved Threads: 31
Posting Whiz
Frederick2 is offline Offline
330 posts
since Jul 2008
Oct 13th, 2009
-1
Re: Add Text To multiline textbox
Click to Expand / Collapse  Quote originally posted by Frederick2 ...
To add additional text to a text box (multiline or otherwise), you need to retrieve the text already in the text box into a string variable/buffer
No, you don't need to retrieve the text !
It's a very old Win16-Win32 FAQ, see (Win32 grp) with EM
Reputation Points: -76
Solved Threads: 14
Junior Poster
marco93 is offline Offline
132 posts
since Apr 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Spot stack errors
Next Thread in C++ Forum Timeline: Why `system("pause")' shouldn't be used?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC