selectexportarticles.cpp
来自「深入浅出Visual C++入门进阶与应用实例 随书光盘 作者 何志丹」· C++ 代码 · 共 115 行
CPP
115 行
// SelectExportArticles.cpp : implementation file
//
#include "stdafx.h"
#include "SelectExportArticles.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CSelectExportArticles dialog
CArticleElements CSelectExportArticles::s_Eles;
CSelectExportArticles::CSelectExportArticles(CMainData * pMainData,CWnd* pParent /*=NULL*/)
: CDialog(CSelectExportArticles::IDD, pParent)
{
m_pMainData = pMainData ;
//{{AFX_DATA_INIT(CSelectExportArticles)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CSelectExportArticles::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CSelectExportArticles)
DDX_Control(pDX, IDC_ARTICLE_TREE, m_treeCtrl);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CSelectExportArticles, CDialog)
//{{AFX_MSG_MAP(CSelectExportArticles)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSelectExportArticles message handlers
BOOL CSelectExportArticles::OnInitDialog()
{
CDialog::OnInitDialog();
if(NULL == m_pMainData)
return FALSE ;
CClassTreeNodeData * pNode = m_pMainData->GetCurTreeNode() ;
if(NULL == pNode )
return FALSE ;
HTREEITEM hRootItem = m_treeCtrl.InsertItem(pNode->m_strText);
for(int i = 0 ; i < pNode->m_arContentData.GetSize() ; i++ )
{
CArticleData * pArticle = pNode->m_arContentData[i] ;
if(NULL == pArticle)
continue ;
HTREEITEM hItem = m_treeCtrl.InsertItem(pArticle->m_topic,hRootItem);
m_treeCtrl.SetItemData(hItem,pArticle->m_ArticleID);
}
m_treeCtrl.Expand(hRootItem,TVE_EXPAND);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
CString CSelectExportArticles::GetArticleTexts(bool bSet , CMainData * pMainData)
{
if(bSet && NULL != pMainData)
{
CSelectExportArticles dlg(pMainData) ;
dlg.DoModal();//设置内容
}
return s_Eles.MakeTextWithCurBBSFormat() ;
}
void CSelectExportArticles::OnOK()
{
s_Eles.Empty() ;
if(NULL != m_pMainData)
{
CClassTreeNodeData * pNode = m_pMainData->GetCurTreeNode();
CString strDir = m_pMainData->GetDirOfCurTreeNode();
if(NULL != pNode)
{
HTREEITEM hRootItem = m_treeCtrl.GetRootItem();
HTREEITEM hChildItem = m_treeCtrl.GetChildItem(hRootItem);
while(NULL != hChildItem)
{
if(m_treeCtrl.GetCheck(hChildItem))
{
DWORD nID = m_treeCtrl.GetItemData(hChildItem);
CArticleData * pArticle = pNode->GetArticleData(nID);
if(NULL != pArticle)
{
CString strUrl = strDir + pArticle->m_FileName ;
s_Eles.AddLink(pArticle->m_topic,strUrl);
s_Eles += "\r\n";
}
}
hChildItem = m_treeCtrl.GetNextSiblingItem(hChildItem);
}
}
}
CDialog::OnOK();
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?