Software Archive
Read-only legacy content
17061 Discussions

How to append text in a EDIT box

Intel_C_Intel
Employee
376 Views
Hi,

I want to use dialogs in my program. A EDIT box is used as
output box. However, I will not write out results at once;
but at different time. If I use DLGSET to update the text in the EDIT box, I must store all
the texts in a long string "text", then DLGSET(dlg,DC_EDIT,text).
This is not a good way. If it is possible to just append text
to the edit box without update whole texts?

BTW, the reason why I use EDIT box is that I can copy out
whole (or part of) texts using CTRL+C.

Many thanks

Min
0 Kudos
3 Replies
Jugoslav_Dujic
Valued Contributor II
376 Views
Here's a subroutine that should do the trick:

 
SUBROUTINE AppendEditText(Dlg, ID, sText) 
USE DFWIN 
USE DFLOGM 
 
TYPE(Dialog):: Dlg 
INTEGER::     ID 
CHARACTER(*):: sText 
 
CHARACTER(LEN=LEN(sText)+1):: szText 
INTEGER::  nLength, hwndEdit, i 
 
hwndEdit = GetDlgItem(Dlg%hWnd, ID) 
szText=TRIM(sText)//CHAR(0) 
nLength = SendMessage ( hwndEdit, WM_GETTEXTLENGTH, 0, 0 )  
i = SendMessage ( hwndEdit, EM_SETSEL, nLength, nLength ) 
i = SendMessage ( hwndEdit, EM_REPLACESEL, .FALSE., LOC(szText)) 
 
END SUBROUTINE AppendEditText 


Few notes:

- This will work only from a callback function or if the dialog is modeless. Before DlgModal, you have to use DlgSet.

- This workarounds DFLOGM processing, so I think you won't be able to retrieve the text using DlgGet. If it's used for output only, that probably doesn't matter.

- It's recommended to check "Multi-line" style on control's property sheet. Note that you can send a newline as CHAR(13)//CHAR(10).

HTH

Jugoslav
0 Kudos
Jugoslav_Dujic
Valued Contributor II
376 Views
[sigh] Forum software... last two lines of code should be:

 
 i = SendMessage ( hwndEdit, EM_SETSEL, nLength, nLength) 
 i = SendMessage ( hwndEdit, EM_REPLACESEL, 0, LOC(szText)) 
0 Kudos
Intel_C_Intel
Employee
376 Views
Hi, Jugoslav

Many thanks for your help.
Actually, I will use the EDIT box only for output. It doesn't matter
that I can not use dlgget to obtain the texts.

Min
0 Kudos
Reply