---------------------------------------------------------
The Liberty Basic Newsletter - Issue #21 - Nov 98
  "The only stupid question is the one you don't ask"!
---------------------------------------------------------
In this issue:
            1) Announcing Brosco's DLL
            2) User Defined Mouse Cursors in LB
            3) Drawing '3D' borders
            4) New Year's Honour List
            
Still in progress:
             Using FreeForm 
             GDI Programming part 2
             ..... and more .....

My Email backlog
Lately I have been away from home quite a lot.  If you have 
sent me email and I haven't responded - I am very sorry - I
have a backlog of unread email and I'm having trouble getting
to it all.  If its been a while since you sent me mail and I
haven't responded - please send it to me again and I will 
try to get to it ASAP.

Once again - sorry for not responding - I'm not ignoring
you - REALLY!
          
            ***************************************

            1) Announcing Brosco's DLL

I have found that when I make a DLL with just a couple of 
functions, the minimum size is around 100Kb - this is because
the compiler I use includes commonly used runtime modules into
the DLL.  I have now made a single DLL called BROSCOS.DLL -
which will be used to include several functions.

The ColorPick function (described in NL0016) is now in this DLL
along with a few new functions:

1) StatusBar.
This function allows you to create a Windows Statusbar on your
window.  

2) ProgressBar
This allows you to create a Windows Progress Bar.

3) Timer Functions.
These functions use Windows CallBacks when a specified time
interval has ellapsed.

What is a Windows CALLBACK??????

Windows keeps your program informed of user actions: mouse 
movement, button clicks, keyboard input, etc., by placing 
messages on a queue for your program to read and take the
appropriate action.  In many cases, Liberty Basic automatically
takes the appropriate action for us - or transfers control to
the appropriate part of the program.  For example, when we code:

    print #w, "trapclose [close.w]"

this informs LB that when it finds a Close Window message on the
message queue to transfer control to the section of code with the
label '[close.w]'.  (The Windows message queue was discussed in
a little more detail in the previous newsletter).

CallBacks are slightly different.  Instead of placing a msg on the
queue, windows needs to CALL your program directly to inform you
of a particular action.  This release of LB cannot handle CallBacks,
so the DLL has been written to receive the CallBack for you, and
then notify you that the CallBack was received.  It does this by
placing a RESIZE message on the message queue - thus getting LB
to transfer control to the label specified for the ResizeHandler.

The attached zip file contains the following files:

STATBAR.BAS
    This program demonstrates how to use the StatusBar Functions.

PROGRESS.BAS
    This program demonstrates how to use the ProgressBar functions.

ColorPk.bas
    This program demostrates how to use the PickColor function.

ANIM1.BAS
    This program demonstrates how to use the timer functions for
animation.

CLOCK.BAS
    This program demostrates how to use the timer functions for
creating a clock.

FILECHK.BAS
    This program uses the timer functions to check for the 
existance of a file - say, created by another program.

TIMERCB.BAS
    Demonstrates the timer functions, displaying a message box
every 5 seconds.

HMAN001.BMP - HMAN014.BMP
    BMPs used by the ANIM1.BAS program

ANIM.TXT, CHKTIME.TXT, TIMERCB.TXT
    Text files displayed by the above programs.

BROSCDLL.TXT
    Documentation for all functions in Brosco's DLL.


            ***************************************

            2) User Defined Mouse Cursors in LB

User defined cursors must be included in a Resource File that
is linked to your program.  Since LB does not allow for the
linking of a Resource file, I have included one in a DLL.  This
means that if you have a Cursor that you would like to use, you
must send it to me to include it into the DLL.  When you do so,
not only will you have access to that cursor for your own use,
you will also be making it available for the whole LB Community!

Unfortunately there is a small amount of flicker - I think this
is caused by the way LB implements its mouse cursor routines. By
using the LB command to make it an I-Beam:

    Cursor text

will reduce the flicker slightly.

Currently I have placed 15 Cursors in the DLL - 

1   Bull's Eye
2   Move 1
3   Move 2
4   Move 3
5   Baby's Bottle
6   Leaf
7   Smiley
8   Smoke
9   Wheel
10  Whale
11  Sword
12  Heart
13  Brosco
14  Hand
15  Alyce


you can see what they look like by running the sample program:  

CURSOR.BAS - it allows you to switch between the default arrow 
cursor and the 15 available cursors in a GraphicBox in a Window.  

CURSOR2.BAS just demonstrates the Bull's Eye cursor in a 
Graphics Window.

I was supprised with the way Windows accomplishes this.  Not 
only do you have to Load the cursor from the resource file,
but you must also "SetCursor" every time the mouse moves, if
you don't - it reverts back to the original cursor.

Notice also that when you move the cursor it is only in effect
for the child window - in the first example - for the GRAPHICBOX,
and for the second example - the client area of the Graphics
window.

The format for the CallDll to load the cursor is:

        CallDll #mcursor, "LoadCursor", _
            cursorID as word, _    ' ID of the cursor to load
            hw as word, _          ' hwnd of Child window
            hCursor as word        ' cursor handle to use in 
                                   '   "SetCursor"

NOTE:  The cursorID is currently a number from 1 to 15 to 
represent the available cursors described above.

After you have loaded the cursor - you must detect when the 
mouse is moved:

        print #w, "when mouseMove [mouse.move]"

and then include code to "SetCursor" each time it is moved:

[mouse.move]    
    CallDll #user, "SetCursor", hCursor as word, result as word
    goto [loop]

and to revert to the default cursor - simply turn off the 
mouseMove detection:

        print #w, "when mouseMove"

So - its now up to you - if you want your own cursors for LB,
send them to me and I will include them in the DLL.  There are
freeware cursors on many sites on the Internet.  Oh - just in
case you were hoping for this - sorry - it will only work for
Win 16-bit cursors - it CAN'T handle Win95 animated cursors.  


And don't forget - by sending them to me you will be SHARING
them with the entire LB community.


            ***************************************

            3) Drawing '3D' borders

I found an API that Windows uses to draw the '3D' type borders
around a control - say, like a Push Button.  I am uncertain of
the version of Windows that you will need for this.  It works 
on Windows 95 - but I am fairly certain that it won't work for
Win 3.1 - and I have no idea if it will work on 3.11 or WFWG.  

' Sample DrawEdge
' Brosco - Nov 98
'
    nomainwin
    WindowWidth = 540
    WindowHeight = 200

    graphicbox #w.b, 20, 20, 450, 100
    open "Demo of DrawEdge API Call" for window as #w
    print #w, "trapclose [close.w]"
    print #w.b, "fill lightgray;backcolor lightgray"

    hw = hwnd(#w.b)

    open "user.dll" for dll as #user
    callDll #user, "GetDC", hw as word, hdc as word


    struct r, _
        x as word, _
        y as word, _
        x2 as word, _
        y2 as word
    r.x.struct = 50
    r.y.struct = 10
    r.x2.struct = 100
    r.y2.struct = 60
    calldll #user, "DrawEdge", _
        hdc as word, _
        r as struct, _
        5 as word, _        ' Edge Raised
        15 as word, _
        result as word
    print #w.b, "place 50 85;\Raised"

    r.x.struct = 150
    r.y.struct = 10
    r.x2.struct = 200
    r.y2.struct = 60
    calldll #user, "DrawEdge", _
        hdc as word, _
        r as struct, _
        10 as word, _       ' Edge Sunken
        15 as word, _
        result as word
    print #w.b, "place 150 85;\Sunken"

    r.x.struct = 250
    r.y.struct = 10
    r.x2.struct = 300
    r.y2.struct = 60
    calldll #user, "DrawEdge", _
        hdc as word, _
        r as struct, _
        9 as word, _        ' Edge Bump
        15 as word, _       ' Flags - see below
        result as word
    print #w.b, "place 250 85;\Bump"

    r.x.struct = 350
    r.y.struct = 10
    r.x2.struct = 400
    r.y2.struct = 60
    calldll #user, "DrawEdge", _
        hdc as word, _
        r as struct, _
        6 as word, _        ' Edge Etched
        15 as word, _
        result as word
    print #w.b, "place 350 85;\Etched"

[loop]
    input var$

[close.w]
    close #user
    close #w
    end

' Edge specification values
    edge.raised = 5
    edge.sunken = 10
    edge.etched = 6
    edge.bump = 9

' DrawEdge Flags
    bf.left = 1
    bf.top = 2
    bf.right = 4
    bf.bottom = 8
    bf.rect = 15  ' rect = left+top+right+bottom


            ***************************************

            4) New Year's Honour List

Have you been holding out on us?  Do you have a bit of
clever code that you haven't shared - well now is the time
to show us.  We are open for nominations for the New Year 
Honours list of outstanding contributions.

That's right - any piece of code - from a snippett thru to
a full blown application - if you have done something clever
- or know another that has - its time to tell us so that the
code can be considered for the New Year Honour list.  Prizes
of a free upgrade/registration of LB will be given to the best
submissions.

The categories are open - just specify a category when you
submit or nominate some code.  Examples are:

Best Utility
Best Game
Best Graphics
Best User Interface
etc.

You have over a month and a half to win this - so start
thinking and show everybody how clever you are.

The following LBers will be the judges - as they are the ones 
who have sponsored the prizes.

Garrett H
Alyce W
Micheal R
and
Brosco

Obviously Carl will also be asked to be a judge.

The judges will be working out the details of the rules over
the next few days and will be posting them at a new Awards
site.

HINTS:
Although I am mainly interested in systems utility software,
Carl has been wanting someone to write a version of the 
Lunar Lander game for as long as I have been a member of
this community.  Garrett is definitely the User Interface
guru, Michael thrives on practical applications and we all
know Alyce is the Graphics expert.  So, can you write 
something to grab the attention of one of the panel? 


--------------------------------------------------------------
 Newsletter compiled and edited by: Brosco and Alyce.
 Comments, requests or corrections: Hit 'REPLY' now!
---------------------------------------------------------------
 
