a_carignan wrote:I'm talking about the two sample code on this page.
I tried to convert the text with its command lines:But it doesn't work, it's still Chinese.Code: Select all
*ascii=Ascii(anchor$) anchor$=PeekS(*ascii,-1)
Code: Select all
Global hBrowser, webInit
Global pElement.IHTMLElement
Global pAnchor.IHTMLAnchorElement
Global pDispatch.IDispatch
Global pDocument2.IHTMLDocument2
Global WebObject.IWebBrowser2
Procedure doweb()
If pDispatch : pDispatch\Release() : EndIf
If WebObject\get_document(@pDispatch) = #S_OK
If pDispatch\QueryInterface(?IID_IHTMLDocument2, @pDocument2) = #S_OK
hChild1 = FindWindowEx_(GadgetID(0), 0, "Shell Embedding", 0)
hChild2 = FindWindowEx_(hChild1, 0, "Shell DocObject View", 0)
hBrowser = FindWindowEx_(hChild2, 0, "Internet Explorer_Server", 0)
If hBrowser = 0 ; is our browser window available yet
If pDispatch : pDispatch\Release() : EndIf
webInit = #False ; browser window not available yet
Else
webInit = #True ; browser window available
EndIf
EndIf
EndIf
EndProcedure
Procedure MouseProc(nCode, wParam, lParam)
*ms.MOUSEHOOKSTRUCT = lParam
Select wParam
Case #WM_RBUTTONUP
StatusBarText(1, 0, "")
currentsb$ = ""
Case #WM_RBUTTONDOWN
If pDocument2
;- I use WindowMouseX() and WindowMouseY() so for
;- PureBasic ver < 3.91, uncomment the next 3 lines
;GetCursorPos_(@cpos.POINT);
;ScreenToClient_(hBrowser, @cpos)
;If pDocument2\elementFromPoint(cpos\x, cpos\y, @pElement) = #S_OK
;- for PureBasic ver < 3.91, comment the next line
If pDocument2\elementFromPoint(WindowMouseX(0) , WindowMouseY(0) , @pElement) = #S_OK
If pElement\QueryInterface(?IID_IHTMLAnchorElement, @pAnchor)= #S_OK
pElement\Release()
pAnchor\get_href(@BSTR_Anchor)
anchor$ = PeekS(BSTR_Anchor)
If currentsb$ <> anchor$
StatusBarText(1, 0, anchor$)
currentsb$ = anchor$
EndIf
pAnchor\Release()
Else
StatusBarText(1, 0, "")
currentsb$ = ""
EndIf
EndIf
EndIf
result = 1 ;result = 0 enables context menu
EndSelect
ProcedureReturn result
EndProcedure
If OpenWindow(0, 0, 0, 700, 500, "Hypertext Info" , #PB_Window_SystemMenu )
If CreateStatusBar(1, WindowID(0))
AddStatusBarField(400)
EndIf
hWeb = WebGadget(0, 0, 0, WindowWidth(0), WindowHeight(0)-25, "http://www.purearea.net/pb/CodeArchiv/English.html")
WebObject = GetWindowLong_(GadgetID(0), #GWL_USERDATA)
hInstance = GetModuleHandle_(0)
lpdwProcessId = GetWindowThreadProcessId_(WindowID(0), 0)
hhook = SetWindowsHookEx_(#WH_MOUSE, @MouseProc(), 0, lpdwProcessId)
EndIf
Repeat
Event = WaitWindowEvent()
If Event = 32770 And webInit = #False
doweb()
EndIf
Until Event = #PB_Event_CloseWindow
If hhook : UnhookWindowsHookEx_(hhook) : EndIf
If pDispatch : pDispatch\Release() : EndIf
End
DataSection
IID_IHTMLDocument2:
;332C4425-26CB-11D0-B483-00C04FD90119
Data.l $332C4425
Data.w $26CB, $11D0
Data.b $B4, $83, $00, $C0, $4F, $D9, $01, $19
IID_IHTMLAnchorElement:
;3050F1DA-98B5-11CF-BB82-00AA00BDCE0B
Data.l $3050F1DA
Data.w $98B5, $11CF
Data.b $BB, $82, $00, $AA, $00, $BD, $CE, $0B
EndDataSection