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
Solved

Multiline Text Area

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone 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

Suggested Solutions

Title # Comments Views Activity
Table Size and Indexes in SQL Server 6 27
Best book to learn C++ 4 84
What .NET URL re-routing tool did I use? 2 75
Windows ICD FFU Issue 4 61
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…
After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
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…

861 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