How do I disable user input on a WebView? - c#

I'm having tons of issues trying to integrate Microsoft's WebView in my WinRT application and one of them is the following. I want to display the WebView and its content (which comes from a local offline server but that works like a charm) and I don't want the user to be able to click around ; basically completely disable user input on this WebView.
There is no IsEnabled property on this control so I tried:
Catching the many Pressed-like events and setting the Handled property of the event object to false in each one of the handlers
Catching the GotFocus event of the WebView to set the focus on another control immediately
Putting the WebView in a ContentControl, then set the IsEnabled property of the ContentControl to false
Obviously, none of these workarounds did work so I'm facing a brickwall here. Maybe some of you can help find a solution?
More details if that can help: the web page that is loaded contains an HTML5 canvas where the user can draw things (like in Microsoft Paint). There are also links (ahref). I dont want the user to be able to draw on this canvas, and I don't want them to be able to click on these links as well!
Thanks

Hi you can use a if the content is not animated then you can use a Rectangle instead of the WebView and in the rectangle you use a WebViewBrush, this actually take the webview and render it's content as an image on the rectangle. since it is an image no interaction is available on the rectangle, but if you have animation then you will lose them.
Generally this trick is used to show content onto the webview.

Related

WinForm Controls are transparent, and not displaying properly

When a form loads, I'd like it to show a loading image (within a Picture Box) and a standard Windows label with some text. However, all I see are white boxes, or sometimes I see another form underneath. How do I get the image and label to display properly.
I've tried setting AllowTransparency to false when the form loads, and also setting the Transparency Key of the form to some other colour, but nothing has worked.
The project is C# .Net v3.5 (also tried v4 and v4.5).
Any ideas?
First, you can't display an image, busy-wait, and then change the image - this will never redraw anything, leading to the symptoms you describe. To "wait" you will need to return control to your main application loop so it can continue to process messages (e.g. to handle redraw requests for your window). One way to do what you want is to display your initial state (splash screen) and then use a timer to call you back later to change the display to your second state.
The next problem you face is using forms controls with transparency. Most controls treat "transparent" as "fill your background with your parent controls color", which is not what you want. An easy way around this is to implement a Paint handler and draw the image and text for yourself - this gives you much more control of how your display looks, and will also allow you to get a cleaner redraw (no flicker or other problems caused by the display being built up but by bit in several controls)
Lastly, consider implementing your splash screen display as a separate control/form that you show above your main form during loading, as that makes it easy to "overlay" on your main form without having to change its design at all.
Just write formObjectName.Refresh() after formObjectName.Show()

AxWindowsMediaPlayer size in WPF applications

I am using an AxWindowsMediaPlayer in a WindowsFormsHost in a WPF application.
I'm having problems with sizing the control.
I need to hide the video part, and keep only the part with buttons and seek bar. (since I run audio)
I need to adjust the WindowsFormsHost to only display this part.
I tried to resize the WindowsFormsHost manually so that it only shows the required part, but when I tested the program on different pc's it wasn't displayed properly. Some parts from the control were cropped.
I know you want to hide the video with the uiMOde
awWindowsMediaPlayer.uiMode= "invisible";
But, this hide controls too...
For me, you have two solutions:
the first, you create your axWindowsPlayer form with 45pixel of height for display just the controls button.
the seconds, you hide all the form, and create all your button...
you've acces at the controls button with : (play button for sample)
axWindowsMediaPlayer.Ctlcontrols.play();
And you've acces to the settings with : (volume for sample)
axWindowsMediaPlayer.settings.volume = 25;
I also saw that it was possible to define a custom uiMode, but I did not find any information about that...
You have two options.
Set uiMode to invisible and define your own buttons (functions are accesable like: axWindowsMediaPlayer.Ctlcontrols.stop();).
Set uiMode to mini or full and set height 40. It leaves control without video visible (link: http://msdn.microsoft.com/en-us/library/windows/desktop/dd562469%28v=vs.85%29.aspx)
You can also hide status, bar and controls
axWindowsMediaPlayer.uiMode= "None";

How to set the background of webview transparent in winRT?

I have a web view which loads html content in a page.How its back ground can set to transparent.I set the html background transparent.
Try this:
<WebView DefaultBackgroundColor="Transparent"/>
To my knowledge that's not possible since this an actual HTML page you are rendering inside the Webview.
The webview does not derive from Control and because of this, it does not support the same templating possibilities as if you we using a control that derived from Control.
Also since browsers can't have a transparent website, the website will appear white per default.
This may not directly relate to your question however I think it's still important to know when using the Webview. There is some important remarks from the documentation on MSDN concerning UI and rendering:
WebView has the characteristic that other UI regions such as controls cannot be rendered on top of the WebView. This is because of how window regions are handled internally, particularly how input events are processed and how the screen draws. If you want to render HTML content and also place other UI elements on top of that HTML content, you should use WebViewBrush as the render area. The WebView still provides the HTML source information, and you reference that WebView through the SourceName property. WebViewBrush does not have this overlay limitation.
If you want to display an interactive WebView that only occasionally has overlapping content (such as a drop-down list or app bar), you can temporarily hide the WebView control when necessary, replacing it with an element using a WebViewBrush fill. Then, when the overlapping content is no longer present, you can display the original WebView again. For more info, see the WebView control sample.
For more information see the full documentation.
They have fixed it in Windows Universal App.
If you set DefaultBackgroundColor to Transparent
and
body, html {
background:transparent;
}
you will get what you want

Make Multiple Controls Use Same Tool Tip Message (c# Client App.)

I would like the same tool tip message (the one entered in the "ToolTip on myControlId" field) to be displayed when the mouse is hovered over an area which contains multiple controls. I tried putting the controls inside a Panel and GroupBox, but it only works when the mouse is in the "white space" area of the Panel/GroupBox, and, of course, does not work when the mouse is on a control within the Panel/GroupBox.
I'm from the web dev world so I'm open to suggestions for a new approach if I'm going about this the wrong way.
In standart windows developmern (WindowsForms) tootltip or tooltip control is associated to a single control. But you can use ToolTip control (see example how: ToolTip: Windows Forms .NET) and assign to all controls that recieve mouseover event.
If you're in WPF, the story becomes easier as you have message routing so usually it's enought to have subscription in one place.
Hope this helps.

Display strokes on an InkCanvas, but do not capture events

I am developing a touch screen application and allow users to add touch-based markup to an overlay over content using an ink canvas. I have reached a point where the view behind the overlay has an element that needs the user should be allowed to interact with, but events are captured by the InkCanvas and not by the underlying control. Is there a way to display strokes, but still allow controls behind the InkCanvas to capture events?
You can set InkCanvas.IsHitTestVisible = false and it will still display but you will not be able to interact with it and all events will go to elements lower in the z-order, which sounds like exactly what you want.
In my case I'm toggling the InkCanvas. To accomplish this, I also had to set InkCanvas.InkPresenter.InputDeviceTypes = CoreInputDeviceTypes.None to disable it.

Categories