Liberty BASIC Community Forum
« FAQ - frequently asked questions »

Welcome Guest. Please Login or Register.
Jan 22nd, 2018, 6:09pm


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


« Previous Topic | Next Topic »
Pages: 1 2 3  Notify Send Topic Print
 sticky  Author  Topic: FAQ - frequently asked questions  (Read 1837 times)
JohnDavidson
Moderator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM

Gender: Male
Posts: 2480
xx Re: FAQ - frequently asked questions
« Reply #15 on: Aug 31st, 2004, 7:48pm »

Can I have a button that is activated automatically when the user hits ENTER?

In windows other than dialog you will have to trap the key press.
Below is a demo that uses "GetAsyncKeyState" to accomplish this task.

A better method is to use WMLiberty.DLL
As Alex L. said "Watch out for a youth newsletter article about trapping messages in various LB controls in a future issue."

John

Code:
'Form created with the help of Freeform 3 v03-27-03
'Generated on Aug 31, 2004 at 17:02:43

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

   statictext #1.st1,"Enter your name and press the Enter key",25,5,100,30
   button #1.b1,"&Do it",[button.b1.Click],ul 230, 75, 75, 22
   textbox #1.txt, 25, 40, 280,  25

    open "Not Titled" for window as #1
    print #1, "font ms_sans_serif 8"
    print #1, "trapclose [quit.1]"
    timer 100,[checkKeyPress]
wait

[checkKeyPress]
    timer 0

    CallDLL #user32, "GetAsyncKeyState",_
                     _VK_RETURN as long,_
                     fKeyPress as long

    if fKeyPress <0 then [button.b1.Click]
    timer 100,[checkKeyPress]
wait

[button.b1.Click]
    timer 0
    print #1.txt,"!contents? text$"
    notice "Your name is: ";text$ 

    timer 100,[checkKeyPress]
wait
[quit.1]
    close #1
    end 


User IP Logged

John Davidson
e-me: johnshomeport@yahoo.com
Comming Soon: http://johnshomeport.com
Did ya Libby yet? http://lblibby.com/



Alyce Watson
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM

Gender: Female
Posts: 14918
xx Re: FAQ - frequently asked questions
« Reply #16 on: Sep 1st, 2004, 07:01am »

Isn't anyone else going to suggest questions? The following questions come up frequently:

Can I print hard copies that include text and graphics on the same page?

When I try to run my program, I get an "index out of bounds" error message. What's wrong?

Why won't the "titlebar" command change the caption on my gui window?

Can I change the background color of textboxes, so that each has a different color?

Can I change the text color on statictext (or other) controls so that each has a different color?

How can I remove the border of a graphicbox?

Why can't I remove the scrollbars from a texteditor with the scrollbar commands?

Why won't my texteditor work with many API calls?

I've tried using SetWindowTextA to change the caption of a graphics window, but it won't work. Why?
« Last Edit: Sep 1st, 2004, 07:09am by Alyce Watson » User IP Logged

Alyce
Liberty BASIC Workshop - a complete IDE for Liberty BASIC


Alyce's Restaurant
for Liberty BASIC code, tools and references
Colin McMurchie
Full Member
ImageImageImage


member is offline

Avatar




PM


Posts: 226
xx Re: FAQ - frequently asked questions
« Reply #17 on: Sep 1st, 2004, 11:13am »

When I try to run my program, I get an "index out of bounds" error message. What's wrong?


You are trying to use an array element that is outside the range of available elements. For example, if you have the following line in your programme. -

dim XNum(100)

and later, a line like

YNum= XNum(101)
or
ZNum = 102
YNum = XNum(ZNum)

you have tried to go beyond the bound of your array. The last case, where the 'array subscript' is itself a variable, is the most difficult to discover.

Remember also that arrays have 11 elements (0 to 10) by default, so if you have forgotten to dimention your array, you get an error if you attempt element 11 or above.

My programme fails to compile, with a message like "syntax error on line 1". Line 1 looks OK to me. What is happening?

This usually occurs when the programme compiler in LB reaches the last line of programme code, and finds some sort of error it cannot specify. The problem is usually one of programme flow. Look for unbalanced 'if..then..else..endif' constructions, 'select..end select' statements, improper constructions of subs, gosubs and function routines, and the lack of an 'end' statement to terminate the main programme.



User IP Logged

David Conner
Guru
ImageImageImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 549
xx Re: FAQ - frequently asked questions
« Reply #18 on: Sep 1st, 2004, 3:30pm »

Why won't my texteditor work with many API calls?

A texteditor is a special widget of LB. It will not work with many API calls.
« Last Edit: Sep 1st, 2004, 4:20pm by Alyce Watson » User IP Logged

--David
Alyce Watson
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM

Gender: Female
Posts: 14918
xx Re: FAQ - frequently asked questions
« Reply #19 on: Sep 3rd, 2004, 09:54am »

Look at the message in this thread above, posted by yours truly. There are a bunch of questions there that need answers. Any takers? Or, feel free to add your own Q & A.
User IP Logged

Alyce
Liberty BASIC Workshop - a complete IDE for Liberty BASIC


Alyce's Restaurant
for Liberty BASIC code, tools and references
David Conner
Guru
ImageImageImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 549
xx Re: FAQ - frequently asked questions
« Reply #20 on: Sep 3rd, 2004, 2:17pm »

Why won't the 'titlebar' command change the caption of my GUI?

The 'titlebar' command only changes the caption of the mainwindow. To change the caption of a GUI window, get the Windows handle, and call SetWindowText.

Code:
Nomainwin
Open "Window" for window as #1
#1 "Trapclose [quit]"
hWnd=hwnd(#1)
Timer 2000, [change]
wait

[quit]
Close #1: End

[change]
Timer 0
txt$="Changed!"
CallDLL #user32, "SetWindowTextA",_
hWnd as long, txt$ as ptr, ret as void
wait 


Edit to change "To change the handle of a GUI" to "To change the caption of a GUI window"

Added link to article explaining this techinique:
http://babek.info/libertybasicfiles/lbnews/nl122/api.htm
« Last Edit: Sep 7th, 2004, 05:33am by Alyce Watson » User IP Logged

--David
kcmonkeyman
New Member
Image


member is offline

Avatar




PM


Posts: 0
xx Re: FAQ - frequently asked questions
« Reply #21 on: Sep 3rd, 2004, 2:55pm »

Can I change the background color of textboxes, so that each has a different color?


Yes But Not With Native Lb Commands You Need To Do So With Api Calls...

Edit to add:
You can do this by issuing a TextboxColor$ command before each command to create a textbox. Only one text color is possible, and it is set using ForegroundColor$. Sample:
Code:
nomainwin
ForegroundColor$="yellow"

TextboxColor$="red"
textbox #1.1, 10,10,100,30
TextboxColor$="green"
textbox #1.2, 10,50,100,30
TextboxColor$="blue"
textbox #1.3, 10,90,100,30

open "Textboxes in Colors" for window as #1
#1 "trapclose [quit]"
#1 "font arial 16"
#1.1 "Red"
#1.2 "Green"
#1.3 "Blue"

wait
[quit] close #1:end
 
« Last Edit: Sep 3rd, 2004, 3:01pm by Alyce Watson » User IP Logged

Alex L.
Guru
ImageImageImageImageImage


member is offline

Avatar




PM


Posts: 1384
xx Re: FAQ - frequently asked questions
« Reply #22 on: Sep 3rd, 2004, 5:19pm »

Why can't I use the method that David mentioned for Graphics Windows and Text Windows?

The handle of a graphics window or text window is actually the handle to teh texteditor or graphicbox that fills the window.

Quote:
Edit to add:
One must use the GetParent API call on graphics windows and text windows and use the handle returned by the function in API calls to manipulate the window itself. The hwnd() of the graphics window is used when sending graphics API commands to the window, such as GetDC, BitBlt, etc.

For an article the explains how to change the caption on any window, go here:
http://babek.info/libertybasicfiles/lbnews/nl122/api.htm

« Last Edit: Sep 7th, 2004, 05:36am by Alyce Watson » User IP Logged

Ken Harding
Junior Member
ImageImage


member is offline

Avatar

Have a lot of fun


Homepage PM

Gender: Male
Posts: 68
xx Re: FAQ - frequently asked questions
« Reply #23 on: Sep 7th, 2004, 02:56am »

1) How would I find out what the current time plus x minutes is?

2) How would I find out that the current date plus x days is?
User IP Logged

David Conner
Guru
ImageImageImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 549
xx Re: FAQ - frequently asked questions
« Reply #24 on: Sep 9th, 2004, 3:14pm »

I've used the SetWindowTextA call for Graphics and Text windows, but it won't work. Why?

When you retrieve the handle of a graphics or text window, it actually retrieves the handle to the graphicbox or texteditor that is in the window. To modify the window, first get the parent handle, and then make any calls that you were going to make.

To get the parent:
Code:
CallDLL #user32, "GetParent", hWnd as long, hParent as long 


How can I remove the border of a graphicbox?
This code works only for LB 4 or higher!

You modify the graphicbox with the stylebits command, removing the _WS_BORDER style.

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

Stylebits #1.g, 0, _WS_BORDER, 0, 0
Graphicbox #1.g, 10, 10, 100, 100
Open "Graphicbox w/ no Borders" for window as #1
#1 "Trapclose [quit]"
#1.g "down;place 10 10"
#1.g "/No/Border!"
wait

[quit]
Close #1:End 
User IP Logged

--David
PoseidonScript
Full Member
ImageImageImage


member is offline

Avatar

Leader of the Space Pirates

ICQ
Homepage PM

Gender: Male
Posts: 106
xx Re: FAQ - frequently asked questions
« Reply #25 on: Sep 10th, 2004, 1:19pm »

What is the best Source Code Editor for Liberty BASIC?

It is a matter of preference and does not really matter which editor you use weither you use LBs' built in source code editor or another external editor. However many people prefer using external editors like Liberty BASIC Workshop(http://alycesrestaurant.com/workshop.htm) or JaLbE(Just Another Liberty BASIC Editor, don't know url) for larger or commercial type projects.

What is the best GUI Editor for Liberty BASIC?

As stated above it is a matter a preference and done not matter. Some like to use LBs' Freeform while users with larger and commercial type projects use Liberty BASIC Workshop(http://alycesrestaurant.com/workshop.htm or even Liberty BASIC Quick Visual Designer(http://www.download.com/LB-Quick-Visual-Designer/3000-2383-10299735.html?tag=lst-0-2)

I would like to use Liberty BASIC to create my own games, where do i start?

Fior starters you can read the LB tutorials. Also you can try using Liberty BASIC Game Workshop(http://alycesrestaurant.com/game.htm) to create a couple of simple games. If you need any help along the way you can visit the Game Programming section of this forum(http://libertybasic.conforums.com/index.cgi?board=game).
« Last Edit: Sep 10th, 2004, 1:20pm by PoseidonScript » User IP Logged

PoseidonScript written in Liberty Basic
Alex L.
Guru
ImageImageImageImageImage


member is offline

Avatar




PM


Posts: 1384
xx Re: FAQ - frequently asked questions
« Reply #26 on: Sep 10th, 2004, 4:51pm »

Hey Ken! Sorry, but I couldn't help noticing that your examples don't put filenames into strings, but instead leave them with no quotation marks. Because the syntax is NAME a$ as b$, you need strings.
User IP Logged

kaalidor
Team Liberty BASIC


member is offline

Avatar



ICQ
Homepage PM

Gender: Male
Posts: 458
xx Re: FAQ - frequently asked questions
« Reply #27 on: Sep 10th, 2004, 6:33pm »

on Sep 10th, 2004, 1:19pm, Dark Mars Software wrote:
What is the best Source Code Editor for Liberty BASIC?

It is a matter of preference and does not really matter which editor you use weither you use LBs' built in source code editor or another external editor. However many people prefer using external editors like Liberty BASIC Workshop(http://alycesrestaurant.com/workshop.htm) or JaLbE(Just Another Liberty BASIC Editor, don't know url) for larger or commercial type projects.


you can find JaLBe here:

http://syberden.net/libertybelle/
User IP Logged

Have a look to LBasicFr (LB for French Users).
Stefan Pendl
Global Moderator
ImageImageImageImageImage


member is offline

Avatar

Computers are like babies, you must teach them what you like them to do ...


Homepage PM

Gender: Male
Posts: 5303
thumbup Re: FAQ - frequently asked questions
« Reply #28 on: Sep 11th, 2004, 12:57pm »

on Sep 7th, 2004, 02:56am, Ken Harding wrote:
1) How would I find out what the current time plus x minutes is?

2) How would I find out that the current date plus x days is?

Here is an example Code:
' get the date for a day in the past or in the future
' get the time for a moment in the past or in the future

    print "In 2 days we have "; GetDate$(2)
    print "We past "; GetDate$(-6); " 6 days before"

    print "It is "; GetTime$(45); " in 45 minutes"
    print "It was "; GetTime$(-60); ", 60 minutes ago"
end

function GetDate$(Offset)
' Offset must be days

    tofind = date$("days") + Offset
    GetDate$ = date$(tofind)
end function

function GetTime$(Offset)
' Offset must be minutes

    now$ = time$()
    Hour = val(word$(now$,1,":"))
    Minute = val(word$(now$,2,":")) + Offset
    Second = val(word$(now$,3,":"))
    if Minute > 59 then
        Minute = Minute - 60
        Hour = Hour + 1
    end if
    if Minute < 0 then
        Minute = Minute + 60
        Hour = Hour - 1
    end if
    GetTime$ = Hour; ":"; Minute; ":"; Second
end function
 
« Last Edit: Sep 11th, 2004, 1:01pm by Stefan Pendl » User IP Logged

Stefan

Make sure to read and follow the Forum Guidelines

Liberty BASIC Pro 4.04, Windows 10 Professional x64, Intel Core i7-4710MQ 2.5GHz, 16GB RAM
Mark
Full Member
ImageImageImage


member is offline

Avatar

Failing to prepare is preparing to fail. Trust me, it's happened before.


Homepage PM

Gender: Male
Posts: 205
xx Re: FAQ - frequently asked questions
« Reply #29 on: Jul 22nd, 2008, 4:53pm »

How do I make a window Fullscreen?

The following code:
Code:
nomainwin

WindowWidth=DisplayWidth
WindowHeight=DisplayHeight

open "Window" for window as #handle
'your code here
 


Also, If you want a fullscreen graphics window without the things at the top to close the window and all that, you may also try this code:

Code:
nomainwin

WindowWidth=DisplayWidth
WindowHeight=DisplayHeight

graphicbox #1.g, 0, 0, WindowWidth, WindowHeight

open "Graphic window" for window_popup as #1
'your code to #1.g here
 
User IP Logged

Visit my website at http://cabsvill.weebly.com.
Also see my photo album: http://www.iExploreChina.com.
Pages: 1 2 3  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