Problems with Flash in WebBrowser

L

ljlevend2

I am having problems interacting with flash objects (i.e., Adobe Flash Player
9) in web pages when using a System.Windows.Forms.WebBrowser control. The
flash objects always seem to display correctly, but when I click on a link
within the flash object the WebBrowser often fails to navigate to the new
page. If I use IE6 (from outside by app) or an AxSHDocVw.AxWebBrowser
control (within my app) then everything works as expected.

You can try this out by creating an app with the following code:

Public Class Form1
Public Sub New()
InitializeComponent()
Me.Size = New Drawing.Size(600, 600)
Dim wb As New System.Windows.Forms.WebBrowser
wb.Dock = DockStyle.Fill
wb.Url = New System.Uri("http://www.falcon-nw.com/")
Me.Controls.Add(wb)
End Sub
End Class

On the web site that opens I can normally navigate to one of the links
(e.g., “WHAT’S NEWâ€). After that the page usually won’t navigate to any of
the other links.

I'm using Visual Basic 2005, .NET Framework 2.0, WinXP SP2.

Thanks for any help!
Lance
 
W

Walter Wang [MSFT]

Hi Lance,

This is a known issue of the .NET 2.0 WebBrowser control code. We're sorry
for the inconvenience caused. Here's the workaround for the WebBrowser
code: we need to inherit from the WebBrowser control and override its
WndProc to handle the mouse releated messages:

Public Class MyWebBrowser
Inherits System.Windows.Forms.WebBrowser

Const WM_LBUTTONDOWN As Integer = &H201
Const WM_RBUTTONDOWN As Integer = &H204
Const WM_MBUTTONDOWN As Integer = &H207
Const WM_MOUSEACTIVATE As Integer = &H21

Private Function FindContainerControl() As ContainerControl
Dim cc As ContainerControl = Nothing
Dim ctl As Control = Me
Do While Not ctl Is Nothing
Dim tempCC As ContainerControl = TryCast(ctl, ContainerControl)
If Not tempCC Is Nothing Then
cc = tempCC
Exit Do
End If
ctl = ctl.Parent
Loop
Return cc
End Function

Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
Select Case m.Msg
Case WM_LBUTTONDOWN, WM_RBUTTONDOWN, WM_MBUTTONDOWN,
WM_MOUSEACTIVATE
If Not DesignMode Then
Dim cc As ContainerControl = FindContainerControl()
If Not cc Is Nothing AndAlso Not cc.ActiveControl Is Me
Then
cc.Focus()
End If
End If
DefWndProc(m)
Case Else
MyBase.WndProc(m)
End Select
End Sub

End Class


I've tested it on my side using this customized WebBrowser control with the
URL you provided, it's working correctly. Please test it on your side and
let me know the result. Thanks.


Sincerely,
Walter Wang ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications. If you are using Outlook Express, please make sure you clear the
check box "Tools/Options/Read: Get 300 headers at a time" to see your reply
promptly.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 
L

ljlevend2

Hi Walter,

Thank you so much for your help. You understood my issue perfectly and your
suggestion was exactly what I needed. I am very grateful of your help!

Lance
 
S

seb

Im sorry if i am digging up a old topic but i had the same error and found
this page thing is im new to visual basic so could some one explain how/where
i add that code
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top