Solved

Multiline Text Area

Posted on 2001-09-13
4
518 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
  • 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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

In this article, I will show how to use the Ribbon IDs Tool Window to assign the built-in Office icons to a ribbon button.  This tool will help us to find the OfficeImageId that corresponds to our desired built-in Office icon. The tool is part of…
What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
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…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

773 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