Solved

Multiline Text Area

Posted on 2001-09-13
4
524 Views
Last Modified: 2013-12-03
I have a edit control  (I am using c/sdk) which i tend to make it as text area to display my program message. the control has properties as:
vertical scroll, auto vscroll, want return.

I was wondering how can i add text in multiple line. for instance, i use
char *buf1 = "hello\r\n";
char *buf2 = "hai\r\n";
SendMessage(GetDlgItem(hDlg, IDC_CON_CON), WM_SETTEXT, 0, (LPARAM) buf1);

SendMessage(GetDlgItem(hDlg, IDC_CON_CON), WM_SETTEXT, 0, (LPARAM) buf2);

it can only display
hai

where i want
hello
hai


Pls help. If possible, do e-mail the solution to my mail box
yccheok@yahoo.com

since i don't have any internet access in this few day and it may take my sometimes to search back my message :)

thanks

regards
yccheok

0
Comment
Question by:yccheok
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 7

Expert Comment

by:peterchen092700
ID: 6481604
To append text, set selection to end of the box, and call ReplaceSel with the text to append.
0
 

Expert Comment

by:chandas
ID: 6486850
Hi there, this question has been asked and answered before. I can't search for the link but anyway, last time I said, the easiest way to do this is to use a function called InsertText(int a, LPSTR lpstr, BOOL b)

a = the zero based index of the position in the text area where you want to insert the text.

b = the string you want to insert

c = TRUE (most likely) it just specifies whether or not you want the insertion re-drawn (or something like that)

You cannot use WM_SETTEXT because it is designed to replace all the text with the current text. That's why you are seeing only your last entry.

Regards

Senkwe
0
 
LVL 7

Accepted Solution

by:
peterchen092700 earned 10 total points
ID: 6486957
>> InsertText(int a, LPSTR lpstr, BOOL b)
Where is this function declared? MSDN doesn't know this (in this context)

yccheok: any comments? anything else you need?

(btw. you would have gotten code if you had offered the 50pts for an easy question)

Peter

0
 

Expert Comment

by:chandas
ID: 6486971
Hi Peter, sorry...I use WTL (and hence I tend to forget that not everybody does) so InsertText is defined as follows for an edit or richedit control...


int InsertText(long nInsertAfterChar, LPCTSTR lpstrText, BOOL bCanUndo = FALSE)
     {
          int nRet = SetSel(nInsertAfterChar, nInsertAfterChar);
          ReplaceSel(lpstrText, bCanUndo);
          return nRet;
     }

So your solution works great if you're not using WTL. Funny thing is I answered the exact same question to a guy that was not using WTL and he gave me the points.

Anyway, yccheok, you can simply copy the body of this function and adapt it to your code...but give the points to Peter because his solution is more or less the same except that it won't allow you to place text arbitrarily inside the text area. But that's easily done as you can see.

Regards

Senkwe.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial is about how to put some of your C++ program's functionality into a standard DLL, and how to make working with the EXE and the DLL simple and seamless.   We'll be using Microsoft Visual Studio 2008 and we will cut out the noise; that i…
This article describes how to programmatically preset the "Pages per Sheet" option that's available with most printer drivers.   This setting lets you do "n-Up" printing, where two, four, or more pages are printed on each sheet of paper. If your …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

737 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question