// TagListDlg.cpp : implementation file
//

#include "stdafx.h"
#include "mw4gameed.h"
#include "TagListDlg.h"

/////////////////////////////////////////////////////////////////////////////
// CTagListDlg dialog


CTagListDlg::CTagListDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CTagListDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CTagListDlg)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
	isCreated = false;
}


void CTagListDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CTagListDlg)
	DDX_Control(pDX, IDC_LISTCTRL, m_ListCtrl);
	DDX_Control(pDX, IDC_TABCTRL, m_TabCtrl);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CTagListDlg, CDialog)
	//{{AFX_MSG_MAP(CTagListDlg)
	ON_LBN_DBLCLK(IDC_LISTCTRL, OnDblclkListctrl)
	ON_WM_SIZE()
	ON_NOTIFY(TCN_SELCHANGE, IDC_TABCTRL, OnSelchangeTabctrl)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CTagListDlg message handlers

void CTagListDlg::OnDblclkListctrl() 
{
	// TODO: Add your control notification handler code here
	GetParent()->SendMessage(WM_LBUTTONDBLCLK);
	//>OnLButtonDblClk(NULL,CPoint(0,0));
}

void CTagListDlg::OnSize(UINT nType, int cx, int cy) 
{
	CDialog::OnSize(nType, cx, cy);

	if(isCreated)
	{
		CRect prct,rct;
		m_TabCtrl.GetWindowRect(&rct);
		GetParent()->ScreenToClient(&rct);
		GetParent()->GetClientRect(&prct);
		m_TabCtrl.SetWindowPos(NULL,-1,-1,cx-rct.left*2,cy-rct.top*2,SWP_NOZORDER|SWP_NOREPOSITION|SWP_NOMOVE);	
		m_ListCtrl.GetWindowRect(&rct);
		m_TabCtrl.ScreenToClient(&rct);
		m_TabCtrl.GetClientRect(&prct);
		m_ListCtrl.SetWindowPos(NULL,-1, -1, prct.Width()-rct.left*2, prct.Height()-rct.top*2, SWP_NOZORDER|SWP_NOREPOSITION|SWP_NOMOVE); 
	}
}

BOOL CTagListDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	isCreated = true;
	isTabBoxDirty = true;
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CTagListDlg::OnSelchangeTabctrl(NMHDR* pNMHDR, LRESULT* pResult) 
{
	isTabBoxDirty = true;
	GetParent()->SendMessage(WM_PAINT);
	*pResult = 0;
}
