Добавил:
Studfiles2
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:Быстрый алгоритм разделения и слияния при помощи мостиков / source / ConvexHull / StatusControl
.cpp
#include "stdafx.h"
#include "StatusControl.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CStatusControl
CStatusControl::CStatusControl()
{
}
CStatusControl::~CStatusControl()
{
}
BEGIN_MESSAGE_MAP(CStatusControl, CWnd)
//{{AFX_MSG_MAP(CStatusControl)
// NOTE - the ClassWizard will add and remove mapping macros here.
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CStatusControls message handlers
BOOL CStatusControl::setup(CStatusBar * parent, UINT id, CRect & r)
{
int i = parent->CommandToIndex(id);
parent->GetItemRect(i, &r);
parent->SetPaneText(i, "");
// If the pane was not visible, GetItemRect has returned a
// (0, 0, 0, 0) rectangle. Attempting to create the control
// using this rectangle creates it, possibly of zero size,
// at the left of the status bar. We correct this by
// forcing it to be off the visible right end of the status
// bar. If the programmer properly handles the parent frame's
// OnSize method, when the control becomes visible it will
// move to the correct location.
if(r.IsRectEmpty())
{ /* offscreen */
CRect r1;
parent->GetWindowRect(&r1); // get parent width
r.left = r1.right + 1;
r.top = r1.top;
r.right = r1.right + 2;
r.bottom = r1.bottom;
return FALSE;
} /* offscreen */
return TRUE;
}
void CStatusControl::reposition(CWnd * wnd)
{
if(wnd == NULL || wnd->m_hWnd == NULL)
return;
UINT id = ::GetWindowLong(wnd->m_hWnd, GWL_ID);
CRect r;
// Note that because the control ID is the same as the
// pane ID, this actually works well enough that
// no special variable is required to obtain the
// pane index.
CStatusBar * parent = (CStatusBar *)wnd->GetParent();
int i = parent->CommandToIndex(id);
parent->GetItemRect(i, &r);
wnd->SetWindowPos(&wndTop, r.left, r.top, r.Width(), r.Height(), 0);
}
BOOL CStatusControl::Create(LPCTSTR classname, CStatusBar * parent, UINT id, DWORD style)
{
CRect r;
setup(parent, id, r);
return CWnd::Create(classname, NULL, style | WS_CHILD, r, parent, id);
}
void CStatusControl::Reposition()
{
reposition(this);
}
Соседние файлы в папке ConvexHull