nomainwin
WindowWidth=400
WindowHeight=300
menu #main, "&File","E&xit", [quit]
graphicbox #main.g, 0, 0, 100, 100
open "Liberty Basic ATL Demo" For Window_nf As #main
#main "TrapClose [quit]"
Open "atl" For DLL As #atl
CallDLL #atl, "AtlAxWinInit", Ret As long
hWndViewer = hWnd(#main.g) 'Windows handle of graphicbox
hMain = hWnd(#main) 'Windows handle of main window
STRUCT Rect,_ 'struct for storing client area rectangle
leftX as long,_ 'upper left x
upperY as long,_ 'upper left y
rightX as long,_ 'lower right x
lowerY as long 'lower right y
calldll #user32,"GetClientRect",_
hMain as ulong,_ 'window handle
Rect as struct,_ 'name of struct
r as long 'return
cw = Rect.rightX.struct
ch = Rect.lowerY.struct
'resize graphicbox to fill client area of window
#main.g "locate 0 0 ";cw+2;" ";ch+2
#main "refresh"
CallDLL #user32, "GetWindowLongA", _
hWndViewer As ulong, _ 'handle of graphicbox
_GWL_HINSTANCE As long, _ 'flag to get instance handle
hInst As ulong 'returns instance handle of graphicbox
style = _WS_CHILD or _WS_VISIBLE or _WS_VSCROLL
'a minimal HTML document:
html$ = "MSHTML:<html><head></head><body>" + _
"This is an <font color=red>HTML</font> window!" + _
"<p><center>This line is centered</center>" + _
"</body></html>"
CallDLL #user32, "CreateWindowExA", _
_WS_EX_STATICEDGE As long, _ 'extended type
"AtlAxWin" As ptr, _ 'class name
html$ As ptr, _ 'URL, or progID or CLSID
style As long, _ 'window style
0 As long, _ 'left x pos
0 As long, _ 'top y pos
cw As long, _ 'width
ch As long, _ 'height
hWndViewer As ulong, _ 'handle of parent = graphicbox
100 As long, _ 'handle to menu or child window ID
hInst As ulong, _ 'parent instance handle
0 As long, _ 'window creation data
hATL As ulong 'handle of active template library control
wait
[quit]
Close #main
close #atl 'close DLL after closing window
end
function CallMethod(object, method, parm$)
code$=chr$(139)+"D$"+chr$(4)+chr$(139)+"T$"+chr$(8)+chr$(139)+"L$" _
+ chr$(16)+"VW"+chr$(139)+"t$"+chr$(20)+chr$(43)+chr$(225)+chr$(139) _
+ chr$(252)+chr$(243)+chr$(164)+chr$(80)+chr$(139)+chr$(0)+chr$(255) _
+ chr$(20)+chr$(144)+chr$(95)+chr$(94)+chr$(194)+chr$(16)+chr$(0)
p$=parm$
n=len(p$)
calldll #user32, "CallWindowProcA", code$ as ptr, object as long,_
method as long, p$ as ptr, n as long, CallMethod as long
end function