• Welcome to Powerbasic Museum 2020-B.
 

News:

Forum in repository mode. No new members allowed.

Main Menu

Remove border from webcontrol?

Started by Edwin Knoppert, August 21, 2009, 11:22:12 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Edwin Knoppert

There seems to be a difference between the ATL container and your code container.
With your code i can not remove the WS_EX_CLIENTEDGE, i forced it by enumming *every* child but i can not get rid of it?

Any idea where to look?
Maybe i tried to remove the wrong style but it looks like the normal 3d border.

José Roca

 
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
   ' =====================================================================================


Edwin Knoppert

Haha. i may have done that somewhere, i forget these kind of things (been using the HOSTUI for theming though).
Thanks, will try that later.
I was using a windowregion at this time to get rid of it :)

Btw, you didn't write an example for use with your code did you?
I do have code but the old fashion way, doesn't matter.

José Roca


Edwin Knoppert

Thank you very much, saves me a headache :)

Edwin Knoppert

To use the UI stuff i have to obtain the document and a 2nd refresh to update the webcontrol.
I do this order:
1) about:blank
2) wait until loaded
3) Set UI
4) about:blank
5) wait until loaded
6) Show form
7) [navigate to url]

This works ok but the wait for ready (state) requires 'doevents' in the loop.
Is there a better way to give the webcontrol time to load the document?
I want don't want to give the users time to click a form's controls while loading the document.
I normally do the above before the form shows so no big deal but i prefer to block input and give the WC the time it needs.
(I am not looking for work arounds)



José Roca

Only you know why you are navigating to about:blank twice. Once should be enough.

Edwin Knoppert

No, once the UI interface is set (which excludes the 3d border) it will be shown on the next navigate.
To prevent that this is done during a real webpage retrieval, i do this with about:blank.
Otherwise it shows the border first.

José Roca

 
No if you do it in the appropriate place. I do it in the DocumentComplete event and, therefore, I only need to use about:blank once, at startup, and also don't need to "wait until loaded".


Edwin Knoppert

I did that before.

That code needs a mechanism that it should not set a UI interface on each complete + the first time you'll see the change afterwards and if i am not mistaken, even worse, from the 2nd complete and up.

Edwin Knoppert

I have done a test using your project, your code:

           vUrl = "about:blank"
           pIWebBrowser2.Navigate2(vUrl)
           ' Navigate to a web site
           vUrl = "http://www.jose.it-berater.org/index.html"
           pIWebBrowser2.Navigate2(vUrl)

The problem is the about:blank (ab) here, when executed my experiance is that it relies on the execution speed of the computer/windows.
I had often the doc-complete being aborted due to the 2nd call.
Therefore the need to wait until it's done.

Then to prove the UI stuff is to late i have remarked the AB, the first navigate shows the website without theming.
No theming and having a 3d border.
Clicking home  'set's' the UI stuff and theming is enabled and the border is gone.

My 2nd suggested loop may not be necessary at all, the first is important.
In any case, to do it right, you should set the UI before a 2nd url is executed, so the wait until complete works out the same as setting it in the event.
Though the event needs a mechanism to avoid resetting.
Not my style and thus i do it this way, it's the same imo.




José Roca

 
Take the second example from this thread:

http://www.jose.it-berater.org/smfforum/index.php?topic=2676.0

Change the line in WM_SIZE to


MoveWindow GetDlgItem(hWnd, %IDC_IEWB), 10, 10, rc.nRight - rc.nLeft - 20, rc.nBottom - rc.nTop - 20, %TRUE


So you can clearly see the borders of the control and not confuse them with the 3D borders of the main window. You will see that there are not 3D borders.


Edwin Knoppert

I know that, you where in luck is what i am telling you.
In this case you had luck that somehow the first call (AB) is completed and the UI is set (but not updating the control frame)
The 2nd *is* the moment the WC is changing.

What i am telling you is that navigating twice *without* making sure the first navigate ends up in a doc complete is an unstable moment.
From my experiance the AB is aborted by the 2nd call and thus the UI stuff is set at another moment.
Therefore you'll find examples with the readystate.

This all depends on the speed of the AB being processed and is unreliable.

Btw, i used that example and the first time the control was not themed, i could reproduce that only once though..

José Roca

 
I don't navigate twice. I only call about:blank once, at startup, just to fire the code that creates the sink to IDocHostUIHandler2 because, otherwise, the first page will appear using the defaults. I need to to this because I set the pointer to the IDocHostUIHandler2 interface in the DownloadComplete event, but you can use another technique if you wish.

Edwin Knoppert

The code above shows that you call navigate2 twice.

>I set the pointer to the IDocHostUIHandler2 interface in the DownloadComplete event
I know that, i am stressing about a coding flaw, navigating or instructing, whatever the name, twice is not good, you where 'lucky' that the complete finished properly but is an unstable factor since the control needs to process the Windows messages and in your case that is not guaranteed.
The AB can be aborted due to the 2nd call.

Where you put the UI stuff is not important, i choose to do it after the AB.
First, i don't need the events code, 2nd this way i can force the control to update itself ondemand and not via some dumb async event ever to happen.
I write for programmers, they may not set a navigate2 on app load and thus the control must be as specified in the PwrDev environment, without border + themed.
They also may not need an event handler.

Frankly, i was only looking for a recommended way to process the messages.
I suspect there isn't a better way.