Liberty BASIC Community Forum
« Input text at bottom of multiline textbox »

Welcome Guest. Please Login or Register.
Oct 23rd, 2017, 02:47am


Rules|Home|Help|Search|Recent Posts|Notification


« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: Input text at bottom of multiline textbox  (Read 462 times)
JohnnyD
Guru
ImageImageImageImageImage


member is offline

Avatar

"If something should, then it doesn't, isn't, can't, hasn't or won't"


Homepage PM

Gender: Male
Posts: 759
xx Input text at bottom of multiline textbox
« Thread started on: Jun 23rd, 2017, 05:13am »

Hi,

I have a textbox set up for multiline and text entry limited to the size of the box, entering text from the right:

stylebits #tim.tm,_ES_RIGHT or _ES_MULTILINE,_EM_SETLIMITTEXT,0,0

I want to make the text enter at the bottom of the textbox and scroll up as it wraps.

I'm sure there is a way but can't think right now.

Cheers,

John.
User IP Logged

Brandon Parker
Moderator
ImageImageImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 1115
xx Re: Input text at bottom of multiline textbox
« Reply #1 on: Jun 23rd, 2017, 07:52am »

Hi John,

Two things here:

1. The EM_SETLIMITTEXT should not be placed in the StyleBits as it is not a Style command; it is a Message. In order to send that properly you should use the SendMessage function after the window containing the control is open.

2. Vertical Alignment of text within a TextBox is not a common thing to do nor is it really supported in any traditional sense that I'm aware of.


Can you provide more information regarding what you want to do and why the text must come from the bottom up? I have a Multi-Line TextBox in my main program that receives input for events from the program (no user input). Basically every time it needs to posts the newest event at the top it first copies all of the information in the TextBox and then appends that to the new post after a CRLF, and then pastes the final product back to the TextBox. I you are just using the TextBox for program output then this might be an easier option for you.

Let us know exactly what you are after and why it needs to be that way and we can try and give you options.


{:0)

Brandon Parker
« Last Edit: Jun 23rd, 2017, 12:31pm by Brandon Parker » User IP Logged

Windows 7 Home Premium 64-bit Intel(R) Quad Core(TM) i5 CPU M 430 @ 2.27GHz 4GB DDR3 RAM
JohnnyD
Guru
ImageImageImageImageImage


member is offline

Avatar

"If something should, then it doesn't, isn't, can't, hasn't or won't"


Homepage PM

Gender: Male
Posts: 759
xx Re: Input text at bottom of multiline textbox
« Reply #2 on: Jun 23rd, 2017, 11:04am »

Hi Brandon,

1. I've used _EM_SETLIMITTEXT numerous times in stylebits and never had any issues with it. It works OK!

I am writing a time calculator that will convert years months days hours minutes & seconds to any format.

As its a calculator, it has buttons to enter the format along with "Year", "Month" and so on, e.g. 77Years 16Months 14 days etc.
There is no input directly into the textbox.

I want it to enter data from bottom right, then wrap up onto the next line. it can then be read from top down so it follows correctly as you read it.

John.
User IP Logged

Brandon Parker
Moderator
ImageImageImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 1115
xx Re: Input text at bottom of multiline textbox
« Reply #3 on: Jun 23rd, 2017, 12:31pm »

Hi John,
How are you then setting the number of bytes for the EM_SETLIMITTEXT message that is supposed to accompany it in the wParam of the SendMessage function? I'm curious now if you are doing something else afterwards or if it is just by chance doing what you want.

Also, do you have any images to share of the program you're working on? Pictures are priceless......

{:0)

Brandon Parker
« Last Edit: Jun 23rd, 2017, 7:47pm by Brandon Parker » User IP Logged

Windows 7 Home Premium 64-bit Intel(R) Quad Core(TM) i5 CPU M 430 @ 2.27GHz 4GB DDR3 RAM
Chris Iverson
Administrator
ImageImageImageImageImage


member is offline

Avatar

20% Cooler


Homepage PM

Gender: Male
Posts: 2282
xx Re: Input text at bottom of multiline textbox
« Reply #4 on: Jun 23rd, 2017, 4:46pm »

Not only is it being used in the STYLEBITS command, it's being used in the part of the command that's used to disable styles, not enable them.

Brandon's right; this is not setting the limit properly, because in order to enforce the limit, it has to know how many characters you want to allow in the box, and there's nowhere in a window style that lets you set that parameter. That's why it's a window message.

(You can also tell by the name. EM = Edit Message; ES = Edit Style)

All the STYLEBITS command is doing is turning off the style bits that correspond to the value 0xC5(the value of EM_SETLIMITTEXT), whatever those are for edit boxes.

EDIT: Going through the definitions of edit box styles, that's equivalent to turning off the styles ES_CENTER(0x01), ES_MULTILINE(0x04), ES_AUTOVSCROLL(0x40), and ES_AUTOHSCROLL(0x80).

Add those values together and you get 0xC5. (Adding the values together is what OR'ing together flags for styles does)

Due to the other flags you're setting at the same time, I'm guessing that turning those off doesn't affect what you intend to use the textbox for. I suspect the textbox would behave much the same way if you left out the EM_SETLIMITTEXT part of the stylebit, and if not, you could get the same as the current behavior by replacing it with (ES_AUTOVSCROLL or ES_AUTOHSCROLL).
« Last Edit: Jun 23rd, 2017, 4:56pm by Chris Iverson » User IP Logged

"Do you believe in destiny?" - Pyrrha Nikos, RWBY
"With what wish will your Soul Gem shine?" - Kyubey, Puella Magi Madoka Magica
JohnnyD
Guru
ImageImageImageImageImage


member is offline

Avatar

"If something should, then it doesn't, isn't, can't, hasn't or won't"


Homepage PM

Gender: Male
Posts: 759
xx Re: Input text at bottom of multiline textbox
« Reply #5 on: Jun 24th, 2017, 4:27pm »

Hi,

Code:
    nomainwin
    textbox #wl.1,5,5,48,22
    stylebits #wl.1,_ES_RIGHT,_EM_SETLIMITTEXT,0,0
    open "Window Limit" for window_nf as #wl
    #wl,"trapclose [quit]"
    #wl.1,"!font Courier 8"
    #wl.1,"!setfocus"
    wait

[quit]
    close #wl
    end
 


I have used this successfully in countless programs that I want to limit the length of text to the length of the textbox. I don't have to set the number of characters.

Anyway, steering the thread back on track, this is the code so far. Very far from finished. Still need some ideas for what I'm trying to achieve:

Code:
    nomainwin
    WindowWidth=216
    WindowHeight=340
    textbox #tim.tm,5,5,200,50
    stylebits #tim.tm,_ES_RIGHT OR _ES_READONLY or _ES_MULTILINE,_EM_SETLIMITTEXT,0,0
    button #tim.yr,"Year",[year],UL,5,65,40,40
    button #tim.dy,"Day",[day],UL,45,65,40,40
    button #tim.hr,"Hour",[hour],UL,85,65,40,40
    button #tim.mn,"Min",[minute],UL,125,65,40,40
    button #tim.sc,"Sec",[second],UL,165,65,40,40
    button #tim.pc,"%",[percent],UL,5,105,50,40
    button #tim.cv,"Convert",[convert],UL,55,105,50,40
    button #tim.bk,"Del",[del],UL,105,105,50,40
    button #tim.cl,"Clear",[clear],UL,155,105,50,40
    button #tim.7,"7",[7],UL,5,145,50,40
    button #tim.8,"8",[8],UL,55,145,50,40
    button #tim.9,"9",[9],UL,105,145,50,40
    button #tim.dv,"",[divide],UL,155,145,50,40
    button #tim.4,"4",[4],UL,5,185,50,40
    button #tim.5,"5",[5],UL,55,185,50,40
    button #tim.6,"6",[6],UL,105,185,50,40
    button #tim.mt,"X",[multiply],UL,155,185,50,40
    button #tim.1,"1",[1],UL,5,225,50,40
    button #tim.2,"2",[2],UL,55,225,50,40
    button #tim.3,"3",[3],UL,105,225,50,40
    button #tim.mi,"-",[minus],UL,155,225,50,40
    button #tim.0,"0",[0],UL,5,265,50,40
    button #tim.dp,".",[dp],UL,55,265,50,40
    button #tim.eq,"=",[equals],UL,105,265,50,40
    button #tim.pl,"+",[plus],UL,155,265,50,40
    open "Time Calculator" for window_nf as #tim
    #tim,"trapclose [quit]"
    #tim.tm,"!font Courier 8"
    wait

[0]
    t$="0"
    goto[dispsub]

[1]
    t$="1"
    goto[dispsub]

[2]
    t$="2"
    goto[dispsub]

[3]
    t$="3"
    goto[dispsub]

[4]
    t$="4"
    goto[dispsub]

[5]
    t$="5"
    goto[dispsub]

[6]
    t$="6"
    goto[dispsub]

[7]
    t$="7"
    goto[dispsub]

[8]
    t$="8"
    goto[dispsub]

[9]
    t$="9"
    goto[dispsub]

[dp]
    gosub[getdisp]
    t$=""
    if instr(tim$,".")=0 then t$="."
    goto[dispsub]

[plus]
    t$="+"
    goto[dispsub]

[minus]
    t$="-"
    goto[dispsub]

[multiply]
    t$="*"
    goto[dispsub]

[divide]
    t$="/"
    goto[dispsub]

[year]
    t$="yr "
    goto[addname]

[day]
    t$="day "
    goto[addname]

[hour]
    t$="hr "
    goto[addname]

[minute]
    t$="min "
    goto[addname]

[second]
    t$="sec "
    goto[addname]

[del]
    gosub[getdisp]
    t$=""
    tt$=right$(tim$,2)
    select case tt$
        case "r "
            sb=3
        case "y ","n ","c "
            sb=4
        case else
            sb=1
    end select
    tim$=left$(tim$,len(tim$)-sb)
    goto[dispsub2]

[clear]
    #tim.tm,""
    tim$=""
    wait

[addname]
    gosub[getdisp]
    tt$=right$(tim$,1)
    if (tt$=" ") or (tt$="") or (instr(tim$,t$))>0 then t$=""
    goto[dispsub2]

[dispsub]
    gosub[getdisp]

[dispsub2]
    tim$=tim$+t$
    #tim.tm,tim$
    wait

[getdisp]
    #tim.tm,"!contents? tim$"
    return

[quit]
    close #tim
    end
 


John.
User IP Logged

Chris Iverson
Administrator
ImageImageImageImageImage


member is offline

Avatar

20% Cooler


Homepage PM

Gender: Male
Posts: 2282
xx Re: Input text at bottom of multiline textbox
« Reply #6 on: Jun 26th, 2017, 5:17pm »

Interesting. Appears to be an effect of disabling ES_AUTOHSCROLL and ES_AUTOVSCROLL simultaneously.

(I do recommend being explicit about it, instead of using _EM_SETLIMITTEXT, since that's not what the EM_SETLIMITTEXT message is for, and in the future, you may be accidentally disabling something you want to keep.)

Code:
    nomainwin
    textbox #wl.1,5,5,48,22
    stylebits #wl.1,_ES_RIGHT,_ES_AUTOVSCROLL or _ES_AUTOHSCROLL,0,0
    open "Window Limit" for window_nf as #wl
    #wl,"trapclose [quit]"
    #wl.1,"!font Courier 8"
    #wl.1,"!setfocus"
    wait

[quit]
    close #wl
    end 



As to your actual question regarding basically a reverse-scrolling text area, that's an intriguing problem, and I'll have to think about that.
« Last Edit: Jun 26th, 2017, 5:18pm by Chris Iverson » User IP Logged

"Do you believe in destiny?" - Pyrrha Nikos, RWBY
"With what wish will your Soul Gem shine?" - Kyubey, Puella Magi Madoka Magica
JohnnyD
Guru
ImageImageImageImageImage


member is offline

Avatar

"If something should, then it doesn't, isn't, can't, hasn't or won't"


Homepage PM

Gender: Male
Posts: 759
xx Re: Input text at bottom of multiline textbox
« Reply #7 on: Jun 27th, 2017, 09:55am »

Hi Chris,

Yes, I get the point about the limit, but because I have generally used it in single line textboxes before, I thought nothing of the consequences as they wouldn't apply and the programs never fell over.

The example I gave in my first post still limits the text, but I found it's only if typing directly into the textbox, not in the way the program does it, which adds characters per button click, so it's not whet I want.

I guess I'll never need to limit the entry anyway, as calculations shouldn't get that big n lary anyway.

There's always starting with a box full of spaces and delete some as characters are added, watching for line wraps with long strings and keep tabs on the number of spaces to limit the text entry.

John.
User IP Logged

tsh73
Board Moderator

member is offline

Avatar

Anatoly (real name)


PM

Gender: Male
Posts: 1684
xx Re: Input text at bottom of multiline textbox
« Reply #8 on: Jun 27th, 2017, 2:45pm »

John,
Quote:
I want it to enter data from bottom right, then wrap up onto the next line. it can then be read from top down so it follows correctly as you read it.

so then you entering "77Years 16Months 14 days"
you want output to be roughly like this
(three frames, display consist of three lines)
Code:
-----------


    77Years
-----------

      77Yea
rs 16Months
-----------
         77
Years 16Mon
ths 14 days
-----------
 

?
Just to compare
Code:
-----------
77Years


-----------
77Years 16M
onths

-----------
77Years 16M
onths 14 da
ys
-----------
 

works "naturally" (except word wrap that is)
(you can have automatic word wrap with Statictext I believe)
User IP Logged

damned Dog in the Manger
JohnnyD
Guru
ImageImageImageImageImage


member is offline

Avatar

"If something should, then it doesn't, isn't, can't, hasn't or won't"


Homepage PM

Gender: Male
Posts: 759
xx Re: Input text at bottom of multiline textbox
« Reply #9 on: Jun 27th, 2017, 3:17pm »

Hi Anatoly,

Yes, that's what I'm looking to achieve. I will most likely abbreviate the names and have more than one part on the same line.

I've been working through the logic of the operands and they are fun.....

Still working out the ins and outs yet but getting there slowly.

John.
User IP Logged

tsh73
Board Moderator

member is offline

Avatar

Anatoly (real name)


PM

Gender: Male
Posts: 1684
xx Re: Input text at bottom of multiline textbox
« Reply #10 on: Jun 28th, 2017, 01:49am »

So if user should not write that text in texteditor, it could be wrapped quite easily
Code:
'   Form created with the help of Freeform-J v.261006
'   Generated on Jun 28, 2017 at 09:15:10

    nomainwin

    WindowWidth = 312
    WindowHeight = 215

    UpperLeftX=int((DisplayWidth-WindowWidth)/2)
    UpperLeftY=int((DisplayHeight-WindowHeight)/2)

    statictext #main.statictext1, "Long winded source string", 26, 16, 144, 20
    textbox #main.textbox2, 22, 36, 272, 25
    statictext #main.statictext3, "Wrapped text", 22, 76, 144, 20
    textbox #main.textbox5, 22, 101, 90, 60 '10 chars wide, 3 lines height
    button #main.button6, "Wrap text", [button6Click], UL, 166, 101, 122, 25
    button #main.button7, "Animate wrapping", [button7Click], UL, 146, 146, 142, 25
    open "untitled" for window as #main
    print #main, "trapclose [quit.main]"

    print #main, "font courier 10"

    #main.textbox2 "Long winded source string"
    '#main.textbox5 "!disable"
    'OR _ES_READONLY, so user could not change it

    wait

[quit.main]
    Close #main
    END


[button6Click]    'Perform action for the button named 'button6'
    #main.textbox2 "!contents? text$"
    call wrap text$ 
    wait


[button7Click]    'Perform action for the button named 'button7'
    #main.textbox2 "!contents? text$"
    timer 300, [nxt]
    i = 0
    wait

[nxt]
    i=i+1
    if i >len(text$) then timer 0: wait
    t$=left$(text$, i)
    call wrap t$ 
wait


sub wrap text$ 
'texteditor is 10x3 characters
    w = 10: h = 3
    text$=padl$(text$, w*h)
    for i = 0 to h-1
        res$=res$+mid$(text$, i*w+1,w)
        if i<h-1 then res$=res$+chr$(13)+chr$(10)
    next
    #main.textbox5 res$
end sub

function padr$(a$,n)
    padr$ = left$(a$+space$(n-len(a$)),n)
end function
function padl$(a$,n)
    padl$ = left$(space$(n-len(a$))+a$,n)
end function

 
User IP Logged

damned Dog in the Manger
Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

Rules|Home|Help|Search|Recent Posts|Notification

Donate $6.99 for 50,000 Ad-Free Pageviews!

| |

This forum powered for FREE by Conforums ©
Sign up for your own Free Message Board today!
Terms of Service | Privacy Policy | Conforums Support | Parental Controls