Скачиваний:
16
Добавлен:
01.05.2014
Размер:
5.13 Кб
Скачать
// MainFrm.cpp : implementation of the CMainFrame class
//

#include "stdafx.h"
#include "ConvexHull.h"

#include "StatusControl.h"
#include "statusslider.h" 

#include "MainFrm.h"

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


/////////////////////////////////////////////////////////////////////////////
// CMainFrame

IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWnd)

BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)
	//{{AFX_MSG_MAP(CMainFrame)
	ON_WM_CREATE()
	ON_COMMAND(ID_SSHORIZONTAL, OnSshorizontal)
	ON_COMMAND(ID_SSVERTICAL, OnSsvertical)
	ON_WM_SIZE()
	ON_NOTIFY(NM_CUSTOMDRAW, ID_INDICATOR_SLIDER, OnCustomdrawSlider1)
	ON_WM_CLOSE()
	ON_WM_PAINT()
	ON_WM_SHOWWINDOW()
	ON_WM_MOUSEMOVE()
	//}}AFX_MSG_MAP
	//ON_MESSAGE(WM_SLIDER_SEND, testMsg)
	//ON_MESSAGE(WM_SLIDER_SEND, CConvexHullView::OnSliderChange)
END_MESSAGE_MAP()

static UINT indicators[] =
{
	ID_SEPARATOR,           // status line indicator
	
	ID_INDICATOR_INFO,
	ID_INDICATOR_SLIDER,
#ifndef SIMPLIFICATION
	ID_INDICATOR_XXX,
	ID_INDICATOR_YYY,
#endif
	ID_INDICATOR_CAPS,
	ID_INDICATOR_NUM,
	ID_INDICATOR_SCRL,
};

/////////////////////////////////////////////////////////////////////////////
// CMainFrame construction/destruction

CMainFrame::CMainFrame()
{
	// TODO: add member initialization code here
	this->SetTitle("ConvexHull"); 

}

CMainFrame::~CMainFrame()
{

}

int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1){
		AfxMessageBox("-1");
		return -1;
	}
	
	if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
		| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
		!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
	{
		TRACE0("Failed to create toolbar\n");
		AfxMessageBox("Failed to create toolbar");
		return -1;      // fail to create
	}

	if (!m_wndStatusBar.Create(this)){
		AfxMessageBox("Failed to create status bar");
		return -1;      // fail to create
	}
	if (!m_wndStatusBar.SetIndicators(indicators,  sizeof(indicators)/sizeof(UINT)))
	{
		AfxMessageBox("Failed to set Indicators");
		return -1;      // fail to create
	}
	else{
		m_wndStatusBar.SetPaneStyle(1,SBPS_NOBORDERS);
		
		if(c_StatusSlider.m_hWnd == NULL){
			BOOL result = c_StatusSlider.Create(&m_wndStatusBar, ID_INDICATOR_SLIDER, WS_VISIBLE | PBS_SMOOTH);
			c_StatusSlider.SetRange(0,5,TRUE);
			c_StatusSlider.SetPos(0);
			c_StatusSlider.ShowWindow(TRUE);
		}

		this->statusInfo(); 

		
	}

	// TODO: Delete these three lines if you don't want the toolbar to
	//  be dockable
	m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
	EnableDocking(CBRS_ALIGN_ANY);
	DockControlBar(&m_wndToolBar);



	return 0;
}

BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
	if( !CMDIFrameWnd::PreCreateWindow(cs) )
		return FALSE;
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs

	return TRUE;
}

/////////////////////////////////////////////////////////////////////////////
// CMainFrame diagnostics

#ifdef _DEBUG
void CMainFrame::AssertValid() const
{
	CMDIFrameWnd::AssertValid();
}

void CMainFrame::Dump(CDumpContext& dc) const
{
	CMDIFrameWnd::Dump(dc);
}

#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CMainFrame message handlers


void CMainFrame::OnSshorizontal() 
{
	// TODO: Add your command handler code here
	//TRACE("H\n");
	
}

void CMainFrame::OnSsvertical() 
{
	// TODO: Add your command handler code here
	//TRACE("V\n");
	
}



void CMainFrame::OnSize(UINT nType, int cx, int cy) 
{
	CMDIFrameWnd::OnSize(nType, cx, cy);
	
	c_StatusSlider.Reposition();
}



int CMainFrame::GetDelay()
{
	
	if (IsWindow(c_StatusSlider.m_hWnd)) return c_StatusSlider.GetPos();
	
	return -10;
	//return (c_StatusSlider.m_hWnd  ? c_StatusSlider.GetPos(): 0); 
	//return 1;
}


void CMainFrame::OnCustomdrawSlider1(NMHDR* pNMHDR, LRESULT* pResult) 
{
	// TODO: Add your control notification handler code here
	//int i = c_StatusSlider.GetPos();
	//TRACE("%d\n",i);
	//SendMessage(WM_SLIDER_SEND, i,0);
	//
	
	//SendMessage(WM_SLIDER_SEND, i,0);
	
	*pResult = 0;

	
}


void CMainFrame::testMsg(){
	TRACE("fsdfs");
}

void CMainFrame::OnClose() 
{
	// TODO: Add your message handler code here and/or call default
	
	CMDIFrameWnd::OnClose();
}

void CMainFrame::statusInfo()
{
	if (::IsWindow(m_wndStatusBar.m_hWnd))
	m_wndStatusBar.SetWindowText("Описание находится в меню Помощь"); 
}

void CMainFrame::OnPaint() 
{
	CPaintDC dc(this); 
	this->statusInfo();
}

void CMainFrame::OnShowWindow(BOOL bShow, UINT nStatus) 
{
	CMDIFrameWnd::OnShowWindow(bShow, nStatus);
	this->statusInfo();
}

void CMainFrame::DoDataExchange(CDataExchange* pDX) 
{
	CMDIFrameWnd::DoDataExchange(pDX);
}

void CMainFrame::OnMouseMove(UINT nFlags, CPoint point) 
{
	this->statusInfo();
	
	CMDIFrameWnd::OnMouseMove(nFlags, point);
}
Соседние файлы в папке ConvexHull_1