Deprecated: Array and string offset access syntax with curly braces is deprecated in /homepages/21/d38531796/htdocs/jose/smfforum/Sources/Subs.php on line 3825
Remove border from webcontrol?

Author Topic: Remove border from webcontrol?  (Read 9197 times)

0 Members and 1 Guest are viewing this topic.

Offline Edwin Knoppert

  • Sr. Member
  • ****
  • Posts: 254
  • User-Rate: +11/-4
    • Hellobasic.com
Remove border from webcontrol?
« on: August 21, 2009, 11:22:12 AM »
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.

Offline José Roca

  • Administrator
  • Hero Member
  • *****
  • Posts: 2487
  • User-Rate: +204/-0
Re: Remove border from webcontrol?
« Reply #1 on: August 21, 2009, 04:03:05 PM »
 
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.

Code: [Select]
   ' =====================================================================================
   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
   ' =====================================================================================

Offline Edwin Knoppert

  • Sr. Member
  • ****
  • Posts: 254
  • User-Rate: +11/-4
    • Hellobasic.com
Re: Remove border from webcontrol?
« Reply #2 on: August 21, 2009, 08:26:21 PM »
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.

Offline José Roca

  • Administrator
  • Hero Member
  • *****
  • Posts: 2487
  • User-Rate: +204/-0
Re: Remove border from webcontrol?
« Reply #3 on: August 21, 2009, 09:03:36 PM »

Offline Edwin Knoppert

  • Sr. Member
  • ****
  • Posts: 254
  • User-Rate: +11/-4
    • Hellobasic.com
Re: Remove border from webcontrol?
« Reply #4 on: August 21, 2009, 09:12:11 PM »
Thank you very much, saves me a headache :)

Offline Edwin Knoppert

  • Sr. Member
  • ****
  • Posts: 254
  • User-Rate: +11/-4
    • Hellobasic.com
Re: Remove border from webcontrol?
« Reply #5 on: August 25, 2009, 07:14:44 PM »
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)



Offline José Roca

  • Administrator
  • Hero Member
  • *****
  • Posts: 2487
  • User-Rate: +204/-0
Re: Remove border from webcontrol?
« Reply #6 on: August 25, 2009, 07:40:53 PM »
Only you know why you are navigating to about:blank twice. Once should be enough.

Offline Edwin Knoppert

  • Sr. Member
  • ****
  • Posts: 254
  • User-Rate: +11/-4
    • Hellobasic.com
Re: Remove border from webcontrol?
« Reply #7 on: August 25, 2009, 07:57:40 PM »
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.

Offline José Roca

  • Administrator
  • Hero Member
  • *****
  • Posts: 2487
  • User-Rate: +204/-0
Re: Remove border from webcontrol?
« Reply #8 on: August 25, 2009, 08:25:31 PM »
 
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".


Offline Edwin Knoppert

  • Sr. Member
  • ****
  • Posts: 254
  • User-Rate: +11/-4
    • Hellobasic.com
Re: Remove border from webcontrol?
« Reply #9 on: August 25, 2009, 08:48:15 PM »
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.

Offline Edwin Knoppert

  • Sr. Member
  • ****
  • Posts: 254
  • User-Rate: +11/-4
    • Hellobasic.com
Re: Remove border from webcontrol?
« Reply #10 on: August 25, 2009, 08:58:21 PM »
I have done a test using your project, your code:
Code: [Select]
           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.




Offline José Roca

  • Administrator
  • Hero Member
  • *****
  • Posts: 2487
  • User-Rate: +204/-0
Re: Remove border from webcontrol?
« Reply #11 on: August 26, 2009, 12:27:20 AM »
 
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

Code: [Select]
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.


Offline Edwin Knoppert

  • Sr. Member
  • ****
  • Posts: 254
  • User-Rate: +11/-4
    • Hellobasic.com
Re: Remove border from webcontrol?
« Reply #12 on: August 26, 2009, 06:25:36 AM »
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..

Offline José Roca

  • Administrator
  • Hero Member
  • *****
  • Posts: 2487
  • User-Rate: +204/-0
Re: Remove border from webcontrol?
« Reply #13 on: August 26, 2009, 03:55:48 PM »
 
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.

Offline Edwin Knoppert

  • Sr. Member
  • ****
  • Posts: 254
  • User-Rate: +11/-4
    • Hellobasic.com
Re: Remove border from webcontrol?
« Reply #14 on: August 26, 2009, 04:57:56 PM »
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.