'gui-skeleton app
$ Filename "t.exe"
'uses RTL64
uses COM\COMutil
uses WebBrowserAtl
uses awinh


#lookahead 
INT win,win2
INT x,y,w,h,x2,y2,w2,h2
x=0:y=10:w=800:h=600
x2=410:y2=10:w2=400:h2=300
INT winstyle,wstyle2,wbstyle
winstyle = WS_MINMAXSIZE or WS_CLIPCHILDREN 
wbstyle = WS_CHILD or WS_VISIBLE or WS_BORDER or WS_VSCROLL or WS_HSCROLL
INT btt0,btt1,btt2
INT b0ID = 100, b1ID=101, b2ID=102


% WM_FORWARDMSG = &H37F ' (895)

% IDB_BACK = 1001
% IDB_FWRD = 1002
% IDB_NAVG = 1003
% IDC_URL  = 1004
% IDC_WB   = 1005

extern lib "ATL.dll"
! AtlAxWinInit() as int
'! AtlAxWinTerm() as int
! AtlAxGetControl( sys hWnd, pp ) as int
end extern

int hWb

'create window
'
win = SetWindow("ATL:Browser",x,y,w,h,0,winstyle)

'create buttons
int style=WS_CHILD | BS_TEXT | BS_PUSHBOX | WS_VISIBLE
btt0=CreateWindowEx(0,"button", "O2", style,  64,4,30,30,  win, b0ID, 0, null)
btt1=CreateWindowEx(0,"button", "<--", style,  98,4,30,30, win, b1ID, 0, null)
btt2=CreateWindowEx(0,"button", "-->", style, 134,4,30,30, win, b2ID, 0, null)



'Initializes ATL
AtlAxWinInit

'create browser window
'hWb = CreateWindowEx(0, "AtlAxWin", "www.google.com",wbstyle , 64, 40, w-100,(h-56)-64, win, IDC_WB, 0, 0)
hWb = CreateWindowEx(0, "AtlAxWin", "https://forum.it-berater.org/index.php",wbstyle , 64, 40, w-100,(h-56)-64, win, IDC_WB, 0, 0)

'create interface
IDispatch *v,*po
int er=AtlAxGetControl(hwb, byval @@v)
v.QueryInterface(IID_IDispatch, byval @@po)
v.release

'message loop
wait()

'close
po.Release
@po=0
'AtlAxWinTerm()
end


function WndProc (sys hwnd,wmsg,wparam,lparam) as sys callback
==============================================================
select hwnd

case win

  select wmsg
  '
  case WM_CLOSE
    DestroyWindow win
    PostQuitMessage 0
  case WM_SIZE
    GetSize(win,0,0,w,h)
    MoveWindow(hWb,64, 40, w-100,(h-56)-64,1)
  case WM_COMMAND	
    controlID = LoWord(wParam) 'get control ID
    notifyCode = HiWord(wParam) 'get notification message
    '
    select controlID
    '
    case b0ID
      if notifycode=0 
        wbstring s="http://www.jose.it-berater.org/smfforum/index.php?board=154.0"
        CallByName(po,"navigate",s)
        frees s
      end if      
    case b1ID
      if notifycode=0          
        'CallByName(po,"GoBack")
        CmdByName(po,"GoBack")
     end if
    case b2ID
      if notifycode=0          
        'CallByName(po,"GoForward")
        CmdByName(po,"GoForward")
      end if
    end select
  end select
end select

return default

end function