Date: 02-16-2022
Return to Index
created by gbSnippets
'... this snippet is in work
'Compilable Example: (Jose Includes)
#Compiler PBWin 9, PBWin 10
#Dim All
%Unicode=1
#Include "win32api.inc"
%IDC_Find = 500 : %ID_OCX = 501
Global hDlg, hOcx As Dword, oOcx As Dispatch
Declare Function AtlAxWinInit Lib "ATL.DLL" Alias "AtlAxWinInit" () As Long
Declare Function AtlAxWinTerm () As Long
Declare Function AtlAxGetControl Lib "ATL.DLL" Alias "AtlAxGetControl" ( ByVal hWnd As Dword, ByRef pp As Dword ) As Dword
Function PBMain
Local hInst,hr,pUnk,dwCookie As Dword
Local OcxName As AsciiZ * 255, vVar As Variant, uMsg As tagMsg
OcxName = "Shell.Explorer"
AtlAxWinInit
Dialog New Pixels, 0, "A Web Browser in a DDT dialog",,, 500, 450, %WS_OverlappedWindow, 0 To hDlg
Control Add Button, hDlg, %IDC_Find, "Find", 10, 425, 50, 20, %WS_TabStop
Control Add "AtlAxWin", hDlg, %ID_OCX, OcxName, 0, 0, 500, 420, %WS_Visible Or %WS_Child
Control Handle hDlg, %ID_OCX To hOcx
AtlAxGetControl(hOcx, pUnk)
AtlMakeDispatch(pUnk, vVar)
Set oOcx = vVar
SetFocus(hOcx)
Dialog Show Modal hDlg Call DlgProc
UnregisterClass ("AtlAxWin", GetModuleHandle(ByVal %NULL))
End Function
CallBack Function DlgProc()
Local rc As RECT, r,x,y,xx,yy As Long
Select Case Cb.Msg
Case %WM_InitDialog
Local strUrl As String, vVar As Variant
strUrl = "http://www.garybeene.com"
vVar = strUrl
Object Call oOcx.Navigate(vVar)
Case %WM_Command
Select Case Cb.Ctl
Case %IDC_Find : FindOCXText
End Select
End Select
End Function
Sub AtlMakeDispatch ( ByVal lpObj As Dword, ByRef vObj As Variant) Export
Local lpvObj As VARIANTAPI Ptr ' Pointer to a VARIANTAPI structure
Let vObj = Empty ' Make sure is empty to avoid memory leaks
lpvObj = VarPtr(vObj) ' Get the VARIANT address
@lpvObj.vt = %VT_Dispatch ' Mark it as containing a dispatch variable
@lpvObj.pdispVal = lpObj ' Set the dispatch pointer address
End Sub
Sub FindOCXText
Local CGID_WebBrowser As Guid
Local pDisp As IDispatch
Local pCmdTarget As IOleCommandTarget
Local vIn As Variant
Local vOut As Variant
CGID_WebBrowser = Guid$("{ED016940-BD5B-11CF-BA4E-00C04FD70816}")
pIWebBrowser2 = OC_GetDispatch(hOCX)
pDisp = pIWebBrowser2.Document
If IsObject(pDisp) Then
pCmdTarget = pDisp
If IsObject(pCmdTarget) Then
pCmdTarget.Exec(CGID_WebBrowser, 1, 0, vIn, vOut)
End If
End If
End Sub
'gbs_00976
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm