Class that Enables Drag '& Drop of Internet Links from IE to a List Control

GetLink sample image

Environment: VC6 , Window98

Using OLE Drag and Drop, this control enables you to drag and drop any link from Internet Explorer (IE) directly to a list control. You can even drag the icon from the IE address bar so that the current Web page's URL is inserted into the list control!

Here is sample list control that get the Internet link from Internet Explorer.


1. Insert Following Routine into the Main App.

BOOL CPerfectGetApp::InitInstance()
{
	CoInitialize(NULL);

    if (!AfxOleInit())
    {
        AfxMessageBox("Ole Initialization Failed");
        return FALSE;
    }

    .....

}


int CPerfectGetApp::ExitInstance() 
{
	CoUninitialize();
	
	return CWinApp::ExitInstance();
}


2. In the main dialog header file.

#include "GetList.h"		 

#define IDC_GET_LIST	4321		// define any constant. ;-)

class CPerfectGetDlg : public CResizingDialog
{

    ....

// Attributes
protected:
	CGetList m_ctrGetList;

    ....
}


3. In the main dialog cpp file.

////////////////////////
// OnCreate
///////////////////////
int CPerfectGetDlg::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{

	....

	
	// Create GetList control.
	m_ctrGetList.Create(
		LVS_REPORT | WS_VISIBLE | WS_CHILD,
			CRect( 10, 10 , 460, 200),	
			this, IDC_GET_LIST);

	m_ctrGetList.SetTextColor(RGB(255,255,255));
	m_ctrGetList.SetTextBkColor(RGB(69,83,103));
	m_ctrGetList.SetBkColor(RGB(69,83,103));


	// List Control Header Initializing.
	LV_COLUMN Lvc;

	Lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
	Lvc.fmt = LVCFMT_LEFT;
	
	// First Column.
	Lvc.pszText = (LPTSTR)(LPCSTR)"Internet Link";
	Lvc.cx = 440; 
	Lvc.iSubItem = 0;
	m_ctrGetList.InsertColumn(0, &Lvc);


	// Set Extended style.
	m_ctrGetList.SetExtendedStyle( 
		LVS_EX_ONECLICKACTIVATE |
		LVS_EX_FULLROWSELECT | 
		LVS_EX_UNDERLINEHOT | 
		LVS_EX_INFOTIP |
		LVS_EX_FLATSB  |
		LVS_EX_GRIDLINES |
		LVS_EX_CHECKBOXES 
		);
	
	...
}


4. Just use it. ;-)



If you drag any link to your new program, your new GetList object show the fully qualified URL.

Downloads

Download demo project - 21 Kb
Download source - 3 Kb


Comments

  • Good and easy sample

    Posted by Legacy on 06/18/2003 12:00am

    Originally posted by: A.Beug

    Thanks, the example I've been looking for days.
    Easy and helpful. Good work.

    Reply
  • great, thanks

    Posted by Legacy on 07/13/2001 12:00am

    Originally posted by: Keith Craigie

    good job, very useful

    Reply
  • how to get the caption of the url

    Posted by Legacy on 06/28/2001 12:00am

    Originally posted by: young

    I can get the address but how to get the caption of the url

    Reply
  • DOWNLOAD A PARTICULAR LINK

    Posted by Legacy on 04/15/2000 12:00am

    Originally posted by: venkat-sra

    How to download a particular link from a web page after drag & drop it ?  
    

    Reply
  • how to drag and drop picture's url

    Posted by Legacy on 03/16/2000 12:00am

    Originally posted by: Rain Huang

    some pictures have no links, but i want to get the link of the picture itself.
    for example: http://www.microsoft.com/logo.jpg
    NetVampire can, how can i do?

    Reply
  • Good, but…

    Posted by Legacy on 12/20/1999 12:00am

    Originally posted by: Cody

    This works well; however, it will put ANYTHING from Internet Explorer into the list box, including plain text. A good way to filter out text is to use the Shell LightWeight API function ::PathIsURL() to determine if it is a URL/link.

    Reply
Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Live Event Date: October 29, 2014 @ 11:00 a.m. ET / 8:00 a.m. PT Are you interested in building a cognitive application using the power of IBM Watson? Need a platform that provides speed and ease for rapidly deploying this application? Join Chris Madison, Watson Solution Architect, as he walks through the process of building a Watson powered application on IBM Bluemix. Chris will talk about the new Watson Services just released on IBM bluemix, but more importantly he will do a step by step cognitive …

  • Live Event Date: October 29, 2014 @ 1:00 p.m. ET / 10:00 a.m. PT It's well understood how critical version control is for code. However, its importance to DevOps isn't always recognized. The 2014 DevOps Survey of Practice shows that one of the key predictors of DevOps success is putting all production environment artifacts into version control. In this eSeminar, Gene Kim will discuss these survey findings and will share woeful tales of artifact management gone wrong! Gene will also share examples of how …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds