
-----------------------------------------------------------------------------
            
            The Liberty BASIC Newsletter - Issue #88 - April 2001
               "Keeping you up to date with the LB community!"

                    (c) 2001 The Liberty BASIC Community 
                        Published by: Brandon Watts

-----------------------------------------------------------------------------

In This Issue:

- Liberty BASIC News
- Programmer Spotlight: Philip Richmond
- A primer on richedit syntax coloring for Liberty BASIC - By Dennis McKinney
- Internet Coding Tutorial
- Access Windows Features
- Technical Corner
- LB Program of the Month
- LB Website of the Month
- Snippets

-----------------------------------------------------------------------------

Liberty BASIC News


This month has been another great month for Liberty BASIC!

The book, "Beginning Programming For Dummies 2nd Edition" was released this 
month! This book provides a solid introduction and tutorial for beginners of
Liberty BASIC. It also includes a CD full of programming goodies. Be sure to
pick up your own personal copy.

We are still waiting for more details about Liberty BASIC Con 2001. This 
should prove to be a great event for all LB programmers!

Liberty BASIC v2.02 should be making it's debut soon. Everyone is very
excited to get their hands on this new version of LB!

I would also like to mention that this is the Liberty BASIC Newsletter's 
third anniversary! That's right, it's been published since April 1998.
Whenever you have a question or you want more information about a certain
topic, check the older newsletters. There is an abundance of information in 
them.

Long Live Liberty BASIC!

Brandon Watts
brandonwatts@ga.prestige.net
http://www.tegdesign.com/lboutpost/lbnews

-----------------------------------------------------------------------------

Programmer Spotlight: Philip Richmond


Philip Richmond is a very kind and talented member of the LB group. He has 
created CAT, one of the best text adventure game creators out there! Philip 
is also very helpful.

His website address is:

http://www.richmond62.freeserve.co.uk/

His e-mail address is:

philip@richmond62.freeserve.co.uk


Q. How did you find Liberty BASIC?

I originally discovered LB on a magazine coverdisk compilation CD in August
1998 soon after acquiring my first PC. Had a quick look at this early
version and remember being rather impressed. A few months later I had
decided that I wanted to rewrite an Amiga program of mine for the PC and set
about looking for a suitable easy to use programming language. It was then
that I recalled looking at LB, dug out the CD again, read the supplied text
file which directed me to the LB website where I eagerly downloaded the
(then) latest version 1.42. I had some great fun learning Liberty, running
the example demos and trying out the various LB commands. I joined the LB
community soon after and eventually registered my copy of LB.

Q. Why do you use Liberty BASIC?

As a novice/hobbiest programmer, I had messed about a bit with BASIC on the
Sinclair ZX Spectrum in the mid 80`s and tried my hand with AmigaBasic and
AMOS Basic on the Amiga 500/1200 machines in the 90`s. Being new and a
little unfamiliar with the PC, I had no experience of using C or Visual
Basic and thought them a little complicated. I found my previous BASIC
knowledge served me well and was applicable in helping me to understand LB,
which I found to be easy to use and extremely powerful. It was still being
actively developed, had a growing user base and a user help support group.
After studying Liberty and its capabilities for a while I realised that I
would be able to convert the program I wanted to using it.

Q. What do you think LB's best feature is?

I like the fact that LB is only a 'small' download. I like the way it is so
simple to code opening a window in just one line. Best feature: Well, I
would say Versatility. You can use it to write all sorts of different
programs, games and utilities. The only real limit is your imagination. Carl
has provided an excellent tool for us to write the program of our dreams and
I look forward to the 32bit LB3!

Q. What are some programs that you have made in LB?

I have sent a few snippets to the newsgroup, but my one and only full
program is the 'Creative Adventure Toolkit' text adventure engine. There are
some adventure games written with CAT available for download from my site
which readers might like to have a play with:
http://www.richmond62.freeserve.co.uk/index.htm

Q. What do you enjoy doing in your free time?

Besides my current home computer interests, I enjoy reading fiction and
non-fiction, keep fit activities, watching X-Files and the occasional night
out with friends.

Q. How old are you?

I am 47 years old.

Q. Where are you from?

I am from the seaside holiday resort of Blackpool, Lancashire in NW England
and that is where I currently reside.

-----------------------------------------------------------------------------

A primer on richedit syntax coloring for Liberty BASIC. By Dennis McKinney

    Now that some progress has been made using a richedit control in Liberty 
Basic we have some interesting possibilities regarding its use. One 
possibility is a BASIC editor with syntax coloring. This is easily done with 
a richedit control, but it does have it's drawbacks. The main one is the 
current inability to save the file in rich text format. Until this is 
overcome each file needs to be colored every time it is loaded and this is a 
slow process. Then there is the 64K limit with the riched control itself. The
control will accept larger amounts of text but some of the parameters in the 
api calls that are used for coloring, selecting text, copying, and pasting 
will not accept values greater than 65535. The good news is this only applies
to the 16 bit rich edit. The 32 bit richedit controls aren't hampered by 
these limitatations. Why bother with a 16 bit richedit? LB will soon be 32 
bit and most of what we learn now can be directly applied to the 32 bit 
richedit controls!  

    Now that all this is out of the way let's discuss the process itself. 
Since the richedit editor is an API created control, every action to use it 
must be done through the API too. I'll assume you already have the basic 
program with the riched editor, the necessary CHARFORMAT structure and have 
opened user.dll for #user before running this code. The first thing you need 
to decide is when to do the syntax coloring. You could color every word as 
you go but that is difficult to do properly and quickly. An easier way to do 
it is to color the entire line after it's finished. To do this you need to 
detect when the caret is placed on another line by either a keystroke or 
mouse click. This can be accomplished by constantly monitoring the line 
number the caret is in. Use a timer to execute a routine for this every 50 to
100 ms. I should mention at this point that several API calls may be required
to retrieve the information you need. Here is a routine to detect line 
changes in a richedit and to set it up for coloring if the line has changed. 
All of the API calls used have been wrapped into functions since they may be 
called many times from different routines.

[ScanLine]
    ret = Timer1(False) 'turn the timer off

    'get the caret position from the start of the document
    lchar = GetCharPos(hRichEd) 'hRichEd is the handle of the richedit control
 
    TxtSelPos = lchar 'save the current caret position

    ' get the current line number, using the caret position as a parameter
    LineNum  = LineFromChar(hRichEd, lchar) 

    If LineNum <> prevLine Then 'caret is on a different line
        'The next 2 calls will hide the highlighting we'll be doing
        'when the text is colored.
        ret = HideCaret(hRichEd) 'hide the caret
        ret = HideSelection(hRichEd,True) 'keep text selecting from showing

        'get the character index of the first character of the previous line
        oldfirstChar = LineIndex(hRichEd, prevLine)

        'set caret to the previous line, that's the one to color
        ret = PosCaret(hRichEd,oldfirstChar)

        prevLine = LineNum ' store this for the next time

        Gosub [ColorTxt] 'do the syntax coloring

        ret = PosCaret(hRichEd,TxtSelPos)'put the caret back where it belongs
        ret = HideSelection(hRichEd,False)'allow text selecting to show
        ret = ShowCaret(hRichEd) ' make the caret visible again
    End If
    ret = Timer1(True)
    Goto [loop]

Here are the API calls in functions along with the related functions that were called from [ScanLine]. You can see how wrapping the api calls into functions really streamlines the above routine.

Function Timer1(on)
    If Not(on) Then Timer 0
    If on Then Timer 100, [ScanLine]
End Function

Function GetCharPos(hEd)
    'get current character position from start of document
    'or start of selected text.
    calldll #user,  "SendMessage", hEd as word, _EM_GETSEL as word,_
    0 as word, 0 as long, Ret as long
    GetCharPos = LoWord(Ret)
End Function

Function LoWord(dword)
    hiword = int(dword / (256*256))
    LoWord = dword - (hiword*256*256)
End Function

Function LineFromChar(hEd, char)
    'get line number from character
    calldll #user,  "SendMessage", hEd as word,_
    _EM_LINEFROMCHAR as word, char as word,_
    0 as long, firstline as long
    LineFromChar=firstline
End Function

Function HideCaret(hndl)
    calldll #user, "HideCaret", hndl as word, Ret as void
End Function

Function HideSelection(hEd,bHide)
    'bHide: 1 or 0 (true or false)
    calldll #user, "SendMessage", hEd as word, 1087 as word, _
    bHide as word, 0 as long, ret as void
End Function

Function LineIndex(hEd,LineNum)
    'gets character index of first char in line LineNum
    calldll #user,  "SendMessage", hEd as word, _EM_LINEINDEX as word,_
    LineNum as word, 0 as long, firstChar as long
    LineIndex=firstChar
End Function

Function PosCaret(hEd,pos)
    'position the caret at pos
    If pos > 65535 Then pos = 65535 'max
    pos = MakeLong(pos,pos)
    calldll #user,  "SendMessage", hEd as word, _EM_SETSEL as word,_
    0 as word, pos as long, Ret as void
End Function

Function MakeLong(loword,hiword)
    'maybe this should be MakeDword instead?
    MakeLong = loword + ((256^2) * hiword)
End Function

Function ShowCaret(hndl)
    calldll #user, "ShowCaret", hndl as word, Ret as void
End Function


Now we're ready for the good stuff. Here is a routine for syntax coloring. 
You can set up to color whatever words or groups of words you want. Just be 
aware that the more you do, the longer it takes.
This routine colors branch labels, comments, text contained in quotes, and 
keywords. It's heavily commented for this article.

    'A few keywords. This would be initialized at the start of the program
    Keyword$ = "|SUB|FUNCTION|END|IF|THEN|AS|LONG|SHORT|STRUCT|GOSUB|GOTO|" + _
    "OR|CALLDLL|NOTICE|ELSE|PRINT|RETURN|OPEN|FOR|"

[ColorTxt]
    'get line information for the line to color
    lchar = GetCharPos(hRichEd)
    LineNum = LineFromChar(hRichEd, lchar)
    firstChar = LineIndex(hRichEd, LineNum)
    LineLen = LineLength(hRichEd, lchar)

    lastChar = firstChar + LineLen

    'copy the line's text to a buffer
    Buffer$ = GetLine$(hRichEd, LineNum)

    TempBuffer$ = ""  'we'll need this to build words in

    StopPos = LineLen + 1

    'examine each character in the line from beginning to end
    For i =  1 To StopPos
        char = Asc(Mid$(Buffer$, i, 1))

        If char = 91 Then '[ branch label
            'find the end of the branch label
            brEnd = InStr(Buffer$, "]", (i + 1))
            If brEnd <> 0 Then
                'select the branch label text
                ret = SetSel(hRichEd,(firstChar+(i-1)),(firstChar+brEnd))
                WordClr = ColorBranches 'this is an RGB color
                Gosub [ColorWord] 'color the word
                'move the loop counter to the end of the text we just colored
                i = brEnd 
                charUsed = True 'flag to determine if we want to skip keyword coloring
            End If
        End If

        'this uses the same technique
        If char = 34 Then 'quotation mark
            qEnd = InStr(Buffer$, chr$(34), (i + 1))
            If qEnd <> 0 Then
		'select the quoted text
                ret = SetSel(hRichEd,(firstChar+(i-1)),(firstChar+qEnd))
                WordClr = ColorQuotes
                Gosub [ColorWord]
                i = qEnd
            End If
            charUsed = True
        End If

        'slightly different technique here
        If char = 39 Then 'Comment
            'empty the TempBuffer
            TempBuffer$ = ""
            'select all of the remaining text
            ret = SetSel(hRichEd,(firstChar+(i-1)),lastChar)
            WordClr = ColorComments
            Gosub [ColorWord]
            i = StopPos 'we are done with this line. exit the loop.
            charUsed = True
        End If

        If Not(CharUsed) Then 'build a word for possible coloring.
            'test for the characters that can make keywords
            If (char >= 97 and char <= 122) or (char >= 65 and char <= 90)_
                or char = 95 or char = 46 or char = 36 Then
                'valid char, add to tmp buffer
                TempBuffer$ = TempBuffer$ + Mid$(Buffer$, i, 1)
                charUsed = True
            End If

            'If the character hasn't been used then it's a space or line feed etc.
            If Not(charUsed) Then
                'if the word we built in TempBuffer$ matches a keyword
                'color the word in the line
                If Trim$(TempBuffer$) <> "" Then
                    TempBuffer$ = Upper$(TempBuffer$)
                    If InStr(Keyword$,("|" + TempBuffer$ + "|")) <> 0 Then
                        SelStart = (firstChar+i)-(Len(TempBuffer$))-1
                        ret = SetSel(hRichEd,SelStart,firstChar+i)
                        WordClr = ColorKeywords
                        Gosub [ColorWord]
                    End If
                End If
                TempBuffer$ = "" 'reset for next word
            End If
        End If
        charUsed = False 'reset for next character
    Next i
    Return

The same basic method is used for every different section of text or word 
that is colored. The text is identified, then selected just like you do for 
copying, then the selected text is colored. This routine examines every 
character in the line until it finds a character that triggers coloring. It 
is very likely that this process could be speeded up. That's a hint folks. 
Here are the new functions that were called from [ColorTxt].

Function LineLength(hEd, Char)
    'return length of line containing character whose char index is Char
    calldll #user,  "SendMessage", hEd as word, _EM_LINELENGTH as word,_
    Char as word, 0 as long, ret as long
    LineLength=ret
End Function

Function GetLine$(hEd, LineNum)
    'gets text in specified riched line
    buffer$=space$(1024)+chr$(0)
    calldll #user,  "SendMessage", hEd as word, _EM_GETLINE as word,_
    LineNum as word, buffer$ as ptr, ret as long
    GetLine$=buffer$
End Function

Function SetSel(hEd,startpos,numchars)
    'select a range of text.
    'selection starts at first char to right of startpos
    pos = MakeLong(startpos,numchars)
    calldll #user,  "SendMessage", hEd as word, _EM_SETSEL as word,_
    1 as word, pos as long, Ret as void
End Function


And here is the word coloring routine and the function it calls

[ColorWord] 'select word & set WordClr before calling
    cf.dwMask.struct = CFMCOLOR
    cf.crTextColor.struct = WordClr
    ret=SetCharFormat(hRichEd, 1)
    Return

Function SetCharFormat(hEd, flag)
    'format text according to struct cf
    'flag 1=selection, 4=all
    EMSETCHARFORMAT = 1092
    calldll #user, "SendMessage", hEd as word,_
    EMSETCHARFORMAT as word, flag as word,_
    cf as ptr, ret as long
    SetCharFormat=ret
End Function


    I hope you have found this to be interesting as well as educational. If 
you would like to get a fully functioning editor that already has this built 
into it then read on! Alyce Watson and I teamed up and modified the open 
source editor to use the rich edit control with syntax coloring. It has 
several richedit features that aren't covered in this little primer along 
with lots of other code. Alyce has also added many other nice features to the
editor that are worth checking out just for themselves. She spent a great 
deal of time cleaning up my sloppy code and took it upon herself to wrap most
of the API calls into the functions presented here along with many more. 
Thank you Alyce!

    The open19.bas editor is available at http://belle2553.tripod.com and at 
Alyce's great site http://www.bigfoot.com/~alycewatson

All of the functions presented here and more have been put into an open 
source library that is also available at Alyce's web site. The library is for
everyone. If you develop more richedit routines please add to it so all may 
benefit.

-----------------------------------------------------------------------------

Internet Coding Tutorial
By: Brandon Watts


In this article, we will talk about different ways of using the internet in
your Liberty BASIC programs.

There have been other examples of how to do this, but these methods are very
important and should not be forgotten. That is why we are publishing another 
article on this subject.

First, here is an example of how to get information from a user and go to a
website that reflects that information.

In this example we will take input from the user, and then search Google for
more information about that topic.

This code is taken from the file lbsearch.bas which is included with the 
newsletter. Here is the code:


WindowWidth = 376
WindowHeight = 65

nomainwin

textbox #main.textbox, 14, 6, 248, 25
button #main.button, "Search!", [Search], UL, 286, 6, 66, 25
open "LB  Search" for graphics_nsb as #main
print #main, "fill darkgreen; flush"
print #main.textbox, "!setfocus";

[Loop]
wait
goto [Loop]

[Search]
print #main.textbox, "!contents?"
input #main.textbox, site$

url$ = "http://www.google.com/search?q="; site$

print #main.textbox, ""

h = 0
lpOperation$ = "open" + chr$(0)
lpFile$ = url$ + chr$(0)
lpParameters$ = "" + chr$(0)
lpDirectory$ = "" + chr$(0)
nShowCmd = _SW_SHOW

open "shell.dll" for dll as #shell

calldll #shell, "ShellExecute", _
h as word, _
lpOperation$ as ptr, _
lpFile$ as ptr, _
lpParameters$ as ptr, _
lpDirectory$ as ptr, _
nShowCmd as short, _
result as word
close #shell

goto [Loop]


Let's now look at the code that does the real work.

print #main.textbox, "!contents?"
input #main.textbox, site$

url$ = "http://www.google.com/search?q="; site$

This code takes the data from the textbox, and puts it in the variable site$.

Then the variable url$ (which holds the url we want to go to) adds the site$
variable to the end of it. This will make Google search for that 
particular topic.

h = 0
lpOperation$ = "open" + chr$(0)
lpFile$ = url$ + chr$(0)
lpParameters$ = "" + chr$(0)
lpDirectory$ = "" + chr$(0)
nShowCmd = _SW_SHOW

open "shell.dll" for dll as #shell

calldll #shell, "ShellExecute", _
h as word, _
lpOperation$ as ptr, _
lpFile$ as ptr, _
lpParameters$ as ptr, _
lpDirectory$ as ptr, _
nShowCmd as short, _
result as word
close #shell

This is the code that calls "shell.dll" and launches the default browser to
the website we specified earlier.


In the second example we will show you how to launch the default e-mail 
application, and put an e-mail address in the To: field.

This code is taken from the file lbemail.bas which is included with the 
newsletter. Here is the code:


WindowWidth = 448
WindowHeight = 85

nomainwin

button #main.default, "Submit an article to The Liberty BASIC Newsletter!", [Submit], UL, 14, 16, 410, 25
open "LB E-mail" for dialog as #main

[Loop]
wait
goto [Loop]

[Submit]
lpOperation$ = "open" + chr$(0)
lpFile$ ="mailto:brandonwatts@ga.prestige.net"+ chr$(0)
lpParameters$ = "" + chr$(0)
lpDirectory$ = "" + chr$(0)
nShowCmd = _SW_SHOWNORMAL

open "shell.dll" for dll as #shell

calldll #shell, "ShellExecute", _
h as word, _
lpOperation$ as ptr, _
lpFile$ as ptr, _
lpParameters$ as ptr, _
lpDirectory$ as ptr, _
nShowCmd as short, _
result as word
close #shell

goto [Loop]


Let's now look at the code that does the real work.

lpOperation$ = "open" + chr$(0)
lpFile$ ="mailto:brandonwatts@ga.prestige.net"+ chr$(0)
lpParameters$ = "" + chr$(0)
lpDirectory$ = "" + chr$(0)
nShowCmd = _SW_SHOWNORMAL

open "shell.dll" for dll as #shell

calldll #shell, "ShellExecute", _
h as word, _
lpOperation$ as ptr, _
lpFile$ as ptr, _
lpParameters$ as ptr, _
lpDirectory$ as ptr, _
nShowCmd as short, _
result as word
close #shell

This code calls "shell.dll" and launches the default e-mail application. The 
line below is the line that tells the program what to put in the To: field.

lpFile$ ="mailto:brandonwatts@ga.prestige.net"+ chr$(0)


Play around with these examples. You will quickly find that they can expand 
your applications potential.

-----------------------------------------------------------------------------

Access Windows Features
By: Brandon Watts


You are probably trying to figure out what I mean by this.

What I'm talking about here, is that Windows has certain dialogs that you
can access.

All of the examples I am going to post below can be very helpful to use in
your apps for a variety of purposes.

To use the examples, type this line in Liberty BASIC:

run "control.exe appwiz.cpl"

Just change the part that says appwiz.cpl to any of the file names posted 
below.


appwiz.cpl - Opens the Add/Remove Programs dialog.
desk.cpl - Opens the Display Properties dialog.
inetpl.cpl - Opens the Internet Properties dialog.
intl.cpl - Opens the Regional Settings dialog.
main.cpl - Opens the Mouse Properties dialog.
mmsys.cpl - Opens the Multimedia Properties dialog.
modem.cpl - Opens the Modem Properties dialog.
netcpl.cpl - Opens the Network dialog.
password.cpl - Opens the Password dialog.
sticpl.cpl - Opens the Scanner/Camera Properties dialog.
sysdm.cpl - Opens the System Properties dialog.
timedate.cpl - Opens the Date/Time Properties dialog.
powercfg.cpl - Opens the Power Managment dialog.
qtw32.cpl - Opens the Quicktime Control Panel.
prefscpl.cpl - Opens the Realplayer Properties dialog.
access.cpl - Opens the Accessibility Properties dialog.
telephon.cpl - Opens the Dialing Properties dialog.
quicktime.cpl - Opens the Quicktime Settings dialog.
joy.cpl - Opens the Game Controller dialog.

Have fun using these!

-----------------------------------------------------------------------------

PROFESSOR B.I. SMART
and his Teknikul Staff

As yew all know, thar has been much spekulashun
bout Aliuns floatin about ar skies. Speshuly since our
town citysen, Booger was ubducted sum two yers ago.

Me an muh teknikul staff set down an wrote unuther
komplicated program in Liberty Basic fer to track down
Aliun space krafts. Haven gotten the bugs out (dang roaches)
of ar lap top compooter we went up on thuh roof of
the Hawg Town Univurcity colluge buildin an set up ar
ekuipmunt. (hunnerd foot of elektrik cord, litenin rod,
an c.b. radio in case thuh aliuns desided to contakt us)

Settin up ar lap top compooter an stuff took us bout an
Doofy, sat an moniturd thuh c.b. an the rest of us
watched the lap top display. Thuh litenin rod wuz firmly
tached to thuh seriel port so we culd watch fer disturbinses
in thuh atmustfere of thuh lectro magnektic variuty.

Doofy didn get nuthin all day cept listen ta a coupl uh
truckers debaten if Michael Jackson was uh lesbian
or uh man what likes wearin women's hats. Not that
thur is anythang wrong with thayut. Truckers have rites
too!

At thuh end of thuh day, we never did git no evidunce
of Aliun space krafts, but we did catch a midget what
jumped from uh 747 jumbo jet. Cute little feller, wandered
round thuh roof swarin like uh sailor an askin us ifn this wuz
hell. I gues it were the hed trawma, cause he was sayin,
he culdint believe he ended up wit a town ful of idjuts.

Poor feller nevur did reelize that he wuz at the finest edukashunal
fasilities in thuh county. So thar ya have it. We didn catch
no Aliuns, aint no evidunce at tall. Just Midgits jumpin out
of jets cross country. . My theoree here is that this is what
happen to all them little peepuls from the movie Wizurd of Oz.
Sumwhar out thar be hords of little people runnin through
them woods.

Professor B.I. Smart
Hawg Town Univercity

By: David Henry
cobra@futura.net

-----------------------------------------------------------------------------

LB Program of the Month - XIDE

XIDE is an excellent IDE for Liberty BASIC. It shows the right way of how to 
program an IDE in LB.

Some of the great features are:

- MDI (Multiple Document Interface).
- A great selection of tools (Array Maker, Menu Maker, Syntax Viewer, etc.).
- A nice insert menu (Allows you to insert things like time, date, and code).
- A macro feature.
- Very helpful backup feature.

XIDE also comes with a program called Programmer's Companion that has more
tools that are helpful for LB.

Get XIDE at:

http://www.xenolithproductions.com

Congragulations XIDE!

-----------------------------------------------------------------------------

LB Website of the Month - Liberty BASIC Outpost

Liberty BASIC Outpost is one of the most impressive LB website's to come out 
in a long time.

With it's top notch design, and great content, Liberty BASIC Outpost will 
have you checking back frequently.

Make sure to bookmark this one!

The url is:

http://www.lboutpost.com

Congragulations Liberty BASIC Outpost!

-----------------------------------------------------------------------------

Snippets


From:  "Brian" <sonic@l...>
Date:  Tue Mar 27, 2001 11:26pm
Subject:  Re: [lbnews] Task List...

 
Hi Bubba 
Is this the one you were looking for ?  
 
Brian D

 'Get the class name and window caption of all running programs
 'By DL McKinney.
 
    nomainwin
 
    WindowWidth=600
    WindowHeight=400
 
    UpperLeftX=int((DisplayWidth-WindowWidth)/2)
    UpperLeftY=int((DisplayHeight-WindowHeight)/2)
 
    Open "Show Class Names and Captions" for Text as #1
 
' Get the handle of the window that covers the desktop.
    open "user" for dll as #user
    calldll #user, "GetDesktopWindow",hwnd as short
 

' Get the first child window of the desk top for a starting point.
    calldll #user,"GetWindow",_
        hwnd AS word,_
        _GW_CHILD AS word,_
        hwnd AS word
 
    WHILE hwnd <> 0
        calldll #user,"GetWindow",_
        hwnd AS word,_
        _GW_HWNDNEXT AS word,_
        hwnd AS word
 
        'Note: if you want the info for ALL running programs then
        'comment out the next line and the 'If - End If' lines.
 
        'calldll #user, "IsWindowVisible", hwnd as word, Result as short
        'If Result <> 0 then
            class$=space$(255)+chr$(0)
            calldll #user,"GetClassName",_
            hwnd AS word,_
            class$ AS ptr,_
            255 AS word,_
            length AS word
 
            class$=left$(class$,length)
 
            Caption$=Space$(244)+Chr$(0)
            calldll #user, "GetWindowText", _
            hwnd as word, _
            Caption$ as ptr, _
            255 as ushort, _
            result as ushort
            Caption$=Left$(Caption$,result)
 
            class$="Class Name = " + class$
            Caption$="Window Caption = " + Caption$
            print #1, class$
            print #1, Caption$
            print #1, " "
        'End If
 
    WEND
 
    CLOSE #user
 
    input a$  'pause until window closing
 
    close #1
 
--------------------

From:  "A. Watson" <alycewatson@c...>
Date:  Wed Apr 4, 2001 8:29am
Subject:  Re: [lbnews] Tiled Bmps

 
At 02:52 AM 4/4/01 -0000, you wrote:
>Is there any way I can tile a bmp over and over again on the screen?
>
>-Tegan

Very simple.  You must know the width and height of the bitmap.  If you are
hardcoding a bitmap in the program, just check these in your paint program.
 Otherwise, use the GetObject api call to get the dimensions.  You also
need to know the dimensions of the graphicbox or window.  Drawbmp in a
nested loop, with the outer loop ranging across the width of the window
with a step equal to the bitmap width and the inner loop ranging across the
height of the window with the height equal to the bitmap height.  Pseudo
code first:

for i = 0 to Width.of.Window step bitmap.width
  for j = 0 to Height.of.Window step bitmap.height
	print #g, "drawbmp bmpname ";i;" ";j
  next j
next i

Now a working model of code.

nomainwin

filedialog "Bitmap","*.bmp",file$
if file$="" then end

loadbmp "pic",file$

hBitmap=hbmp("pic")

struct BITMAP,_ '14 bytes
bmType as short,_
bmWidth As short,_
bmHeight As short,_
bmWidthBytes As short,_
bmPlanes as ptr,_
bmBitsPixel as ptr,_
bmBits as Long

open "gdi" for dll as #gdi
   calldll #gdi, "GetObject",_
   hBitmap as word,_
   14 as short,_
   BITMAP as struct,_
   results as short
close #gdi

width=BITMAP.bmWidth.struct
height=BITMAP.bmHeight.struct

open "Test" for graphics_fs_nsb as #1
print #1, "trapclose [quit]"
print #1, "down"

for i = 0 to DisplayWidth step width
    for j = 0 to DisplayHeight step height
        print #1, "drawbmp pic ";i;" ";j
    next j
next i

print #1, "flush"

unloadbmp "pic"
wait

[quit]
close #1:end

--------------------

From:  "Tim Brown" <teum@m...>
Date:  Wed Apr 11, 2001 4:39pm
Subject:  Re: Getting input

 


--- In lbnews@y..., "Brandon Watts" <brandonwatts@g...> wrote:
> <<Did I understand correctly that you need to log every possible 
key 
> press from the keyboard and output that to a text file?>>
> 
> Yes. That is exactly what I'm trying to do.
> 
> I'm playing around with it still while I type, but with bad 
results. 
> 
> <<In the meantime you might want to search the message archives. 
Carl C 
> and others have posted lots of good info related to this.>>
> 
> Sounds good. I will give it a try.
> 
> Thanks again,
> 
> Brandon (Stumped) Watts

Hello Brandon Stumped,

I expanded a little on one of Carl's examples below. As I understand 
it though, this inkey stuff only works with a graphics window...

  'INKEY.BAS  - how to use the Inkey$ variable
  NOMAINWIN
  open "Inkey$ example" for graphics as #graph
  print #graph, "when characterInput [fetch]"

[mainLoop]
  print #graph, "setfocus"
  input r$

[fetch]  'a character was typed!

  key$ = Inkey$
    if key$ = CHR$(13) then notice "RETURN was pressed"
    if key$ = CHR$(13) then goto [mainLoop]
    if key$ = CHR$(9) then notice "TAB was pressed"
    if key$ = CHR$(9) then goto [mainLoop]
    if key$ = CHR$(32) then notice "SPACE Bar was pressed"
    if key$ = CHR$(32) then goto [mainLoop]

    if len(key$) = 1 then notice key$+" was pressed!"
    if len(key$) = 1 then goto [mainLoop]

  keyValue = asc(right$(key$, 1))
    if keyValue = _VK_SHIFT then notice "Shift was pressed"
    if keyValue = _VK_CONTROL then notice "Ctrl was pressed"
    if keyValue = _VK_BACK then notice "BACkSpace was pressed"
    if keyValue = _VK_TAB then notice "TAB was pressed"
    if keyValue = _VK_CLEAR then notice "CLEAR was pressed"

    if keyValue = _VK_MENU then notice "Alt was pressed"
    if keyValue = _VK_ESCAPE then notice "ESCAPE was pressed"
    if keyValue = _VK_SPACE then notice "SPACE was pressed"
    if keyValue = _VK_PRIOR then notice "Page Up was pressed"
    if keyValue = _VK_NEXT then notice "Page Down was pressed"
    if keyValue = _VK_END then notice "End was pressed"


    if keyValue = _VK_HOME then notice "HOME was pressed"
    if keyValue = _VK_LEFT then notice "LEFT was pressed"
    if keyValue = _VK_UP then notice "UP was pressed"
    if keyValue = _VK_RIGHT then notice "RIGHT was pressed"
    if keyValue = _VK_DOWN then notice "Down was pressed"
    if keyValue = _VK_INSERT then notice "Insert was pressed"
    if keyValue = _VK_DELETE then notice "Delete was pressed"

    if keyValue = _VK_F1 then notice "F1 was pressed"
    if keyValue = _VK_F2 then notice "F2 was pressed"
    if keyValue = _VK_F3 then notice "F3 was pressed"
    if keyValue = _VK_F4 then notice "F4 was pressed"
    if keyValue = _VK_F5 then notice "F5 was pressed"
    if keyValue = _VK_F6 then notice "F6 was pressed"
    if keyValue = _VK_F7 then notice "F7 was pressed"
    if keyValue = _VK_F8 then notice "F8 was pressed"
    if keyValue = _VK_F9 then notice "F9 was pressed"
    if keyValue = _VK_F10 then notice "F10 was pressed"
    if keyValue = _VK_F11 then notice "F11 was pressed"
    if keyValue = _VK_F12 then notice "F12 was pressed"

  goto [mainLoop]

--------------------

From:  smartestmanal1ve@n...
Date:  Thu Apr 12, 2001 7:44pm
Subject:  Re: Getting input

 
hey brandon,

here is something to get you started.  it needs some work, doesnt 
detect the difference between upper and lower case, and will record 
the non printable characters.  also, you have to change it from a 
notice to writing it to a file.  hope it helps!

'key log code!

nomainwin

open "user" for dll as #user

inc=0
string$=""
exit=0

while not(exit)
 for VK = 0 to 135
  calldll #user, "GetAsyncKeyState", VK as short, result as short
  if result = -32767 then 'this makes sure it doesn't count it more 
then once
    inc=inc+1
    string$=string$+chr$(VK)
  end if
 next VK
 if inc=10 then exit=1
wend

notice string$

close #user

end 

-----------------------------------------------------------------------------
Please send all comments, article submissions, etc, to:

brandonwatts@ga.prestige.net
-----------------------------------------------------------------------------