// testdoc.cpp : implementation of the CTestDoc class
//

#include "stdafx.h"
#include "test.h"

#include "testdoc.h"

#include "..\acroauto.h"

#ifdef _DEBUG
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CTestDoc

IMPLEMENT_DYNCREATE(CTestDoc, CDocument)

BEGIN_MESSAGE_MAP(CTestDoc, CDocument)
	//{{AFX_MSG_MAP(CTestDoc)
	ON_COMMAND(ID_AUTOMATION_TEST, OnAutomationTest)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CTestDoc construction/destruction

CTestDoc::CTestDoc()
{
	// TODO: add one-time construction code here
}

CTestDoc::~CTestDoc()
{
}

BOOL CTestDoc::OnNewDocument()
{
	if (!CDocument::OnNewDocument())
		return FALSE;

	// TODO: add reinitialization code here
	// (SDI documents will reuse this document)

	return TRUE;
}

/////////////////////////////////////////////////////////////////////////////
// CTestDoc serialization

void CTestDoc::Serialize(CArchive& ar)
{
	if (ar.IsStoring())
	{
		// TODO: add storing code here
	}
	else
	{
		// TODO: add loading code here
	}
}

/////////////////////////////////////////////////////////////////////////////
// CTestDoc diagnostics

#ifdef _DEBUG
void CTestDoc::AssertValid() const
{
	CDocument::AssertValid();
}

void CTestDoc::Dump(CDumpContext& dc) const
{
	CDocument::Dump(dc);
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CTestDoc commands

void CTestDoc::OnAutomationTest()
{
	HACROAUTO hAcroAuto = AcroAutoInitialize();
	if (!hAcroAuto) return;
	HACROAPP hAcroApp = AcroAppNew();
	if (!hAcroApp) goto done;
	{
		AcroAppShow(hAcroApp);
		
		HACRORECT hAcroRect = AcroAppGetFrame(hAcroApp);
		AfxMessageBox("Please move the Acrobat window so we\n can move it back :)");
		BOOL bOk = AcroAppSetFrame(hAcroApp, hAcroRect);
			
		LPCSTR szLanguage = AcroAppGetLanguage(hAcroApp);
		AfxMessageBox(szLanguage);
			                        
		// AcroAppExit(hAcroApp);
		AcroRectDelete(hAcroRect);
		AcroAppDelete(hAcroApp);
	}
done:
	AcroAutoUninitialize(hAcroAuto);
	return;
}
