source code and executable file: Http://files.cnblogs.com/rainboy2010/ListCtrlLinkTest.zip
Clistctrllink is an extension class for CListCtrl that can contain Web links in Listctrl controls
How to use:
1. Add ListCtrlLink.h,ListCtrlLink.cpp,LinkItem.h,LinkItem.cpp files to your project project
2. Add the Listctrl control and associate it with the corresponding Clistctrllink variable
Clistctrllink M_listctrl;
3. Add the following code in OnInitDialog ():
M_listctrl.insertcolumn (0, _t ("Name"), Lvcfmt_left, -); M_listctrl.insertcolumn (1, _t (" Age"), Lvcfmt_left, -); M_listctrl.insertcolumn (2, _t (" Company"), Lvcfmt_left, -); M_listctrl.insertcolumn (3, _t ("Email"), Lvcfmt_left, $); M_listctrl.insertitem (0, _t ("Ana")); M_listctrl.setitemtext (0,1, _t (" -")); M_listctrl.setitemtext (0,2, _t ("Stanford"), _t ("http://www.stanford.edu")); M_listctrl.setitemtext (0,3, _t ("Unpublished"));
M_listctrl.insertitem (1, _t ("John")); M_listctrl.setitemtext (1,1, _t (" +")); M_listctrl.setitemtext (1,2, _t ("Yahoo"), _t ("http://www.yahoo.com")); M_listctrl.setitemtext (1,3, _t ("[email protected]"), _t ("Mailto:[email protected]")); M_listctrl.insertitem (2, _t ("Cassio")); M_listctrl.setitemtext (2,1, _t (" in")); M_listctrl.setitemtext (2,2, _t ("Symantec"), _t ("http://www.symantec.com")); M_listctrl.setitemtext (2,3, _t ("[Email protected]_email.org"), _t ("Mailto:[email protected]_email.org")); M_listctrl.insertitem (3, _t ("Peter")); M_listctrl.setitemtext (3,1, _t (" -")); M_listctrl.setitemtext (3,2, _t ("retired")); M_listctrl.setitemtext (3,3, _t ("[Email protected]_man.org"), _t ("Mailto:[email protected]_man.org"));
The prototype for Setitemtext is: BOOL setitemtext (int nitem, int nsubitem, LPCTSTR lpszText, lpctstr lpctszurl = NULL),
If Lpctszurl does not set a value, the hyperlink is not displayed, such as setting the value, the corresponding column is displayed as a hyperlink, and clicking on the hyperlink will execute the ShellExecute API call
CListCtrl with Web Links