// ChPicFrm.cpp : implementation file
//

#include "stdafx.h"
#include "Client.h"
#include "ChPicFrm.h"
#include "ChatDlg.h"

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

/////////////////////////////////////////////////////////////////////////////
// CChPicFrm

IMPLEMENT_DYNCREATE(CChPicFrm, CFrameWnd)

CChPicFrm::CChPicFrm()
{
	Create(NULL , "PicToolBar" 
	,  WS_POPUP |WS_VISIBLE  ,  CRect( 20 , 20 , 315 , 40 )  
	, NULL , NULL , WS_EX_TOPMOST );
}

CChPicFrm::CChPicFrm( CRect m , CChatDlg* m_pin )
{
	Create(NULL , "PicToolBar" 
		,  WS_POPUP |WS_VISIBLE  ,  m
		, (CWnd *)m_pin , NULL , WS_EX_TOPMOST );

	m_pMainDlg = m_pin;
}

CChPicFrm::~CChPicFrm()
{
}


BEGIN_MESSAGE_MAP(CChPicFrm, CFrameWnd)
	//{{AFX_MSG_MAP(CChPicFrm)
	ON_WM_CREATE()
	ON_WM_KILLFOCUS()
	//}}AFX_MSG_MAP
	ON_COMMAND_RANGE(ID_BUTTON32771 , ID_BUTTON32785, OnFaceSelect)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CChPicFrm message handlers

int CChPicFrm::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
		return -1;
	
	// TODO: Add your specialized creation code here
	m_wndToolBar.Create(this ,  WS_CHILD | WS_VISIBLE| CBRS_TOP | CBRS_TOOLTIPS  | CBRS_SIZE_FIXED);
	m_wndToolBar.LoadToolBar(IDR_MSGPIC);
	for (int i = 4; i < 15; i += 5)
	{
		UINT nStyle = m_wndToolBar.GetButtonStyle(i);
		nStyle |= TBBS_WRAPPED;
		m_wndToolBar.SetButtonStyle( i, nStyle );
	}
	m_wndToolBar.EnableDocking(CBRS_ALIGN_TOP);
	ShowWindow( SW_HIDE );
	
	return 0;
}

void CChPicFrm::OnKillFocus(CWnd* pNewWnd) 
{
	CFrameWnd::OnKillFocus(pNewWnd);
	
	// TODO: Add your message handler code here
	ShowWindow( SW_HIDE );

}

void CChPicFrm::OnFaceSelect(UINT nID)
{
	int nFace = nID - ID_BUTTON32771;
	m_pMainDlg->FacePicSelect( nFace );
}
