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

📄 sitelist.cpp

📁 网络图片收集软件
💻 CPP
字号:
// SiteList.cpp : implementation file
//

#include "stdafx.h"
#include "image.h"
#include "SiteList.h"
#include "Option.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif


/////////////////////////////////////////////////////////////////////////////
// CSiteList

CSiteList::CSiteList()
{
}

CSiteList::~CSiteList()
{
}


BEGIN_MESSAGE_MAP(CSiteList, CListCtrl)
	//{{AFX_MSG_MAP(CSiteList)
	ON_NOTIFY_REFLECT(NM_DBLCLK, OnDblclk)
	ON_NOTIFY_REFLECT(NM_RCLICK, OnRclick)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CSiteList message handlers



void CSiteList::OnDblclk(NMHDR* pNMHDR, LRESULT* pResult) 
{
	// TODO: Add your control notification handler code here
	CPoint point;
	CString str;
	int i;
	UINT uFlags;
	GetCursorPos(&point);
	ScreenToClient(&point);
	if(point.x>20)
		point.x=20;
	i=HitTest(point,&uFlags);
	//i为选中的项的索引
	m_pDoc->m_siteinfo[i].bdownload=!m_pDoc->m_siteinfo[i].bdownload;
	if(m_pDoc->m_siteinfo[i].bdownload)
	{
		SetItem(i,0,LVIF_TEXT,"是",-1,0,0,0);
		str.Format(_T("update log set bdownload=1 where sitename='%s'"),m_pDoc->m_siteinfo[i].sitename);
	}
	else
	{
		SetItem(i,0,LVIF_TEXT,"否",-1,0,0,0);
		str.Format(_T("update log set bdownload=0 where sitename='%s'"),m_pDoc->m_siteinfo[i].sitename);
		
	}
	//m_pDoc->m_siteinfo.RemoveAt(i,1);
	//DeleteItem(i);
	CImageApp * app=(CImageApp *)AfxGetApp();
	//str.Format(_T(""),
	app->m_db.ExecuteSQL(str);




	
	
	*pResult = 0;
}


void CSiteList::OnRclick(NMHDR* pNMHDR, LRESULT* pResult) 
{
	// TODO: Add your control notification handler code here
	//在此消息处理中对选中的项进行编辑
	CPoint point;
	//CString str;
	Option option;
	int i;
	UINT uFlags;
	GetCursorPos(&point);
	ScreenToClient(&point);
	if(point.x>20)
		point.x=20;
	i=HitTest(point,&uFlags);
	
	if(i==-1)
		return ;

	//i为选中的项的索引
	
	option.bDownload=m_pDoc->m_siteinfo[i].bdownload;
	option.date=m_pDoc->m_siteinfo[i].lasttime;
	option.image_type=m_pDoc->m_siteinfo[i].imagetype;
	option.max_length=m_pDoc->m_siteinfo[i].max_height;
	option.max_level=m_pDoc->m_siteinfo[i].max_level;
	option.max_width=m_pDoc->m_siteinfo[i].max_width;
	option.min_length=m_pDoc->m_siteinfo[i].min_height;
	option.min_width=m_pDoc->m_siteinfo[i].min_width;
	option.priority.Format(_T("%d"),m_pDoc->m_siteinfo[i].priority);
	option.sitename=m_pDoc->m_siteinfo[i].sitename;
	option.url=m_pDoc->m_siteinfo[i].url;
	option.exclusive_level=m_pDoc->m_siteinfo[i].m_exclusive_level;
	
	COption dlg(&option);
	int nResponse=dlg.DoModal();
	if(nResponse==IDOK)
	{
		CString str;

		//对内存中的内容进行修改		
		m_pDoc->m_siteinfo[i].bdownload=option.bDownload;
		m_pDoc->m_siteinfo[i].lasttime=option.date;
		m_pDoc->m_siteinfo[i].imagetype=(short)option.image_type;
		m_pDoc->m_siteinfo[i].max_height=option.max_length;
		m_pDoc->m_siteinfo[i].max_level=option.max_level;
		m_pDoc->m_siteinfo[i].max_width=option.max_width;
		m_pDoc->m_siteinfo[i].min_height=option.min_length;
		m_pDoc->m_siteinfo[i].min_width=option.min_width;
		m_pDoc->m_siteinfo[i].priority=atoi(option.priority);
		//m_pDoc->m_siteinfo[i].sitename=option.sitename;
		m_pDoc->m_siteinfo[i].url=option.url;
		m_pDoc->m_siteinfo[i].m_exclusive_level=option.exclusive_level;

		//现在对数据库中的东西进行修改.
		//把修改后的内容放入数据库中
		str.Format(_T("update log set sitename='%s', url='%s',lasttime=%s,priority=%d,imagetype=%d,min_height=%d,max_height=%d,min_width=%d,max_width=%d,bdownload=%d,max_level=%d,exclusive_level=%d where sitename='%s'"),
			option.sitename,option.url,option.date.Format("%Y-%m-%d"),atoi(option.priority),option.image_type,option.min_length,option.max_length,option.min_width,option.max_width,option.bDownload,option.max_level,option.exclusive_level,m_pDoc->m_siteinfo[i].sitename);
		CImageApp * app=(CImageApp *)AfxGetApp();
		app->m_db.ExecuteSQL(str);

		m_pDoc->m_siteinfo[i].sitename=option.sitename;


		//对列表的外观进行修改
		if(option.bDownload)
			SetItem(i,0,LVIF_TEXT,"是",-1,0,0,0);
		else
			SetItem(i,0,LVIF_TEXT,"否",-1,0,0,0);

		SetItem(i,1,LVIF_TEXT,option.sitename,-1,0,0,0);
		SetItem(i,2,LVIF_TEXT,option.url,-1,0,0,0);
		SetItem(i,3,LVIF_TEXT,option.date.Format("%Y-%m-%d"),-1,0,0,0);		
		
		switch(m_pDoc->m_siteinfo[i].priority)
		{
		case 1:
			str="*";
			break;
		case 2:
			str="**";
			break;
		case 3:
			str="***";
			break;
		case 4:
			str="****";
			break;
		case 5:
			str="*****";
			break;
		default:
			str="error";
		}
		SetItem(i,6,LVIF_TEXT,str,-1,0,0,0);
		
		str.Format(_T("%d"),option.image_type);
		SetItem(i,7,LVIF_TEXT,str,-1,0,0,0);

		str.Format(_T("%d"),option.min_length);
		SetItem(i,8,LVIF_TEXT,str,-1,0,0,0);
		
		str.Format(_T("%d"),option.max_length);
		SetItem(i,9,LVIF_TEXT,str,-1,0,0,0);
		
		str.Format(_T("%d"),option.min_width);
		SetItem(i,10,LVIF_TEXT,str,-1,0,0,0);
		
		str.Format(_T("%d"),option.max_width);
		SetItem(i,11,LVIF_TEXT,str,-1,0,0,0);
		
		str.Format(_T("%d"),option.max_level);
		SetItem(i,12,LVIF_TEXT,str,-1,0,0,0);

		str.Format(_T("%d"),option.exclusive_level);
		SetItem(i,13,LVIF_TEXT,str,-1,0,0,0);


		
	}
	else if(nResponse==10)
	{
		//现在将要进行删除操作自己定义的返回值确定了结果
		m_pDoc->m_siteinfo.RemoveAt(i);
		DeleteItem(i);
	}
	
	*pResult = 0;
}

⌨️ 快捷键说明

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