Print Page | Close Window

File drag drop on webbrowser control

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Suite Pro
Forum Description: Topics Related to Codejock Suite Pro
URL: http://forum.codejock.com/forum_posts.asp?TID=12261
Printed Date: 21 November 2024 at 7:06pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: File drag drop on webbrowser control
Posted By: Alina
Subject: File drag drop on webbrowser control
Date Posted: 26 September 2008 at 6:20am
   Hello,
   I have a form having a web browser control on it.    
   I want to get the file name(s) along with path(s) whenever some file is dragged and dropped on my web browser control. 
   I added in code Application.RegisterAsDropTarget = True.  After that, when a file is draged and dropped on my webbrowser , the webbrowser loads the file's content.  And the  DragDrop event is not fired.

   How can I achieve this functionality?

   Thanks in advance!



Replies:
Posted By: Lodep59
Date Posted: 02 October 2008 at 2:54am

Hi,

Why don't you use the WB navigate_complete event ?

When you drag and drop a file on a WB the file is loaded in the WB (do you want this ?) and the navigate_complete event is fired.
 
So you can do something like this :
 
Private Sub WebBrowser1_NavigateComplete2(ByVal pDisp As Object, URL As Variant)
    MsgBox "File loaded " & URL
End Sub

Hope this help.


Posted By: Alina
Date Posted: 04 October 2008 at 10:03am
Hi,
Thank you for your reply.
It doesn't help me very much  because I don't want the file to load in the webbrowser. I want to get only  the file name along with path. My application is an instant messenger. I want to have the possibility to send a file to the person I'm talking to, just like Yahoo messenger does.

Any other idea?
Thanks!



Posted By: Lodep59
Date Posted: 09 October 2008 at 4:24am
If you want you can cancel the navigation !
For this use the before navigate event :
 
Private Sub WebBrowser1_BeforeNavigate2(ByVal pDisp As Object, URL As Variant, Flags As Variant, TargetFrameName As Variant, PostData As Variant, Headers As Variant, Cancel As Boolean)
    MsgBox "File to upload : " & URL
    Cancel = True
End Sub
 
You should write some conditions to cancel the navigation. If you don't do that your webbrowser will no navigate at all.


Posted By: Alina
Date Posted: 09 October 2008 at 4:31am
It was so simple and I didn't see it!
Thank you!



Posted By: Lodep59
Date Posted: 10 October 2008 at 5:16am
You're welcome


Posted By: Pooja
Date Posted: 04 November 2008 at 3:54am
hello all
 
I have a from having web browser control on it...
webBroswer control have the url : 

this.webBrowser1.Url = new System.Uri("http://localhost:1162/OCOTVWidgetTestPage.html", System.UriKind.Absolute);

But my problem is this that i am unable to drag drop the webBrowser Control..I also make true this property AllowWebBrowserDrop

this.webBrowser1.AllowWebBrowserDrop = true;

But still i am unable to do it..

and secondly i m unable to make transperent the back ground og webBrowser Control
Please help me what to do.
 
Thanks in advance
Pooja


Posted By: Lodep59
Date Posted: 05 November 2008 at 9:43am
Hi,
 
The background of a webbrowser can't be transparent because it's the background of the webpage.
 
You want to allow the drag and drop ON the webbrowser or OF the webbrowser ?
 
It's different, if you want to allow drag and drop of a file on the webbrowser just look at my answer on the top of this post. The drag and drop is controled by the webbrowser control, you don't have to write any code (except for interception).
 
Note : i'm working with VB6, not you i think...
 
Hope this help,


-------------
Product: Xtreme SuitePro (ActiveX) last version
Platform: Windows 7 Ultimate
Language: VB6 SP6 (FR)



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net