//并保存Clipboard Viewer Chain中下一个窗口的句柄
m_hwndNextViewer = SetClipboardViewer();
}
void CMonitorUrlView::OnDestroy()
{
CListView::OnDestroy();
//从Clipboard Viewer Chain注销本窗口
ChangeClipboardChain(m_hwndNextViewer);
}
//Clipboard Viewer注销
void CMonitorUrlView::OnChangeCbChain(HWND hWndRemove, HWND hWndAfter)
{
//如果注销的Clipboard Viewer窗口是本窗口的下一个窗口,
//则修改本窗口保存的下一个窗口句柄,
CView::OnChangeCbChain(hWndRemove,hWndAfter);
if(hWndRemove == m_hwndNextViewer)
m_hwndNextViewer = hWndAfter;
}
//剪贴板内容变化,判断剪贴板中的内容是否为URL地址,如是则显示
void CMonitorUrlView::OnDrawClipboard()
{
CView::OnDrawClipboard();
unsigned int anFormats = {CF_TEXT};
unsigned int nFormat =
GetPriorityClipboardFormat(anFormats,sizeof(anFormats));
if(nFormat == CF_TEXT)
{
HGLOBAL hMem;
OpenClipboard();
if(hMem = ::GetClipboardData(CF_TEXT))
{
LPTSTR lpszText = (LPTSTR) GlobalLock(hMem);
CString strURL = lpszText;
strURL = strURL.SpanExcluding("\r\n");
if(strURL.Left(7).CompareNoCase("http://") == 0 ||
strURL.Left(6).CompareNoCase("ftp://") == 0 ||
strURL.Left(7).CompareNoCase("file://") == 0)
{
m_pListCtrl->InsertItem(0,lpszText);
}
GlobalUnlock(hMem);
}
CloseClipboard();
&