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

📄 maindlg.cpp

📁 概述:数据的纵向收集
💻 CPP
字号:
// MainDlg.cpp : implementation of the CMainDlg class
//
/////////////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "resource.h"

#include "aboutdlg.h"
#include "MainDlg.h"

#include "Template.h"
#include "IniUtil.h"
#include ".\maindlg.h"

BOOL CMainDlg::PreTranslateMessage(MSG* pMsg)
{
	return CWindow::IsDialogMessage(pMsg);
}

BOOL CMainDlg::OnIdle()
{
	return FALSE;
}

LRESULT CMainDlg::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
	// center the dialog on the screen
	CenterWindow();

	// set icons
	HICON hIcon = (HICON)::LoadImage(_Module.GetResourceInstance(), MAKEINTRESOURCE(IDR_MAINFRAME), 
		IMAGE_ICON, ::GetSystemMetrics(SM_CXICON), ::GetSystemMetrics(SM_CYICON), LR_DEFAULTCOLOR);
	SetIcon(hIcon, TRUE);
	HICON hIconSmall = (HICON)::LoadImage(_Module.GetResourceInstance(), MAKEINTRESOURCE(IDR_MAINFRAME), 
		IMAGE_ICON, ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON), LR_DEFAULTCOLOR);
	SetIcon(hIconSmall, FALSE);

	// register object for message filtering and idle updates
	CMessageLoop* pLoop = _Module.GetMessageLoop();
	ATLASSERT(pLoop != NULL);
	pLoop->AddMessageFilter(this);
	pLoop->AddIdleHandler(this);

	UIAddChildWindowContainer(m_hWnd);

	//init ddx
	DoDataExchange(DDX_LOAD);

	//set timer
	m_hTimer = SetTimer(0x1001,1000);

	return TRUE;
}

LRESULT CMainDlg::OnAppAbout(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
	CAboutDlg dlg;
	dlg.DoModal();
	return 0;
}

LRESULT CMainDlg::OnOK(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
	// TODO: Add validation code 
	CloseDialog(wID);
	return 0;
}

LRESULT CMainDlg::OnCancel(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
	CloseDialog(wID);
	return 0;
}

void CMainDlg::CloseDialog(int nVal)
{
	DestroyWindow();
	::PostQuitMessage(nVal);
}

LRESULT CMainDlg::OnQuerystate(WORD wNotifyCode, WORD wID, HWND hWndCtl)
{
	m_iState = QueryStateEx((DWORD*)&m_iDone);
	DoDataExchange(DDX_LOAD);

	return 0;
}

LRESULT CMainDlg::OnResume(WORD wNotifyCode, WORD wID, HWND hWndCtl)
{
	Resume();
	return 0;
}

LRESULT CMainDlg::OnSuspend(WORD wNotifyCode, WORD wID, HWND hWndCtl)
{
	Suspend();
	return 0;
}

LRESULT CMainDlg::OnStop(WORD wNotifyCode, WORD wID, HWND hWndCtl)
{
	Stop();
	return 0;
}

LRESULT CMainDlg::OnStart(WORD wNotifyCode, WORD wID, HWND hWndCtl)
{
	DoDataExchange(DDX_SAVE);

	Start(m_iCid,m_iSid);
	return 0;
}

CMainDlg::CMainDlg(void)
: m_iCid(1)
, m_iSid(9999)
, m_iState(0)
, m_iDone(0)
{
	TCHAR lpszPath[MAX_PATH]={0};
	GetModuleFileName(0,lpszPath,MAX_PATH);
	PathRemoveFileSpec(lpszPath);
	PathAppend(lpszPath,DEFAULT_TEMPLATE_FILE_EX);
	if(!NIniUtil::FileExist(lpszPath))
	{
		DebugString("[CCrawlerMgr::AssignTask]","no template file");
		return;
	}

	CTemplate* objTemplate = CTemplate::Instance();

	objTemplate->SetPath(lpszPath);
	objTemplate->Parse();
	m_iSid = objTemplate->GetSid();

	delete objTemplate;

}

LRESULT CMainDlg::OnTimer(UINT id, TIMERPROC lpTimerProc)
{
	m_iState = QueryStateEx((DWORD*)&m_iDone);
	DoDataExchange(DDX_LOAD);

	return 0;
}

LRESULT CMainDlg::OnDestroy(void)
{
	//You should call SetMsgHandled(FALSE) or set bHandled = FALSE for the main window of your application
	if(m_hTimer)
		KillTimer(m_hTimer);
	m_hTimer=0;
	return 0;
}

LRESULT CMainDlg::OnDebug(WORD wNotifyCode, WORD wID, HWND hWndCtl)
{
	CPPDebug();

	return 0;
}

⌨️ 快捷键说明

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