'===========================================================================
' Subject: BRING WINDOW TO TOP                Date: 01-20-97 (15:11)       
'  Author: Carl Gundel                        Code: LB                     
'  Origin: carlg@world.std.com              Packet: LIBERTY.ABC
'===========================================================================

   'BOBSP2.BAS - code snippet for Liberty BASIC v1.3 or better

   'This example shows how to bring a window to the top using an
   'API call

   WindowWidth = 640
   WindowHeight = 480
   open "USER.EXE" for DLL as #user

   '****************** Make 1st window and button ******************
   button #graf1.button1, "Goto Window 2", [button1Click], UL, 198, 171, 140, 25
   open "Window 1" for graphics as #graf1
   'get the parent handle for our graphics window because by default it gets
   'the handle for the graphics child part of the window, not the top level window
   intermediate=HWND(#graf1)
   calldll #user, "GetParent",_
       intermediate as word, _
       handle1 as word
   print #graf1,"fill yellow"
   print #graf1,"flush"


   '******************* Make 2nd window and button *****************
   button #graf2.button2, "Goto Window 1", [button2Click], UL, 198, 171, 140, 25
   open "Window 2" for graphics as #graf2
   'get the parent handle for our graphics window because by default it gets
   'the handle for the graphics child part of the window, not the top level window
   intermediate=HWND(#graf2)
   calldll #user, "GetParent",_
       intermediate as word, _
       handle2 as word
   print #graf2,"fill blue"
   print #graf2,"flush"

   '******************** Input Loop ********************************
   [inputLoop]   'wait here for input event
    scan aVar$ 
    goto [inputLoop]

   '*********************** Change to Window 2 ************************
 [button1Click]   'Perform action for the button named 'button1'
    'use BringWindowToTop instead of ShowWindow
    calldll #user,"BringWindowToTop",_
        handle2 as word,_
        result as void
 goto [inputLoop]

   '*********************** Change to Window 1 ***********************
[button2Click]   'Perform action for the button named 'button2'
    'use BringWindowToTop instead of ShowWindow
    calldll #user,"BringWindowToTop",_
        handle1 as word,_
        result as void
 goto [inputLoop]
