Board Logo
« Using many controls »

Welcome Guest. Please Login or Register.
Feb 25th, 2018, 7:56pm


Conforums Terms of Service | Membership Rules | Home | Search | Recent Posts | Notification | Format Your Message | Installation FAQ

Please use the forums Search feature before asking.
Please post code using the code box described in Format Your Messages.
This will keep indentation, separate it better form the message and prevent gibberish.
If the code is too long for one post or additional files are needed, upload a ZIP archive to the Just BASIC Files Archive Site.

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: Using many controls  (Read 1007 times)
JohnDavidson
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 4142
xx Using many controls
« Thread started on: Mar 23rd, 2007, 5:39pm »

Ever had a need for lots of controls on you GUI?
When I say 'lots' I'm not talking about a paltry forty or fifty... I'm talking hundreds, maybe thousands!

The bad news is that it can't be done.
Even if you had enough window space JB, and Windows, would not be able to handle the task.

The good news is that most JB controls are reusable.
In the code below, three textbox and three statictext controls are able to handle the input, and display, as many elements of an array as needed.

The code should be easy to modify to suit needs and the only restriction is that your app can not use more than 70 meg.
This limit includes space needed for your arrays.

I'm betting someone could figure out a way to add side scrolling and turn out a nifty little spreadsheet app.

John

Code:
'Released as public domain

    numberOfTextboxs=10
    dim textboxLabel$(numberOfTextboxs)
    dim textboxContent$(numberOfTextboxs)

'Build some dummy labels for the statictext controls.
    for x=1 to numberOfTextboxs
        a$=str$(x)
        while len(a$)<3
            a$="0";a$
        wend
        textboxLabel$(x)="Textbox label ";a$
    next

'Add a variable to control which elements of the array are displayed.
    controlIndex=1

    nomainwin

    WindowWidth = 392
    WindowHeight = 225

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

    statictext #1.st1, textboxLabel$(1), 22, 46, 100, 20
    statictext #1.st2, textboxLabel$(2), 22, 91, 100, 20
    statictext #1.st3, textboxLabel$(3), 22,132, 100, 20

    textbox #1.textbox1, 126, 40, 160, 25
    textbox #1.textbox2, 126, 85, 160, 25
    textbox #1.textbox3, 126,125, 160, 25

    button #1.b1, "up", [moveUpList],   UL, 318, 46, 26, 25
    button #1.b2, "dn", [moveDownList], UL, 318, 71, 26, 25

    open "" for window as #1
    print #1, "trapclose [quit.1]"
    print #1, "font MS_Sans_Serif 8"

    #1.b1,"!disable"
    #1.textbox1,"!setfocus"

wait

[quit.1]
    Close #1
    END


[moveUpList]
    if controlIndex=numberOfTextboxs-2 then #1.b2,"!enable"

'Get the contents for current array elements.
    #1.textbox1, "!contents? string1$"
    #1.textbox2, "!contents? string2$"
    #1.textbox3, "!contents? string3$"

'Update the array.
    textboxContent$(controlIndex)   = string1$
    textboxContent$(controlIndex+1) = string2$
    textboxContent$(controlIndex+2) = string3$

'Increment the array controller.
    controlIndex=controlIndex-1

'Prevent the user from going past the end of the list.
    if controlIndex=1 then #1.b1,"!disable"

'Update the display.
    #1.st1, textboxLabel$(controlIndex)
    #1.st2, textboxLabel$(controlIndex+1)
    #1.st3, textboxLabel$(controlIndex+2)

    #1.textbox1, textboxContent$(controlIndex)
    #1.textbox2, textboxContent$(controlIndex+1)
    #1.textbox3, textboxContent$(controlIndex+2)

    #1.textbox1,"!setfocus"
wait

[moveDownList]
    if controlIndex=1 then #1.b1,"!enable"

    #1.textbox1, "!contents? string1$"
    #1.textbox2, "!contents? string2$"
    #1.textbox3, "!contents? string3$"

    textboxContent$(controlIndex)   = string1$
    textboxContent$(controlIndex+1) = string2$
    textboxContent$(controlIndex+2) = string3$

    controlIndex=controlIndex+1
    if controlIndex=numberOfTextboxs-2 then #1.b2,"!disable"


    #1.st1, textboxLabel$(controlIndex)
    #1.st2, textboxLabel$(controlIndex+1)
    #1.st3, textboxLabel$(controlIndex+2)

    #1.textbox1, textboxContent$(controlIndex)
    #1.textbox2, textboxContent$(controlIndex+1)
    #1.textbox3, textboxContent$(controlIndex+2)

    #1.textbox3,"!setfocus"
wait 

User IP Logged

John Davidson
e-me: johnshomeport@yahoo.com
My JB Page: http://john.jbusers.com/
Did ya Libby yet? http://lblibby.com/
Stefan Pendl
Administrator
ImageImageImageImageImage


member is offline

Avatar

Let's talk JB ...


Homepage PM

Gender: Male
Posts: 3720
xx Re: Using many controls
« Reply #1 on: Mar 24th, 2007, 06:08am »

It is always a pleasure how a bright mind can get rid of most limitations of any tool grin
User IP Logged

Stefan - Homepage

Remember to read the forum rules board wink

Just BASIC 2.0 beta 2, Windows 10 Professional x64, Intel Core i7-4710MQ 2.5GHz, 16GB RAM
Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

Conforums Terms of Service | Membership Rules | Home | Search | Recent Posts | Notification | Format Your Message | Installation FAQ

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