// MailBar.cpp : implementation file
//

#include "stdafx.h"
#include "BCGPOutlookDemo.h"
#include "MailBar.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CMailBar dialog


CMailBar::CMailBar()
{
	//{{AFX_DATA_INIT(CMailBar)
	//}}AFX_DATA_INIT
}


void CMailBar::DoDataExchange(CDataExchange* pDX)
{
	CBCGPDialogBar::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CMailBar)
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CMailBar, CBCGPDialogBar)
	//{{AFX_MSG_MAP(CMailBar)
	ON_WM_SIZE()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CMailBar message handlers

void CMailBar::AdjustWidth (int cx, UINT uiCtrlID)
{
	const int nMargin = 10;

	CWnd* pWnd = GetDlgItem (uiCtrlID);
	if (pWnd == NULL)
	{
		return;
	}

	CRect rect;
	pWnd->GetWindowRect (rect);
	ScreenToClient (rect);

	rect.right = cx - nMargin;

	pWnd->SetWindowPos (NULL, -1, -1, rect.Width (), rect.Height (),
		SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER);
}

void CMailBar::OnSize(UINT nType, int cx, int cy) 
{
	CBCGPDialogBar::OnSize(nType, cx, cy);

	AdjustWidth (cx, IDC_MAIL_TO_NAME);
	AdjustWidth (cx, IDC_MAIL_CC_NAME);
	AdjustWidth (cx, IDC_MAIL_SUBJECT_NAME);

}
