LB Booster
« Long text input? »

Welcome Guest. Please Login or Register.
Apr 1st, 2018, 05:11am



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
We apologize Conforums does not have any export functions to migrate data.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

Thank you Conforums members.
Speed up Liberty BASIC programs by up to ten times!
Compile Liberty BASIC programs to compact, standalone executables!
Overcome many of Liberty BASIC's bugs and limitations!
LB Booster Resources
LB Booster documentation
LB Booster Home Page
LB Booster technical Wiki
Just BASIC forum
BBC BASIC Home Page
Liberty BASIC forum (the original)

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: Long text input?  (Read 946 times)
Monkfish
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 104
xx 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 » User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx 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.
User IP Logged

Monkfish
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 104
xx Re: Long text input?
« Reply #10 on: Feb 12th, 2015, 7:20pm »

Thanks for the pointers smiley
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 » User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »


This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls