Windows Phone 7 WebBrowser control swallows manipulation events? - webbrowser-control

If I place a WebBrowser control on any page, the page no longer responds to manipulation events under the WebBrowser. Other areas of the page work fine.
It's easily confirmed by overriding OnManipulationCompleted in a page, then placing a WebBrowser control on the page. Try swiping over the WebBrowser, and OnManipulationCompleted is never called.
I can't set the WebBrowser to IsHitTestVisible=false because I need to be able to click on links. But I want the page to respond to left/right swipes.
Anyone got any bright ideas? Or know if this is a bug in the current release?

I'd like to extend what Skeet already written.
The point is, that the MS WP7 dev team has published "guidelines", where they highly discourage putting (on the same page) multiple layout controls that accept and react to the same set of gestures. For example, you shouldn't try to embed a Pivot inside a Pano, because the horizontal-swipe will clash and it will be hard do distinguish which of them should execute its actions. The same case is with the browser: it responds to all swipes and pans.. so should not be put in almost any scrolling control!!
Now, having said that, I want to tell you it is possible to overcame it - although it may turn not easy, depending on your actual case.
The most trivial thing to do, if you want to still be notified about the gestures is to use GestureService/GestureListener from the Silverlight Toolkit library. Even when the WebBrowser extinguishes the raw manipulations events, the GestureListener will still be able to notify you - because it apparently listens on some "other layer", I don't exactly want to get in to it now. Just fetch the library, add-reference it, do something like:
GestureService.GetListener( targetcontrol ).Flick( myBrowserFlickHandler );
and it's done - you get the notification whenever someone flicks on the control, with completely no regard of the manipulation events being e.handled=true or not. Small disclaimer here: I don't remember if on 7.0 it works, because the WebBrowser is build a bit differenlty there. On 7.1 and 7.5 it should work.
However, if you apply that on a WebBrowser - you will get the notif - but the webbrowser will get it too. That means, that 2 controls will react, and it turn to be visually quite rejecting if you start some storyboards from within the handler..
On 7.1 and almost-current 7.5, it is possible to play hard with the WebBrowser and to completely control which manipulation-event it will see. Thus, by filtering the mani-events for the WB, and by using GestureListener to see the events yourself, you can both block the WB from doing anything, and at the same time you can respond with your own action instead. I've written about that extensively in a response to similar problem, see WP7 Pivot control and a WebBrowser control for details. It is not a quick/easy/funny thing to do though.
EDIT: and MOST importantly, it is NOT guaranteed to work in the future. Throughout the 7.1 and 7.5 SDK/OS/API versions, inside the WebBrowser control some major internal undergoing changes are visible, and I would not be surprised, if it would dramatically change in the next few releases. Don't play with the things I've wrote there about if you do not want to have to revisit the subject again in the next 1-2 years.

This is a consequence of the way we implemented WebBrowser. The touch events are handed off directly to the browser engine. Once that happens Silverlight is basically out of the picture. Unfortunately I can't think of any workarounds that might give you what you want. -Skeets, MS dev

If you really want it:
<Grid>
<phone:WebBrowser Source="http://www.microsoft.com" />
<Rectangle Fill="Transparent" ManipulationCompleted="HandleManipulationCompleted"/>
</Grid>
But of course it completely locks down interaction with web browser control and there's just no way to echo manipulation events to browser...

I think you have a better way capturing the manipulation events, if it is in WP7.5 Mango since the browser controls are completely different, which I read from this link

Related

How to generate Domino dialogboxes on traditional (non-xpages) webforms

I want to have a popup/dialogbox with an "OK" button on it that will close the dialogbox...after someone performs a task on a Domino webform. I know I used overlays in xpages before, but the current application I am maintaining was built with traditional Domino forms (lots of pass-thru HTML) and my initial attempt to build an overlay effect did not work.
I have tried using javascript code of:
var window = window.open(url, windowName, [windowFeatures]);
...but this has not been successful. No errors in debug, yet my url page does not pop up. I am hoping someone might be able to provide a snippet of what you use so I can see where I am going wrong.
The url parameter I am passing is correct, as I used an alert to show me what was going in there, but I am doing something basic wrong.
If I can answer any questions for you I can do that as well.
Thank you
The only way I know to display a dialog box in a classic Domino web application is to do just like you would on any HTML-based webpage. Either you create your own popup functionality, or you use one of the many plugins available.
When I work with classic Domino web applications, I have often added Bootstrap to it, to make things look a bit better. Then I can use either the native Bootstrap dialog boxes, or a plug-in called Bootbox.js. But there are many other ones.

Surface Table Project with Web Browsers

I'm working on a project that will use a Surface table to show web browsers that can be manipulated via the multitouch behaviors. I'd like to be able to show a browser at full screen and then resize, move, etc.
I'd also like to be able to launch a new, separate browser windows that can also be manipulated through multitouch.
Any suggestions on controls to look into for this?
Thanks!
This is a non-trivial task. As far as I know, many have tried and put months of effort into it but none of been very successful. Don't even bother trying to get something to work well based on WPF's built in WebBrowser control. Best bet is to start with the SurfaceScatterView control and trying to put a 'Chromium' control inside of it (http://wpfchromium.codeplex.com/). It appears that even this isn't straightforward though: http://wpfchromium.codeplex.com/discussions/244117

How does "Cinch App" do it?

If you aren't familiar with Cinch, its an application on Mac App Store that allows you to resize ANY window to half/full screen size if you drag the window to the edge of the screen. Exactly like the functionality in windows 7.
Now my question is, how is it done? I have looked all over cocoa apis looking for notifications/delegate methods for whenever a window is being dragged (ALL windows, not just windows owned by the app from which code is running from) but can't find it. Looked in Core Graphics API...Quartz Display Services....but can't find it.
Any help will be greatly appreciated as I have been looking for the past week....Thanks!
Edit: Resize the window is easy since it can be done through applescript bridge..
Are you developer behind i-Snap or some other Mac App Store clone of Cinch?
I'm the developer behind Cinch, and while I try to maintain an "abundance mentality" which basically says "There's enough out there for everyone", I've been upset by the Mac App Store lowering the barrier for entry to this market which has produced a number of half-backed competitors.
I would be thrilled to see some real innovation around the work I have done, and not just clones looking to make a quick buck.
Anyway, you want to look at the Accessibility APIs. It's a Carbon C API. This is probably your best reference: http://developer.apple.com/library/mac/#samplecode/UIElementInspector/Introduction/Intro.html%23//apple_ref/doc/uid/DTS10000728
I've not used the Cinch app, but if I were to do this I'd expect to be using cocoa events. (Also see here) Specifically the mouse handling events, combined with where the mouse is currently on-screen. They probably set a variable when a window is grabbed and then track the mouse pointer until it hits an edge or until they release the mouse button.
Events are very powerful and provide very low level access to what is happening, but can also be very complex. Good luck!
I'm not sure. Maybe the developers combine apple script and carbon events. You can create carbon events to know when the mouse has been clicked or dragged

Supress pop-up with VB 2008 Express Edition

The radio recently broke in our bedroom and as a result my missus now listen to various radio stations through her laptop. She moans that visiting various pages and clicking the 'listen' link is a bit of a pain. (Note to self: Must buy new radio!)
In the meantime, I have made a 'radio player' in VB 2008 Express, which is nothing more than 6 buttons down the left hand side of the 'player' I have created and a Web Browser Control on the right hand side.
Clicking each button links to the relevant player of the station she wants to listen to. (Being a newbie to VB and programming, I'm quite proud with what I've achieved so far!!)
Anyway, one station I do link to gives an "Are you sure you want to navigate away from this page" prompt: This one:
http://www.mygoldmusic.co.uk/
Well, thats the homepage of the site anyway, the actual player is here:
(Oops, seems I can only post one link! The actual player opens on-click of the 'listen' button then, sorry to be a pain!)
My question is: Is there a way to suppress this message in VB, or even auto-answer OK somehow?
The other sites I have linked to do not display this message, they just navigate away quite happily. Clicking OK on the prompt is no real hardship either, I hear you say, but in the interests of usability, I would just like it to navigate away from the site/player without prompting.
Remember, I'm using Microsoft Visual Basic 2008 Express Edition. (I say that, because I've come across loads of sites that tell you how to do it with JavaScript, just not VB!)
I've got to the point of thinking it can't be done, but here's hoping!
Any help/advice would be greatly appreciated. And, sorry for the lengthy question. Hope it gives you enough info on what I'm trying to achieve.
Thanks in advance again.
J.
The only way I can think of is to actually modify the DOM of the page in the WebBrowser control. That popup is loading when the "window.onunload" event fires. You should be able to override this behaviour by modifying the DOM.
The HTML document DOM (Document Object Model, essentially an object graph of the page structure) is stored in the WebBrowser.HTMLDocument property. Unfortunately, that specific property isn't available to the .NET version. It IS available to COM however, so through some very ugly and messy code you might be able to suppress the event.
The following code should be able to access the COM property containing the HTML DOM. The type returned is IHTMLDocument2, although you'll note that the class itself will return an object. You might need to add a reference to mshtml.dll to get the IHTMLDocument2 interface access the properties of this in a reasonable way.
Dim domDocument As IHTMLDocument2 = webBrowser.HtmlDocument.DomDocument
You can then access the OnUnload event (which sits on the "window" element, one above the document). Unfortunately, the plot thickens a bit here (I did say it was going to be ugly) because you need to pass a IDispatch object to the onunload event. I've never done this specifically but I found a write-up at the following link that provides some samples and should point you in the right direction: http://blogs.msdn.com/cgarcia/archive/2009/08/28/handling-dom-events-in-a-c-activex.aspx
You should be able to follow a similar approach but simply do nothing in the handler method, which should suppress the javascript alert you are getting.
Get the handle to the dialog and destroy it. Use FindWindow and send a WM_CLOSE message to it.

Code for extending the NETCF MainMenu to support background color property

I've searched for the solution to change the background color on the Compact Framework's MainMenu control, and the only answer I've found is that you need to create a custom control. Does anyone have example code for this?
I did something vaguely similar where I wanted to handle the WM_EXITMENULOOP message which was not available as an event in .NETCF.
The solution was to "subclass" the Main Menu, an old MFC trick where you replace the WndProc function with your own, handle any windows messages (WM_EXITMENULOOP in my case) and call the base class WndProc for everything else.
Some sample code is available on Alex Yakhnin's blog on how to subclass a control:
Example of subclassing a window in .NETCF
In your case you'd actually be subclassing the Form that the MainMenu resides on, and I think WM_DRAWITEM would be the windows message you'd want to handle yourself.
I haven't tried changing the background color myself so not totally sure this will work, but subclassing would be where I'd start.
There is no way of doing this.
Your right in that you'll probably need to create your own control.
This was something I was considering doing anyway to make the application go on Windows CE and Windows Mobile.
The problem with adding menus when the application needs to work with both is that the menu goes to the top of the screen on Windows CE and covers any controls that might be there.
It would be less hassle in the long run just make a new control.
I tried to do something similar a while back and discovered that you have to write your own menu; essentially from scratch. I gave up because the project I was working on couldn't afford the expense. I also discovered that OpenNETCF has a pretty awesome menu control. I don't know if it's included in their free software, but it might be worth looking into.