- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I tried to add more than 10,000 lines to Edit Boxes in Dialog so that I could copy them to clipboard and save, if not all 10,000 lines can be saved, I perfer as much as possible final lines could be saved. How I can do it?
Please do me a favour.
I have tried the following codes, which listed in the boards before:
SUBROUTINE AppendEditText(Dlg, ID, sText)
TYPE(Dialog):: Dlg
INTEGER:: ID
CHARACTER(*):: sText
CHARACTER(LEN=LEN(sText)+1):: szText
INTEGER:: 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, 0, LOC(szText))
END SUBROUTINE AppendEditText
With this method, I could add multi-lines to EditBox, but after some lines, it will stop work.
Thanks in advance
Yao
xianyaochen@yahoo.com.cn
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Which operating system? Docs (vaguely) imply that the limit of text of edit controls on Windows 9x is 64 kB, while the limit on Windows 2000/XP is 2GB. It's not stated very explicitly though -- see e.g. EM_LIMITTEXT -- if the limit for manual entering is 64 kB, it's probably true as well for programatic entering of the text. (Also, I recall that early versions of Notepad had 64 kB limit, becauseit actuallyhosts a multiline edit control).
If you're on Win2000+, well, I'm not sure.
In any case, you could probably applysimilar SETSEL/REPLACESEL logic to delete the first couple of bytes when nLength is close to e.g. 60 kB. (If you need to delete one line at a time, return value from EM_GETLINE tells you how long a line is).
Jugoslav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The operating system is XP. I use sendmessage(hwndEdit, EM_LimitText, 0,0) to change the default limit of length of input character (30,000). But I donot think it is a good idea because it sound like I use maximum resource.
How I can output multilines like "cmd.exe" does, deleting first line when the output exceeds the specified number? Is the following procedure suitable and efficient?
At each time,
step 1, read all characters in EditBox,
step 2, truncate first line and add the new output lines at the end
step 3, select all, replace all using EM_ReplaceSEL
thanks,
Yao
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
integer:: i, ist, nlength character(10):: line character(100):: dummyinclude "resource.fd"do i=1,4000 nLength = DlgSendCtrlMessage(dlg, IDC_EDIT1, WM_GETTEXTLENGTH, 0, 0) !If length is too long, delete the first line: if (nLength.gt.29000) then !CVF Help is little outdated. MSDN says that the first word of buffer pointed !to by EM_GETLINE:wParam must contain length of the buffer on input: dummy(1:1)=transfer(int2(len(dummy)), "a") !Length of first line: nLength = DlgSendCtrlMessage(dlg, IDC_EDIT1, EM_GETLINE, 0, loc(dummy)) !Add 2 to nLength to select terminating char(13)//char(10) ist = DlgSendCtrlMessage(dlg, IDC_EDIT1, EM_SETSEL, 0, nLength+2) !Replace with empty string: ist = DlgSendCtrlMessage(dlg, IDC_EDIT1, EM_REPLACESEL, 0, loc(""C)) !New length nLength = DlgSendCtrlMessage(dlg, IDC_EDIT1, WM_GETTEXTLENGTH, 0, 0) end ifist = DlgSendCtrlMessage(dlg, IDC_EDIT1, EM_SETSEL, nLength, nLength) write(line,"(i6.6,a3)") i, char(13)//char(10)//char(0) ist = DlgSendCtrlMessage(dlg, IDC_EDIT1, EM_REPLACESEL, 0, loc(line)) end do
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yao
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
SUBROUTINE AppendEditText(Dlg, ID, sText, NewLine)
TYPE(Dialog):: Dlg
INTEGER:: ID
CHARACTER(*):: sText
integer :: nLength
logical :: NewLine
CHARACTER(LEN=LEN(sText)+1):: szText
INTEGER:: ist
character(len=2) :: dummy
szText=TRIM(sText)//CHAR(0)
nLength = DlgSendCtrlMessage(Dlg,ID, WM_GETTEXTLENGTH, 0 ,0)
if (nLength > 29000 .and. NewLine) then
dummy(1:1)=transfer(int2(len(dummy)), "a")
!Length of first line:
nLength = DlgSendCtrlMessage(Dlg, ID, EM_GETLINE, 0, loc(dummy))
!Add 2 to nLength to select terminating char(13)//char(10)
ist = DlgSendCtrlMessage(Dlg, ID, EM_SETSEL, 0, nLength+2)
!Replace with empty string:
ist = DlgSendCtrlMessage(Dlg, ID, EM_REPLACESEL, 0, loc(""C))
!New length
nLength = DlgSendCtrlMessage(Dlg, ID, WM_GETTEXTLENGTH, 0, 0)
end if
if (NewLine) then
nLengthLast = nLength
endif
ist = DlgSendCtrlMessage(Dlg, ID, EM_SETSEL, nLengthLast, nLength)
ist = DlgSendCtrlMessage(Dlg,ID, EM_REPLACESEL, 0, LOC(szText))
END SUBROUTINE AppendEditText
where nLengthLast is another parameter to remember the last length of the contents in EditBox
so that I could use this subroutine to add some output in the same line in EditBox and add some output in new line, which is determined by variable : NewLine. When using EM_GetLine,
wparam = 0 means topmost line of multiline EditBox, is there another parameter store the bottom-most line?
Thanks
Yao
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
See EM_GETLINECOUNT.
Jugoslav

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page