📄 createchannelpage3.cpp
字号:
// CreateChannelPage3.cpp : implementation file
//
#include "stdafx.h"
#include "BeeReader.h"
#include "CreateChannelPage3.h"
#include "CreateChannelSheet.h"
#include "MainFrm.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CCreateChannelPage3 property page
IMPLEMENT_DYNCREATE(CCreateChannelPage3, CPropertyPage)
CCreateChannelPage3::CCreateChannelPage3() : CPropertyPage(CCreateChannelPage3::IDD)
{
//{{AFX_DATA_INIT(CCreateChannelPage3)
m_szTitle = _T("");
m_szNote = _T("正在进行频道有效性检验...");
//}}AFX_DATA_INIT
hThread = NULL;
}
CCreateChannelPage3::~CCreateChannelPage3()
{
}
void CCreateChannelPage3::DoDataExchange(CDataExchange* pDX)
{
CPropertyPage::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CCreateChannelPage3)
DDX_Control(pDX, IDC_STATIC_NAME, m_pTitle);
DDX_Control(pDX, IDC_EDIT1, m_butTitle);
DDX_Control(pDX, IDC_PROGRESS1, m_Progress);
DDX_Text(pDX, IDC_EDIT1, m_szTitle);
DDX_Text(pDX, IDC_STATIC_NOTE, m_szNote);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CCreateChannelPage3, CPropertyPage)
//{{AFX_MSG_MAP(CCreateChannelPage3)
// NOTE: the ClassWizard will add message map macros here
//}}AFX_MSG_MAP
ON_MESSAGE( WM_RSS_READ_STATUS,OnReader)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CCreateChannelPage3 message handlers
DWORD WINAPI CheckThread(LPVOID pParam)
{
CCreateChannelSheet* pSheet = (CCreateChannelSheet*)pParam;
ASSERT(pSheet);
CoInitialize( NULL );
pSheet->pManager->GetReader()->Read( pSheet->pNewChannel,pSheet->pNewChannel->GetURL() );
CoUninitialize();
return 1;
}
BOOL CCreateChannelPage3::OnSetActive()
{
// TODO: Add your specialized code here and/or call the base class
CCreateChannelSheet* pSheet = (CCreateChannelSheet*)GetParent();
pSheet->SetWizardButtons( PSWIZB_DISABLEDFINISH );
pSheet->pNewChannel->SetCallbackHwnd( GetSafeHwnd() );
m_Progress.SetRange32(0,100);
DWORD dw;
if( !hThread )
hThread = ::CreateThread( NULL,0,CheckThread,(LPVOID)pSheet,0,&dw );
m_pTitle.ShowWindow(SW_HIDE);
m_butTitle.ShowWindow(SW_HIDE);
m_Progress.ShowWindow(SW_SHOW);
m_szNote = _T("正在进行频道有效性检验...");
return CPropertyPage::OnSetActive();
}
BOOL CCreateChannelPage3::OnWizardFinish()
{
// TODO: Add your specialized code here and/or call the base class
CCreateChannelSheet* pSheet = (CCreateChannelSheet*)GetParent();
pSheet->pNewChannel->SetCallbackHwnd( NULL );
pSheet->bFinish = TRUE;
CMainFrame* pMainWnd = (CMainFrame*)AfxGetMainWnd();
ASSERT(pMainWnd);
pMainWnd->CreateChannel( pSheet->page2.GetParentNode(), pSheet->pNewChannel );
HTREEITEM htItem = pMainWnd->GetNewsTree()->FindItem(pSheet->pNewChannel);
if( htItem )
pMainWnd->GetNewsTree()->SelectItem( htItem );
return CPropertyPage::OnWizardFinish();
}
LRESULT CCreateChannelPage3::OnReader(WPARAM wParam, LPARAM lParam)
{
CRSSChannel* pChannel = (CRSSChannel* )lParam;
switch( LOWORD(wParam) )
{
case SM_REFRESH_START:
{
m_Progress.SetPos( 5 );
break;
}
case SM_DOWNLOAD_START:
{
m_Progress.SetPos( 10 );
break;
}
case SM_DOWNLOAD_END:
{
m_Progress.SetPos( 40 );
break;
}
case SM_PRASEXML_START:
{
m_Progress.SetPos( 50 );
break;
}
case SM_PRASEXML_END:
{
m_Progress.SetPos( 80 );
break;
}
case SM_REFRESH_END:
{
if( pChannel )
{
m_Progress.SetPos(100);
m_szNote = _T("检验频道成功!");
m_szTitle = pChannel->GetTitle();
m_pTitle.ShowWindow(SW_SHOW);
m_butTitle.ShowWindow(SW_SHOW);
CCreateChannelSheet* pSheet = (CCreateChannelSheet*)GetParent();
pSheet->SetWizardButtons( PSWIZB_BACK | PSWIZB_FINISH );
break;
}
}
case SM_DOWNLOAD_FAILED:
case SM_LOADXML_FAILED:
case SM_PRASEXML_FAILED:
{
m_Progress.ShowWindow(SW_HIDE);
m_szNote = _T("检验频道失败,可能是提供的Rss Feed链接错误或者此链接不是有效的RSS格式。");
CCreateChannelSheet* pSheet = (CCreateChannelSheet*)GetParent();
pSheet->SetWizardButtons( PSWIZB_BACK | PSWIZB_DISABLEDFINISH);
break;
}
default:
break;
}
UpdateData(FALSE);
return 0;
}
LRESULT CCreateChannelPage3::OnWizardNext()
{
// TODO: Add your specialized code here and/or call the base class
if( hThread ) TerminateThread(hThread,0);
return CPropertyPage::OnWizardNext();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -