Drag and drop images from WebBrowser control? - c#

In a traditional web browser (Chrome, IE, etc.), I can grab an image and drag it somewhere else, and depending on the application, I can drop the image and something will happen: it will be displayed, opened, saved, etc.
In the application I'm working on, I've added event handlers and code to download and display an image if you drag and drop it onto one of the PictureBoxes on the form. Works great, no problems with that.
For whatever reason, if I load a page in a WebBrowser control, I can't drag images from the page that's loaded. At first I thought maybe I had changed a property of the control that was disabling this functionality, but I created a brand new project with nothing but a WebBrowser on the form and pointed it to a few different pages with images. Even pointing it to a local file with just an img tag in it, I cannot get it to drag images out of the displayed pages. If I select text, I'm able to drag that text out, but no images.
Is there a property I'm missing that I need to set to enable this functionality?
Running in .NET 4 on Win 7 x86 with IE 10 and the registry key to cause the WebBrowser class to use the IE 10 engine. (also tried disabling that and going back to the default IE 7 engine)

Still haven't found an answer to the actual issue, but I found that wrapping my img tag with an anchor with href set to the image path, I can now drag and drop that anchor in the normal way. Drop event handler still manages to get a file path that works, and I have no problem setting the WebBrowser control's AllowNavigation to false. Couple CSS changes and I'm done.

Related

Webbrowser control not loading elements on screen without firing any events

I've built an app running a CRM website. Everything seems to be working fine except one thing.
When I click on a certain button on screen, it registers the mouseclick but never "load" anything. It display a new html popup on screen, like a div or frame on top of everything but the webbrowser is not seeing it as navigating or anything.
I checked all the events associated with webbrowser and nothing is firing but a new "window" appear on top of everything on the page.
I tried : navigated, documentcompleted, ProgressChanged, StatusTextChanged and DocumentTitleChanged but nothing is registering changes in the webpage.
And I really need to know when the popup and elements are loaded so my app can do some changed...

Linking Image control and FileUpload control

As the heading suggests, I'm trying to give the user the option to choose an image using the FileUpload control and after hitting the update button, display it in the Image control, existing inside a Panel control.
So far I've gotten here. This is my form.
And this is my code.
I let the highlighted code stay inside PageLoad function just for testing. I know it should be inside the Button's event handler.
Also, can someone explain me why the above fails to display the image even after hardcoding an absolute URL for Image.ImageUrl property. It worked when I referenced it just by giving the file name cake.png and putting the file inside the website folder. But I want to reference absolute URLs.
Any and all help is appreciated. Thanks.
You are creating a web application, which can be available on internet and can be accessible throughout the globe. In your example, which is not working, you are referencing a image file from local file system from your own computer, inside a web application. Your Web application is running under its own process and under its own account/user(IUSR in case of IIS) and your local system is running under a different process. so the two can't talk to each other like that.

Visual C# Programmatically Scroll Web Browser that has a PDF loaded into it

I know there are tons of similar topics to this question, but none have the answer I am looking for.
Basically what I have is a windows form, and on this form is a webbrowser control.
What I am trying to do is use the arrow keys to allow for scrolling of the web browser.
Now when it comes to HTML pages, everything works fine.
I do the normal Document.body.scrollTop to scroll the page.
Everything works great here.
The issue is when a PDF is loaded in the browser, The document is null, and I cannot scroll.
I have tried everything I could think of, and I have checked when a document is completed loaded if the sender object has the document filled in, for which it does not.
This kinda makes sense because I am going to assume that Document is for HTML to begin with.
Now my issue is, what do I use to make the browser scroll. I seem to have no viable access point to the window to change its scroll position.

Awesomium Is Not Loading In DockRight Pane When In Add-In-Express

We have been experiencing problems using Awesomium in the ADX add in when it is loaded in either the DockRight or DockLeft positions, but not when it is loaded in the ReadingPaneRight (or other non dock positions).
The Awesomium browser fails to display anything and just shows a busy cursor. It also does not fire any events. It is as if it has gone into some loop during startup.
If the form region is dragged to another location (for instance to the right of the message pane) and outlook is restarted, it loads just fine and the pane can be dragged into the DockRight/Left positions.
Is this a known issue? Is there any work around?
I have also asked this question over on the ADX support forums
http://www.add-in-express.com/forum/read.php?FID=5&TID=12055&MID=61413#message61413
I did see this support issue:
http://www.add-in-express.com/forum/read.php?FID=5&TID=11542
But that seemed to be about painting, while this seems to be about loading.
Note that Awesomium does load just fine in a VSTO custom task pane (if that helps at all.)
I've created a sample project here: https://github.com/greenkiwi/AwesomiumADXDockIssue/
This is an example ADX project running Awesomium that fails to display the browser or load anything in either the DockRight or DockLeft positions.
To run this project, you must have both Add-in-express installed and Awesomium and Outlook 2007 or greater (I tested against 2010).
Awesomium
http://www.awesomium.com/
Add-in-express
http://www.add-in-express.com/
Once they are installed, debug the application. The Awesomium window will open in the DockRight position, on my machine, I just get a busy cursor when ever the mouse enters the region, and the page never loads and no events get fired.
If you drag the form into the reading pane area and stop and restart the project, you will see the page load as it should load. The form region can now be dragged to other locations w/o a problem, however, if it is left in the dock right or left positions and outlook is stopped and started, it will stop working.
Please follow the discussion at http://www.add-in-express.com/forum/read.php?FID=5&TID=12055.

windows controls are disappearing in a win form after installing for adifferent locale

I am new to windows forms and localization.I have a windows form which is containing some radio buttons and checkboxes and some buttons. this from is impleneted as a child form inside a master form. the problems i am facing now is when i install the english build controls are appearing as they are positioned while desinging. But the problem is when i install the danish build for the same app the controls are not visible in the UI. but they are available somewhere on the Winform. the reason for making this statement is when the tab+ enter keys are pressed the browse dailog which is availble in the UI is opening but could not see it.
I tried the following ways.
set the Locked property of the controls to true.
set the autosize as true
anchor all the controls to left..
please let me know if anyone have any pointers on this ..
Thanks in advance..
I am not quite sure what type of localization you guys do, so I might be not 100% right here, but it seems that Danish resx file (something.da.resx) defines incorrect Location for the missing controls. Make sure that Location and Size values are correct.
If you are using some kind of tool to localize the contents, still Location of the controls is likely the cause, but I can't tell you why it happen (version incompatibility?).

Categories

Resources