Is there a way to have web control with flat style?
I was able to add border and inset style but not able to remove 3D border and have it just flat.
Thanks
Eros
I have it flat, simply not adding styles imo.
Yes, that was my idea.
I just have %WS_CHILD Or %WS_VISIBLE and zero in exStyle but styll it has 3D borders
But I'm using José OLE Container anyhow.
It is not the container who is adding the 3D border, but the WebBrowser control.
To customize the WebBrowser control, you have to implement the IDocHostUIHandler2 interface and, in the GetHostInfo method, provide the appropriate flags, e.g. %DOCHOSTUIFLAG_NO3DBORDER OR %DOCHOSTUIFLAG_THEME to have both a WebBrowser control without border and using themes.
' =====================================================================================
METHOD GetHostInfo ( _ ' VTable offset = 16
BYREF pInfo AS DOCHOSTUIINFO _ ' /* [out][in] */ DOCHOSTUIINFO *pInfo
) AS LONG ' HRESULT
IF VARPTR(pInfo) THEN
pInfo.cbSize = SIZEOF(DOCHOSTUIINFO)
pInfo.dwFlags = %DOCHOSTUIFLAG_NO3DBORDER OR %DOCHOSTUIFLAG_THEME
pInfo.dwDoubleClick = %DOCHOSTUIDBLCLK_DEFAULT
pInfo.pchHostCss = %NULL
pInfo.pchHostNS = %NULL
END IF
METHOD = %S_OK
END METHOD
' =====================================================================================
In the WebGui example, we can do the connection with the IDocHostUIHandler2 in the DownloadComplete event.
' =====================================================================================
' Note It would be more appropriate to use the DocumentComplete event, but this
' event isn't fired. See: BUG: DocumentComplete Does Not Fire When WebBrowser Is Not Visible
' http://support.microsoft.com/kb/q259935/
' =====================================================================================
METHOD DownloadComplete <104>
' Get a reference to the IHTMLDocument2 interface
LOCAL pHTMLDocument2 AS IHTMLDocument2
pHTMLDocument2 = pIWebBrowser2.Document
IF ISNOTHING(pHTMLDocument2) THEN EXIT METHOD
' Connect to the events fired by the page
pHTMLDocumentEvents2 = CLASS "CHTMLDocumentEvents2"
IF ISNOTHING(pHTMLDocumentEvents2) THEN EXIT METHOD
EVENTS FROM pHTMLDocument2 CALL pHTMLDocumentEvents2
' After the MSHTML document has been loaded we retrieve a reference to his
' ICustomDoc interface and give him a pointer to our IDocHostUIHandler interface
' to allow for customization.
LOCAL pICustomDoc AS ICustomDoc
LOCAL pDocHostUIHandler AS IDocHostUIHandler2Impl
' Get a reference to the CustomDoc interface
pICustomDoc = pHTMLDocument2
IF ISNOTHING(pICustomDoc) THEN EXIT METHOD
' Set our IDocHostUIHandler interface for MSHTML
' MSHTML will release its previous IDocHostUIHandler interface
' (if one is present) and call pDocHostUIHandler's AddRef method.
pDocHostUIHandler = CLASS "CDocHostUIHandler2"
IF ISOBJECT(pDocHostUIHandler) THEN
pICustomDoc.SetUIHandler(pDocHostUIHandler)
END IF
' Release the interfaces
pDocHostUIHandler = NOTHING
pICustomDoc = NOTHING
END METHOD
' =====================================================================================
Note that this customization won't have effect in the first html page displayed, so we need to navigate first to a blank page, but we are already doing it in the WebGui example:
' Navigate to a blank page
vUrl = "about:blank"
pIWebBrowser2.Navigate2(vUrl)
The attached file contains a version of the WebGui example with the IDocHostUIHandler2 interface added. Since it is an IUnknown interface, don't remove or change the placement of any of the methods because they are called by offset, not by ID.
Thanks a lot José. It would be impossible for me to get it at the stage I am in learning COM interfaces but I'm getting in there more day by day.
I found a nice introduction to COM interfaces in the following article that unlighted my brain a lot: http://www.codeproject.com/KB/COM/COM_from_scratch_1.aspx
Back to the problem, for some reason suggested method is not working in thinBasic module but your example is working correctly so there is something wrong on my side.
Thanks again.
Eros
Building a browser control with basic functionality isn't too difficult. The OLE container will host the WebBrowser control and you only will have to add some functions.
But now you also want events... You will have to implement a class for events sink and write functions to allow you to set pointers to callback functions in your application that will receive the events.
But now you also want to customize the browser's behavior (a common request is to be able to disable the right click menu)... You will need to implement the IDocHostUIHandler and IDocHostUI interfaces and provide functions to set options.
But now you also want interactivity with the loaded web page... You will have to implement the IHTMLDocument interface, provide functions to set pointers to callback functions in your application, etc.
But now yo also want support for frames, for scripts...
Here is a list of HTML event classes:
HTMLAnchorEvents
HTMLAreaEvents
HTMLButtonElementEvents
HTMLControlElementEvents
HTMLDocumentEvents
HTMLElementEvents
HTMLFormElementEvents
HTMLFrameSiteEvents
HTMLImgEvents
HTMLInputFileElementEvents
HTMLInputImageEvents
HTMLInputTextElementEvents
HTMLLabelEvents
HTMLLinkElementEvents
HTMLMapEvents
HTMLMarqueeElementEvents
HTMLNamespaceEvents
HTMLObjectElementEvents
HTMLOptionButtonElementEvents
HTMLScriptEvents
HTMLSelectElementEvents
HTMLStyleElementEvents
HTMLTableEvents
HTMLTextContainerEvents
HTMLWindowEvents
Anything else that adding support for the WebBrowser events, the IDocHostUIHandler interface and the IHTLDocument interface can quickly become a nightmare.
Yes, I get your point and all your indications are a threasury for me.
My problem is not the COM interface per se or your OLE container or the browser control. I can understand that (well, till some point). My problem is to interact to all those interfaces with an interpreted language (thinBasic) at runtime and at the same time keep track of all. I do not have any compiled code or predetermined situation, all is built at runtime.
Anyhow, you have already done and suggested even too much. It is my job to try to understand all that and transform it to something stable and easy to be used for thinBasic users.
I'm coming to a point where I see more easy for me to create a COM runtime dynamic discovering library instead of incapsulating all those interfaces and all their methods.
Ok, that's all. Thanks again.
Eros