
#include "stdafx.h"

#include "RegDumpViewCPU.h"
#include "BKErrMsgSys.h"

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

/////////////////////////////////////////////////////////////////////////////
// CRegDumpView
IMPLEMENT_DYNAMIC(CRegDumpViewCPU, CDockablePane)

CRegDumpViewCPU::CRegDumpViewCPU()
{
}

CRegDumpViewCPU::~CRegDumpViewCPU()
{
}

BEGIN_MESSAGE_MAP(CRegDumpViewCPU, CDockablePane)
	ON_WM_CREATE()
	ON_WM_SIZE()
	ON_WM_SETFOCUS()
	ON_WM_PAINT()
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// обработчики сообщений CWorkspaceBar

int CRegDumpViewCPU::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (CDockablePane::OnCreate(lpCreateStruct) == -1)
	{
		return -1;
	}

	if (!m_wndDlgex.Create(IDD_REGDUMP_CPU_DLG, this))
	{
		g_BKMsgBox.Show(g_pstrErrors[BK_ERROR_NOCREGDUMPDLGINIT]);
		TRACE0("Не удалось создать диалог Дамп регистров CPU\n");
		return -1;      // не удалось создать
	}

	AdjustLayout();
	return 0;
}

void CRegDumpViewCPU::OnSize(UINT nType, int cx, int cy)
{
	CDockablePane::OnSize(nType, cx, cy);
	AdjustLayout();
}

void CRegDumpViewCPU::OnSetFocus(CWnd *pOldWnd)
{
	CDockablePane::OnSetFocus(pOldWnd);
	m_wndDlgex.SetFocus();
}

void CRegDumpViewCPU::AdjustLayout()
{
	if (GetSafeHwnd())
	{
		CSize size(m_wndDlgex.GetMinSize());
		int c = (IsDocked()) ? GetSystemMetrics(SM_CYSMCAPTION) : 0;
		size.cy += c;
		SetMinSize(size);
		CRect rectClient;
		GetClientRect(rectClient);
		m_wndDlgex.SetWindowPos(nullptr, rectClient.left, rectClient.top, rectClient.Width(), rectClient.Height(), SWP_NOACTIVATE | SWP_NOZORDER);
	}

	CDockablePane::AdjustLayout();
}

void CRegDumpViewCPU::OnPaint()
{
	CPaintDC dc(this); // device context for painting

	// TODO: добавьте свой код обработчика сообщений
	// Не вызывать CDockablePane::OnPaint() для сообщений рисования
	if (IsVisible())
	{
		m_wndDlgex.Invalidate(FALSE);
	}
}
