⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 watchclipboard.cpp

📁 类似flashget下载工具代码 本来想在完善了上传的
💻 CPP
字号:
// WatchClipBoard.cpp : implementation file
//

#include "stdafx.h"
#include "MyInsaneBT.h"
#include "WatchClipBoard.h"
#include "MainFrm.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CWatchClipBoard

CWatchClipBoard::CWatchClipBoard()
{
   m_cut = false;
}

CWatchClipBoard::~CWatchClipBoard()
{
}


BEGIN_MESSAGE_MAP(CWatchClipBoard, CWnd)
	//{{AFX_MSG_MAP(CWatchClipBoard)
	ON_WM_DESTROY()  
    ON_WM_DRAWCLIPBOARD()   
    ON_WM_CHANGECBCHAIN()  
    // NOTE - the ClassWizard will add and remove mapping macros here.
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CWatchClipBoard message handlers

BOOL CWatchClipBoard::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, 
							 DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, 
							 UINT nID, CCreateContext* pContext)
{    
	  lpszClassName = AfxRegisterWndClass(NULL);
	  BOOL r = CWnd::Create(lpszClassName,lpszWindowName,dwStyle,rect,pParentWnd,nID,pContext);
      //加入剪切版监视链
	  m_hWndNextCBViewer=SetClipboardViewer();
	  return r;
}
void CWatchClipBoard::OnChangeCbChain(HWND   hWndRemove,   HWND   hWndAfter)     
{   
  //   TODO:   监视链中窗口发生变动   
  if(m_hWndNextCBViewer==hWndRemove)   
     m_hWndNextCBViewer=hWndAfter;   
    
   //传WM_CHANGECBCHAIN给下一个监视窗口   
  ::SendMessage(m_hWndNextCBViewer,WM_CHANGECBCHAIN,(WPARAM)hWndRemove,(LPARAM)hWndAfter);   
}
//内容改变   
void CWatchClipBoard::OnDrawClipboard()     
{    
	//获得剪切板内容
	//打开剪贴板查询格式类型   
	CString sText;
	HGLOBAL hGlobal;		
	LPSTR lpszData;			
	unsigned long nSize;	
    if(OpenClipboard())   
	{   
	     	// Request a pointer to the text on the clipboard.
		hGlobal = GetClipboardData(CF_TEXT);

	
		if (hGlobal == NULL) return;

		lpszData = (LPSTR)GlobalLock(hGlobal);

		nSize = GlobalSize(hGlobal);
    
		sText = lpszData;
	
		GlobalUnlock(hGlobal);
        
	    ::CloseClipboard();
	
		ParseClipBoardText(sText);
	}   
    
	//传WM_DRAWCLIPBOARD给下一个监视窗口   
	::SendMessage(m_hWndNextCBViewer,WM_DRAWCLIPBOARD,0,0);   
 
}

void CWatchClipBoard::OnDestroy()
{

  //从监视链中删除本监视窗口   
  ChangeClipboardChain(m_hWndNextCBViewer);   
  CWnd::OnDestroy(); 
}

//解析剪切板内容
void CWatchClipBoard::ParseClipBoardText(CString ClipText)
{    
	 CString strServer,strObject;
	 DWORD dwServiceType;
	 unsigned short nPort;
	 CString tmp = ClipText.Left(4);
	 tmp.MakeUpper();
	 if(tmp.Left(4)!="HTTP")
		return;
     
	 BOOL rigth= AfxParseURL((LPCTSTR)ClipText,dwServiceType,strServer,strObject,nPort);
     //能解析出来的,发下载信息
	 CMainFrame* pFrm = (CMainFrame*)AfxGetApp()->m_pMainWnd;
	 if(rigth && pFrm!=NULL)
	 {
	 
	   PURL downURL = new URL();
       downURL->m_url = ClipText;
	   //下载通知 
	   
	   pFrm->SendMessage(WM_STASRTDOWN,0,(LPARAM)downURL);
	 }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -