The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: LieseLover on January 30, 2009, 08:11:50 AM

Title: Can not drag URLs from Internet Explorer and Drop them onto a UserForm
Post by: LieseLover on January 30, 2009, 08:11:50 AM
Hi folks,
I'd like to drag URLs from Internet Explorer and Drop them onto my UserForm
and finaly save them as a "*.url" file to use as bookmark in the Browser.

The procedure should be a part of a portable BookmarkManager which changes
temporary the Bookmarksfolder from usally "C:\Dokuments and Settings\USER\Favorites"
to the Location where the Bookmarks of the USB-Stick are.

So first I set the Style of my DialogBox on "WM_ACCEPTFILES" but this made the Win only accept
Files and Folders etc. not Links/Urls from a Browser.

After Googling for solutions I found an Example that came my wishes the nearest.
I modiefied it that when you drag a url from a Browser over the Form a messagebox appears holding
the URL.
But this is not a clean solution there should be a smarter Way with the typical Dragging Icon
and the Drop event.

As atachment for this Post there are 2 Files first A Flashdemo of what my Goal is
and second the Project file I modified.

Is someone here able to help me?

sry for my bad English

[attachment deleted by admin]
Title: Re: Can not drag URLs from Internet Explorer and Drop them onto a UserForm
Post by: ToutEnMasm on January 30, 2009, 08:41:26 AM
Hello,
Your application need to implement OLE and perhaps used a control who accept this feature.A richedit control for example.



Title: Re: Can not drag URLs from Internet Explorer and Drop them onto a UserForm
Post by: jj2007 on January 30, 2009, 01:31:51 PM
Quote from: ToutEnMasm on January 30, 2009, 08:41:26 AM
Hello,
Your application need to implement OLE and perhaps used a control who accept this feature.A richedit control for example.

COM is not needed. A RichEdit control pastes the URL directly into the text.
Title: Re: Can not drag URLs from Internet Explorer and Drop them onto a UserForm
Post by: LieseLover on January 30, 2009, 09:45:56 PM
Thx for yor reply.
It wasn't my aim to solve the Problem with an RichEdit I'd just like to drag the link on my
form and receive the Url when dropping it.

Greetz
Title: Re: Can not drag URLs from Internet Explorer and Drop them onto a UserForm
Post by: donkey on January 30, 2009, 10:20:06 PM
Quote from: LieseLover on January 30, 2009, 09:45:56 PM
Thx for yor reply.
It wasn't my aim to solve the Problem with an RichEdit I'd just like to drag the link on my
form and receive the Url when dropping it.

Greetz

A URL is not really an object in the Shell namespace and therefore drag and drop using the shell api will not work with it. You will probably have to implement the IDropTarget interface and call RegisterDragDrop function with the handle of your window and an IDropTarget interface pointer. Once you have detected a drop, you will have to use the IDataObject interface to extract any information you need about the data. Interesting project, I might take a look at it this weekend if I finish up with the IVSHelp80 interface I am working on.
Title: Re: Can not drag URLs from Internet Explorer and Drop them onto a UserForm
Post by: jj2007 on January 30, 2009, 11:28:45 PM
Quote from: LieseLover on January 30, 2009, 09:45:56 PM
Thx for yor reply.
It wasn't my aim to solve the Problem with an RichEdit I'd just like to drag the link on my
form and receive the Url when dropping it.

Greetz

Keep up the good spirit :thumbu
Why choose a simple solution (see attachment) if you can have fun with COM?

[attachment deleted by admin]
Title: Re: Can not drag URLs from Internet Explorer and Drop them onto a UserForm
Post by: ToutEnMasm on January 31, 2009, 07:00:58 AM

After a little search , i found the more simple soluce
A richedit control have a EM_AUTOURLDETECT message who made the url text acting as an url and appear as an url.
Use a sample richedit control (there is one in the masm32 package without bug) and test this.

Title: Re: Can not drag URLs from Internet Explorer and Drop them onto a UserForm
Post by: jj2007 on January 31, 2009, 08:34:57 AM
Quote from: ToutEnMasm on January 31, 2009, 07:00:58 AM

After a little search , i found the more simple soluce
A richedit control have a EM_AUTOURLDETECT message who made the url text acting as an url and appear as an url.
Use a sample richedit control (there is one in the masm32 package without bug) and test this.

Just add the bold line to the source posted above:
      mov hEdit, eax                     ; we have created a RichEdit control
      sm hEdit, EM_AUTOURLDETECT, 1, 0
However, I don't think it will solve the problem. What he needs is not a richedit control that generates an EN_LINK notification. He simply wants to get the URL. For doing that, you need to capture EN_CHANGE in the WM_COMMAND handler, grab the URL with WM_GETTEXT and clear the control. Very simple, but still, why waste time with simple solutions if you can spend a weekend with COM? :bg
Title: Re: Can not drag URLs from Internet Explorer and Drop them onto a UserForm
Post by: LieseLover on January 31, 2009, 09:02:10 AM
Quote from: jj2007 on January 31, 2009, 08:34:57 AM
..., but still, why waste time with simple solutions if you can spend a weekend with COM? :bg
Man I got the feeling you don't take me seriously  :lol but an RichEdit doesn't look good in a TrayBarIcon for example  :tdown

I simply want to get a handle for the Proc IDropTarget_Drop (see source)
In the Proc IDropTarget_DragEnter the Drag is recogniced by the Application and the Url (what is dragged) is also known but the
window doesen't accept that kind of Source showing the false cursor.
So in my opinion it's nessersary to change the GUID or something is that possible?

Greetz and thanks for helping
Title: Re: Can not drag URLs from Internet Explorer and Drop them onto a UserForm
Post by: jj2007 on January 31, 2009, 11:00:52 AM
Quote from: LieseLover on January 31, 2009, 09:02:10 AM
Quote from: jj2007 on January 31, 2009, 08:34:57 AM
..., but still, why waste time with simple solutions if you can spend a weekend with COM? :bg
Man I got the feeling you don't take me seriously  :lol but an RichEdit doesn't look good in a TrayBarIcon for example  :tdown

Yep that's right. Don't know if it would work with a TrayBarIcon... :dazzled:
Attached an advanced version of the UrlDropper.

[attachment deleted by admin]
Title: Re: Can not drag URLs from Internet Explorer and Drop them onto a UserForm
Post by: ToutEnMasm on January 31, 2009, 01:27:28 PM

To jj2007,
Your sample need a debugger,He crash on a drag drop of a link.
Title: Re: Can not drag URLs from Internet Explorer and Drop them onto a UserForm
Post by: ToutEnMasm on January 31, 2009, 01:38:56 PM


Quote
Man I got the feeling you don't take me seriously   but an RichEdit doesn't look good in a TrayBarIcon for example 

Seems here there is too many people needing help and laughing when someone try to help them.

I have no need of help and leave this post









Title: Re: Can not drag URLs from Internet Explorer and Drop them onto a UserForm
Post by: jj2007 on January 31, 2009, 04:44:17 PM
Quote from: ToutEnMasm on January 31, 2009, 01:27:28 PM

To jj2007,
Your sample need a debugger,He crash on a drag drop of a link.


Works perfectly for me, on Win XP SP2. Which OS are you using? Others having the same problem??
Title: Re: Can not drag URLs from Internet Explorer and Drop them onto a UserForm
Post by: ToutEnMasm on January 31, 2009, 05:15:35 PM

XP SP3 ,the two samples crash.
Title: Re: Can not drag URLs from Internet Explorer and Drop them onto a UserForm
Post by: jj2007 on January 31, 2009, 05:24:17 PM
Quote from: ToutEnMasm on January 31, 2009, 05:15:35 PM

XP SP3 ,the two samples crash.


Immediately? Does the dialog show? Crash only when dropping the URL? I am getting curious...
Title: Re: Can not drag URLs from Internet Explorer and Drop them onto a UserForm
Post by: ToutEnMasm on January 31, 2009, 05:30:46 PM

(a9c.d0): Access violation - code c0000005 (first chance)
First chance exceptions are reported before any exception handling.
This exception may be expected and handled.
eax=7ffde000 ebx=00000000 ecx=40000000 edx=00000000 esi=74dc0e66 edi=0012ec44
eip=74dc0e66 esp=0012ebe0 ebp=0012ec08 iopl=0         nv up ei pl nz na po nc
cs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000             efl=00010202
<Unloaded_RichEd20.dll>+0x20e66:
74dc0e66 ??              ???
Title: Re: Can not drag URLs from Internet Explorer and Drop them onto a UserForm
Post by: jj2007 on January 31, 2009, 07:11:32 PM
I have added some error checking for the RichEdit LoadLibrary and CreateWindow invokes. At which point does it crash?

[attachment deleted by admin]