#include "stdafx.h"
#include "MdispMFC.h"
#include "ChildFrm.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
static UINT indicators[] =
{
ID_INDICATOR_FRAMERATE,
ID_INDICATOR_SCALE,
ID_INDICATOR_MOUSE,
};
IMPLEMENT_DYNCREATE(CChildFrame, CMDIChildWnd)
BEGIN_MESSAGE_MAP(CChildFrame, CMDIChildWnd)
ON_WM_CREATE()
END_MESSAGE_MAP()
CChildFrame::CChildFrame()
{
}
CChildFrame::~CChildFrame()
{
}
BOOL CChildFrame::PreCreateWindow(CREATESTRUCT& cs)
{
return CMDIChildWnd::PreCreateWindow(cs);
}
#ifdef _DEBUG
void CChildFrame::AssertValid() const
{
CMDIChildWnd::AssertValid();
}
void CChildFrame::Dump(CDumpContext& dc) const
{
CMDIChildWnd::Dump(dc);
}
#endif
int CChildFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CMDIChildWnd::OnCreate(lpCreateStruct) == -1)
return -1;
if (!m_wndStatusBar.Create(this) ||
!m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT)))
{
TRACE0("Failed to create status bar\n");
return -1;
}
m_wndStatusBar.SetPaneInfo(0, ID_INDICATOR_FRAMERATE, SBPS_NORMAL, 140);
m_wndStatusBar.SetPaneInfo(1, ID_INDICATOR_SCALE, SBPS_NORMAL, 100);
m_wndStatusBar.SetPaneInfo(2, ID_INDICATOR_MOUSE, SBPS_NORMAL, 180);
return 0;
}
void CChildFrame::UpdateStatusBarWithFrameRate(MIL_DOUBLE CurrentRate)
{
CString strCurrentRate;
if(CurrentRate == M_INVALID)
{
strCurrentRate.Format(MIL_TEXT("Display Updates: Not Available"));
}
else
{
strCurrentRate.Format(MIL_TEXT("Display Updates: %.2f fps"),CurrentRate);
}
m_wndStatusBar.SetPaneText(0,strCurrentRate);
}
void CChildFrame::UpdateStatusBarWithScale(MIL_DOUBLE CurrentScaleX, MIL_DOUBLE CurrentScaleY)
{
CString strCurrentScale;
strCurrentScale.Format(MIL_TEXT("%.4f, %.4f"),CurrentScaleX, CurrentScaleY);
m_wndStatusBar.SetPaneText(1,strCurrentScale);
}
void CChildFrame::UpdateStatusBarWithMouse(MIL_INT DispPositionX, MIL_INT DispPositionY, MIL_DOUBLE BufPositionX, MIL_DOUBLE BufPositionY)
{
CString strMouse;
strMouse.Format(MIL_TEXT("M:(%d,%d)->(%.2f,%.2f)"),(MIL_INT)DispPositionX, (MIL_INT)DispPositionY,
BufPositionX, BufPositionY);
m_wndStatusBar.SetPaneText(2,strMouse);
}
CSize CChildFrame::GetStatusBarSize()
{
RECT statusBarRECT;
m_wndStatusBar.GetStatusBarCtrl().GetClientRect(&statusBarRECT);
CSize statusBarSize(statusBarRECT.right - statusBarRECT.left,
statusBarRECT.bottom - statusBarRECT.top);
return statusBarSize;
}