📄 createchannelpage2.cpp
字号:
// CreateChannelPage2.cpp : implementation file
//
#include "stdafx.h"
#include "BeeReader.h"
#include "CreateChannelPage2.h"
#include "CreateChannelSheet.h"
#include "CreateGroupDlg.h"
#include "MainFrm.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CCreateChannelPage2 property page
IMPLEMENT_DYNCREATE(CCreateChannelPage2, CPropertyPage)
CCreateChannelPage2::CCreateChannelPage2(PGROUPNODE pParentNode ) : CPropertyPage(CCreateChannelPage2::IDD)
{
//{{AFX_DATA_INIT(CCreateChannelPage2)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
m_pParentNode = pParentNode;
}
CCreateChannelPage2::~CCreateChannelPage2()
{
}
void CCreateChannelPage2::DoDataExchange(CDataExchange* pDX)
{
CPropertyPage::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CCreateChannelPage2)
DDX_Control(pDX, IDC_TREE1, m_pTree);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CCreateChannelPage2, CPropertyPage)
//{{AFX_MSG_MAP(CCreateChannelPage2)
ON_BN_CLICKED(IDC_BUT_CREATEGROUP, OnButCreategroup)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CCreateChannelPage2 message handlers
BOOL CCreateChannelPage2::OnSetActive()
{
// TODO: Add your specialized code here and/or call the base class
CCreateChannelSheet* pSheet = (CCreateChannelSheet*)GetParent();
pSheet->SetWizardButtons( PSWIZB_BACK | PSWIZB_NEXT );
return CPropertyPage::OnSetActive();
}
BOOL CCreateChannelPage2::OnInitDialog()
{
CPropertyPage::OnInitDialog();
// TODO: Add extra initialization here
// Create the image list used by the tree control.
if ( !m_imageList.Create( 16, 16, ILC_COLOR24 | ILC_MASK, 1, 1 ) )
{
TRACE0("Failed to create image list.\n");
return -1;
}
// load the tree images bitmap and add it to the image list.
m_bitmap.LoadBitmap( IDB_IMGLIST_VIEW );
m_imageList.Add( &m_bitmap, RGB( 0x00,0xff,0x00 ) );
m_pTree.SetImageList( &m_imageList, TVSIL_NORMAL );
CCreateChannelSheet* pSheet = (CCreateChannelSheet*)GetParent();
ASSERT(pSheet);
pNewsGroup = pSheet->pNewsGroup;
CString szItem;
szItem = pNewsGroup->GetRootNode()->szNodeName;
HTREEITEM htItem = m_pTree.InsertItem( szItem );
m_pTree.SetItemState( htItem, TVIS_BOLD, TVIS_BOLD );
m_pTree.SetItemData( htItem,(DWORD)pNewsGroup->GetRootNode() );
if( !m_pParentNode || (m_pParentNode == pNewsGroup->GetRootNode()) )
m_pTree.SelectItem( htItem );
LoadGroup( pNewsGroup->GetRootNode()->pFirstChild,htItem);
m_pTree.Expand( htItem, TVE_EXPAND );
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CCreateChannelPage2::LoadGroup(PGROUPNODE pNode,HTREEITEM hParentItem)
{
PGROUPNODE pg = NULL;
HTREEITEM hItem;
if( !pNode ) return;
if( pNode->dwData == 0 )
hItem = m_pTree.InsertItem( pNode->szNodeName,2,3,hParentItem);
m_pTree.SetItemData(hItem,(DWORD)pNode);
if( m_pParentNode == pNode )
m_pTree.SelectItem( hItem );
if( pNode->pFirstChild )
{
LoadGroup( pNode->pFirstChild,hItem);
}
if( pNode->pNextSibling != pNode->pParentNode->pFirstChild )
LoadGroup( pNode->pNextSibling,hParentItem);
}
void CCreateChannelPage2::OnButCreategroup()
{
// TODO: Add your control notification handler code here
UpdateData( TRUE );
HTREEITEM htSelect = m_pTree.GetSelectedItem();
CCreateGroupDlg cgd( (PGROUPNODE)m_pTree.GetItemData(htSelect) );
if( cgd.DoModal() == IDOK )
{
PGROUPNODE pNode = pNewsGroup->Insert( cgd.GetParentNode(),NULL,cgd.GetGroupName(),0);
if( pNode )
{
HTREEITEM htItem;
htItem = FindItem(m_pTree.GetRootItem(),(DWORD)m_pParentNode);
if( htItem )
{
htItem = m_pTree.InsertItem( pNode->szNodeName,2,3,htItem);
m_pTree.SelectItem( htItem );
m_pParentNode = pNode;
}
CMainFrame* pMainWnd = (CMainFrame*)AfxGetMainWnd();
ASSERT(pMainWnd);
pMainWnd->GetNewsTree()->InsertGroup( cgd.GetParentNode(),pNode );
}
}
}
HTREEITEM CCreateChannelPage2::FindItem(HTREEITEM htParent, DWORD dwData)
{
if( htParent == NULL ) return NULL;
if( m_pTree.GetItemData( htParent ) == dwData ) return htParent;
if( m_pTree.ItemHasChildren(htParent) )
{
HTREEITEM hItem = m_pTree.GetChildItem(htParent);
HTREEITEM hItem1 = FindItem( hItem,dwData );
if( hItem1 == NULL )
{
while (hItem != NULL)
{
hItem = m_pTree.GetNextSiblingItem(hItem);
hItem1 = FindItem( hItem,dwData );
if( hItem1 ) return hItem1;
}
}
else return hItem1;
}
return NULL;
}
LRESULT CCreateChannelPage2::OnWizardNext()
{
// TODO: Add your specialized code here and/or call the base class
UpdateData(TRUE);
HTREEITEM htSelect = m_pTree.GetSelectedItem();
if( htSelect )
{
m_pParentNode = (PGROUPNODE)m_pTree.GetItemData(htSelect);
}
return CPropertyPage::OnWizardNext();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -