'===========================================================================
' Subject: SELECTING TEXT IN A TEXTBOX        Date: 01-20-97 (15:11)       
'  Author: Carl Gundel                        Code: LB                     
'  Origin: carlg@world.std.com              Packet: LIBERTY.ABC
'===========================================================================

    'SETSEL.BAS - code snippet for Liberty BASIC v1.3 or better

    'Here is a useful snippet of code for selecting the text
    'in a textbox.  This is NOT a complete program and will
    'not run on its own.  This is useful if you want to set up a
    'textbox for typeover.  The handle #window.tbox is chosen
    'for example purposes only.

    'find out the size of the contents of #window.tbox
    print #window.tbox, "!contents?"
    input #window.tbox, guessField$
    sizeOfField = len(guessField$)

    'get the Windows handle for our textbox
    hTextbox = hwnd(#window.tbox)

    'calculate the data required to make the selection
    selectFrom = 1
    selectTo = sizeOfField * 256
    selectionData = selectFrom + selectTo

    'make an API call to make the selection
    open "user" for dll as #user
    calldll #user, "SendMessage", _
        hTextbox as ushort, _
        _EM_SETSEL as ushort, _
        0 as ushort, _
        selectionData as ulong, _
        result as ulong
    close #user
