'===========================================================================
' Subject: SPLASH SCREEN                      Date: 12-17-98 (08:23)       
'  Author: Alyce Watson                       Code: LB                     
'  Origin: awatson@wctc.net                 Packet: LIBERTY.ABC
'===========================================================================
'Program Name: splash.bas  for Liberty BASIC
'Program Author: Alyce Watson: awatson@wctc.net
'Program Date: 1998
'Make a splash screen stay onscreen for as long as you want.
'Get the device context of the entire window, not just the
'client area, and transfer the desired bitmap for splash screen
'onto entire window, hiding frames, titlebar, etc.
'This program is released to the public domain.  This author accepts
'no responsiblilty for the performance of this program.
'Use this code freely in any way you wish.  It is not necessary
'to give any credit to the author.


'REQUIRES Liberty BASIC v1.41 for the hbmp function!
'Liberty Basic can be found at http://world.std.com/~carlg/basic.html


    bmpName$="c:\lb14w\vwsignon.bmp" 'put your bmp name here - must be 256 or fewer colors

nomainwin
    loadbmp "splash", bmpName$

    hSplash=hbmp("splash")

    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",_
           hSplash as word,_   'handle of bitmap
           14 as short,_       'bytes in STRUCT
           BITMAP as struct,_  'STRUCT
           results as short

    nWide=BITMAP.bmWidth.struct  'width of bmp
    nHigh=BITMAP.bmHeight.struct 'height of bmp



WindowWidth=nWide:WindowHeight=nHigh 'make window exact size of bmp
UpperLeftX=int((DisplayWidth-nWide)/2) 'center window width
UpperLeftY=int((DisplayHeight-nHigh)/2) 'center window height

open "" for window as #splash

    hSP=hwnd(#splash) 'handle of splash window

open "user" for dll as #user

    calldll #user, "GetWindowDC",_
        hSP as word,_      'handle of splash window
        hDCsplash as word  'device context of splash window


    calldll #gdi,"CreateCompatibleDC",_
        hDCsplash as word,_  'dc of splash window
        newDC as word        'handle of new DC created in memory


    calldll #gdi, "SelectObject",_
        newDC AS short,_     'DC in memory
        hSplash AS short,_   'select handle of bitmap into DC
        RESULT AS short

    calldll #gdi,"BitBlt",_  'block image transfer
        hDCsplash as word,_  'destination DC
        0 as word,_          'x loc destination
        0 as word,_          'y loc destination
        nWide as word, _     'width of bmp
        nHigh as word,_      'height of bmp
        newDC as word, _     'source - memory DC that contains bmp
        0 as word, _         'x org source
        0 as word, _         'y org source
        _SRCCOPY as dword, _ 'raster operation is COPY
        r as ushort

    calldll #gdi,"deleteDC",_
        newDC as word,_   'delete DC created in memory
        r as ushort

    calldll #user, "ReleaseDC",_
        hSP as word,_        'handle of splash window
        hDCsplash as word,_  'release DC for splash window
        results as void

    close #gdi
    close #user

    for count = 1 to 7 'a 7 second delay
        t$ = time$()
        while t$ = time$()
        wend
    next count

    close #splash
    unloadbmp ("splash")

open "Main Program" for graphics_fs_nsb as #main
    print #main, "trapclose [quit.main]"
    input aVar$

[quit.main]
    close #main: end
