// HelpText.cpp : implementation file
//

#include "stdafx.h"
#include "resource.h"
#include "HelpText.h"

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

/////////////////////////////////////////////////////////////////////////////
// CHelpText dialog


CHelpText::CHelpText(CWnd* pParent /*=NULL*/)
	: CaplTranslateDialog(CHelpText::IDD, pParent)
{
	//{{AFX_DATA_INIT(CHelpText)
	m_RichText = _T("");
	//}}AFX_DATA_INIT
}


void CHelpText::DoDataExchange(CDataExchange* pDX)
{
	CaplTranslateDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CHelpText)
	DDX_Control(pDX, IDC_RICH_TEXT, m_RichTextCtrl);
	DDX_Text(pDX, IDC_RICH_TEXT, m_RichText);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CHelpText, CaplTranslateDialog)
	//{{AFX_MSG_MAP(CHelpText)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CHelpText message handlers



static DWORD CALLBACK 
MyStreamInCallback(DWORD dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb)
{
	CaplDataBuf *dbuf= (CaplDataBuf *) dwCookie;
	*pcb=dbuf->m_Size-dbuf->GetCurPos();
	*pcb = *pcb>cb?cb:*pcb;
	dbuf->Read(pbBuff,*pcb);

	return 0;
}

BOOL CHelpText::OnInitDialog() 
{
	CaplTranslateDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	SetWindowText(m_header);
	EDITSTREAM es;

	m_dbuf.Reset();
	es.dwCookie = (DWORD) &m_dbuf;
	es.pfnCallback = MyStreamInCallback; 
	m_RichTextCtrl.StreamIn(SF_RTF, es);
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CHelpText::OnOK() 
{
	// TODO: Add extra validation here
	
	CaplTranslateDialog::OnOK();
}
