Author |
Topic: Long text input? (Read 946 times) |
|
Monkfish
Full Member
member is offline


Gender: 
Posts: 104
|
 |
Re: Long text input?
« Reply #8 on: Feb 12th, 2015, 11:06am » |
|
I took your advice Richard and made a text box. The code below works fine but I was looking for a way to position the cursor at the end of the text in the box instead of the beginning. Just putting a semi-colon at the end of the printed sampletext$; didn't seem to work. So I thought I would use the !lines control to get the number of lines of text, then the !line control to get the last line and from that its length, and finally the !select control to position the cursor. But the program objects to the four commented out lines in the following code.
text$="" WindowWidth=400 WindowHeight=200 UpperLeftX=int((DisplayWidth-WindowWidth)/2) UpperLeftY=int((DisplayHeight-WindowHeight)/2) textbox #main.tbx, 10, 10, 330, 150 stylebits #main.tbx, _WS_VSCROLL OR _ES_MULTILINE, _ES_AUTOHSCROLL, 0, 0 button #main, " OK ", [accept], UL, 345, 72 open "Edit the text and then press OK" for Dialog as #main print #main, "trapclose [ignore]" print #main, "font courier_new 12 bold" print #main.tbx, sampletext$ ' print #main.tbx, "!lines r" ' print #main.tbx, "!line ";r;" l$" ' c=len(l$) ' print #main.tbx, "!select ";c;" ";r wait
[accept] flg=1 print #main.tbx, "!contents? text$" close #main end
[ignore] flg=0 close #main end
|
| « Last Edit: Feb 12th, 2015, 7:30pm by Monkfish » |
Logged
|
|
|
|
Richard Russell
Administrator
member is offline


Posts: 1348
|
 |
Re: Long text input?
« Reply #9 on: Feb 12th, 2015, 1:02pm » |
|
on Feb 12th, 2015, 11:06am, Monkfish wrote:| But the program objects to the four commented out lines in the following code. |
|
What program? LB 4.04 objects to those commands, because they are TEXTEDITOR commands, not TEXTBOX commands. But LBB doesn't complain - it just ignores them (in general LBB doesn't report an error if a command is inappropriate for the control type to which it is sent).
Could you use a TEXTEDITOR control (LBB is happy for one to be used in a DIALOG window)? Failing that, there's code at one of the LB support sites for using a Windows API call to position the caret in a TEXTBOX.
Richard.
|
|
Logged
|
|
|
|
Monkfish
Full Member
member is offline


Gender: 
Posts: 104
|
 |
Re: Long text input?
« Reply #10 on: Feb 12th, 2015, 7:20pm » |
|
Thanks for the pointers  This now seems to work...
text$="" WindowWidth=400 WindowHeight=200 UpperLeftX=int((DisplayWidth-WindowWidth)/2) UpperLeftY=int((DisplayHeight-WindowHeight)/2) textbox #main.tbx, 10, 10, 330, 150 stylebits #main.tbx, _WS_VSCROLL OR _ES_MULTILINE, _ES_AUTOHSCROLL, 0, 0 button #main, " OK ", [accept], UL, 345, 72 open "Edit the text and then press OK" for Dialog as #main print #main, "trapclose [ignore]" print #main, "font courier_new 12 bold" print #main.tbx, sampletext$ pos=len(sampletext$) hTextbox=hWnd(#main.tbx) CallDLL #user32, "SendMessageA", hTextbox as Ulong, _EM_SETSEL as Long, pos as Long, pos as Long, result as Long wait
[accept] flg=1 print #main.tbx, "!contents? text$" close #main end
[ignore] flg=0 close #main end
|
| « Last Edit: Feb 12th, 2015, 7:34pm by Monkfish » |
Logged
|
|
|
|
|