Home All Groups Group Topic Archive Search About

XP Styles and Web Browser control

Author
14 Oct 2005 7:49 PM
Faraz Azhar
Hello

I have successfully implemented the XP styles on my app. I have a web
browser control in my app and I use it to view an html page which
contains forms (buttons). If I view that html file in Internet
Explorer, the buttons show all nice and ok with XP styles, but when I
try to view that file in my app through Web Browser control, the
buttons dont appear with XP styles whereas my app has implement the
styles.

How to make web browser control implement xp styles?

Faraz Azhar

Author
14 Oct 2005 11:31 PM
MikeD
Show quote Hide quote
"Faraz Azhar" <itz_fa***@hotmail.com> wrote in message
news:1129319365.226978.38220@g43g2000cwa.googlegroups.com...
> Hello
>
> I have successfully implemented the XP styles on my app. I have a web
> browser control in my app and I use it to view an html page which
> contains forms (buttons). If I view that html file in Internet
> Explorer, the buttons show all nice and ok with XP styles, but when I
> try to view that file in my app through Web Browser control, the
> buttons dont appear with XP styles whereas my app has implement the
> styles.
>
> How to make web browser control implement xp styles?


I don't really have an answer other than VB6 and under aren't designed to
support XP styles (because they came out well before WinXP). Yes, you can
get XP styles implemented via a manifest file, but VB6 (and therefore, apps
created with it) don't natively support this.

I would think the WebBrowser control would conform to XP styles since it's
dependent on the version of IE installed.  But who knows?  Maybe IE just
needs updated on the PC? Or maybe the WebBrowser control, even though it's
basically IE, just doesn't support this.

--
Mike
Microsoft MVP Visual Basic
Author
15 Oct 2005 4:57 AM
Fatih Argun
try using (original) Internet Explorer.

sory for my bad english

'FORM CODE

Option Explicit

Private Const GWL_STYLE As Long = (-16)
Private Const GWL_EXSTYLE As Long = (-20)
Private Const WS_CAPTION As Long = &HC00000
Private Const WS_EX_CONTROLPARENT As Long = &H10000
Private Const WM_CLOSE As Long = &H10

Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA"
(ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA"
(ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function SetParent Lib "user32" (ByVal hwndChild As Long,
ByVal hWndNewParent As Long) As Long
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA"
(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam
As Long) As Long
Private Declare Function DrawMenuBar Lib "user32" (ByVal hwnd As Long) As
Long

Private Declare Function IsWindow Lib "user32" (ByVal hwnd As Long) As Long
Private WithEvents IEBrowser  As InternetExplorer
Private hwndBrowser As Long
Private bExit As Boolean

Private Sub Form_Load()
    CreateBrowser
End Sub

Private Function CreateBrowser(Optional ByVal URL As String) As Boolean
    Dim lStyle As Long

    Set IEBrowser = Nothing 'if iebrowser crashes before create, this line
is important
    Set IEBrowser = New InternetExplorer

    hwndBrowser = IEBrowser.hwnd

    IEBrowser.Resizable = False
    IEBrowser.RegisterAsBrowser = True
    IEBrowser.RegisterAsDropTarget = True
    If LenB(URL) Then
        IEBrowser.Navigate2 URL
    Else
        IEBrowser.Navigate2 "about:blank"
    End If

    lStyle = GetWindowLong(hwndBrowser, GWL_STYLE)
    lStyle = lStyle And Not WS_CAPTION
    SetWindowLong hwndBrowser, GWL_STYLE, lStyle

    lStyle = GetWindowLong(hwndBrowser, GWL_EXSTYLE)
    lStyle = lStyle Or WS_EX_CONTROLPARENT
    SetWindowLong hwndBrowser, GWL_EXSTYLE, lStyle

    IEBrowser.Left = 0
    IEBrowser.Top = 0
    IEBrowser.Width = Me.ScaleWidth \ Screen.TwipsPerPixelX
    IEBrowser.Height = Me.ScaleHeight \ Screen.TwipsPerPixelY

    SetParent hwndBrowser, Me.hwnd

    DrawMenuBar hwndBrowser 'if iebrowser recrates (see onquit event) then
menubar disappears (titlebar appears); refresh menubar

    IEBrowser.Visible = True

    CreateBrowser = True
End Function

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    bExit = True
End Sub

Private Sub Form_Resize()
    'do not use Left or Top properties here (or try and see iebrowser
left/top)
    IEBrowser.Width = Me.ScaleWidth \ Screen.TwipsPerPixelX
    IEBrowser.Height = Me.ScaleHeight \ Screen.TwipsPerPixelY
End Sub

Private Sub IEBrowser_OnQuit()
    If bExit Then 'program closing
        hwndBrowser = 0
    Else 'user closing iebrowser using alt+f4, ctrl+w or file menu vs.
(alt+f4 or ctrl+w determines if form keypreview property true and you can
use this key closing program)
        CreateBrowser "" 'IEBrowser.LocationURL '=Cancel (where is "Cancel"
or how can i subclass iebrowser ("other application"))
    End If
End Sub

Private Sub Form_Unload(Cancel As Integer)
    'don't use "If Not IEBrowser Is Nothing Then" or "If hwndBrowser Then"
to determine iebrowser is exist
    'for example: if user ends iebrowser by using task manager then the
following loop prevents to unloading
    If IsWindow(hwndBrowser) Then
        Me.Visible = False 'hide form before closing iebrowser
        PostMessage hwndBrowser, WM_CLOSE, 0&, 0&
        Do Until hwndBrowser = 0 'otherwise could be occurs an automation
error
            DoEvents
        Loop
    End If
    Set IEBrowser = Nothing
End Sub
Author
16 Oct 2005 6:37 PM
Faraz Azhar
oh geez... original IE instead of OCX... thats a nice piece of coding
though. ok I'll try to place it in my app.

Thanks fellows!
Author
18 Oct 2005 12:37 AM
Faraz Azhar
error occuring at this stage:

Set IEBrowser = New InternetExplorer

Its not creating a new window/class. Error was "Class does not support
Automation or does not support expected interface."
Author
18 Oct 2005 4:16 AM
jack
just get the information of XP manifest .xml
Author
18 Oct 2005 5:41 AM
Fatih Argun
- Do not use WebBrowser object.
- Delete WebBrowser object on your form
- Remove "Microsoft Internet Controls" from "Components"
- Add reference "Microsoft Internet Controls" from "References".