⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 myprogressctrl.cpp

📁 该程序是一个对于一个对于以某一直线为边界的两类进行分类
💻 CPP
字号:
// MyProgressCtrl.cpp : implementation file
//

#include "stdafx.h"
#include "线性分类器.h"
#include "MyProgressCtrl.h"

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

/////////////////////////////////////////////////////////////////////////////
// CMyProgressCtrl
CMyProgressCtrl::CMyProgressCtrl()
{
m_nPos = 0;
m_nStepSize = 1;
m_nMax = 100;
m_nMin = 0;
m_colFore =RGB(0,255,0);
m_nBarWidth = -1;
}

CMyProgressCtrl::~CMyProgressCtrl()
{
}


BEGIN_MESSAGE_MAP(CMyProgressCtrl, CProgressCtrl)
	//{{AFX_MSG_MAP(CMyProgressCtrl)
	ON_WM_PAINT()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CMyProgressCtrl message handlers

void CMyProgressCtrl::OnPaint() 
{
	//CPaintDC dc(this); // device context for painting
	
	// TODO: Add your message handler code here
	if (m_nMin >= m_nMax) 
        return;

   CRect LeftRect, RightRect, ClientRect;
   GetClientRect(ClientRect);

   double Fraction = (double)(m_nPos - m_nMin) / ((double)(m_nMax - m_nMin));

   
  CPaintDC dc(this); // device context for painting (if not double buffering)
dc.FillSolidRect(ClientRect, RGB(255,255,255));
  LeftRect = RightRect = ClientRect;

  LeftRect.right = LeftRect.left + (int)((LeftRect.right - LeftRect.left)*Fraction);
  
  dc.FillSolidRect(LeftRect, m_colFore);


	// Do not call CProgressCtrl::OnPaint() for painting messages
}

void CMyProgressCtrl::SetForeColour(COLORREF col)
{
m_colFore = col;
}

int CMyProgressCtrl::SetPos(int nPos)
{
if (!::IsWindow(m_hWnd))
return -1;

int nOldPos = m_nPos;
m_nPos = nPos;

CRect rect;
GetClientRect(rect);

double Fraction = (double)(m_nPos - m_nMin) / ((double)(m_nMax - m_nMin));
int nBarWidth = (int) (Fraction * rect.Width());

if (nBarWidth != m_nBarWidth)
{
m_nBarWidth = nBarWidth;
RedrawWindow();
}
return nOldPos;
}

int CMyProgressCtrl::StepIt()
{
return SetPos(m_nPos + m_nStepSize);
}

void CMyProgressCtrl::SetRange(int nLower, int nUpper)
{
m_nMax = nUpper;
m_nMin = nLower;
}

int CMyProgressCtrl::OffsetPos(int nPos)
{
return SetPos(m_nPos + nPos);
}

int CMyProgressCtrl::SetStep(int nStep)
{
int nOldStep = nStep;
m_nStepSize = nStep;
return nOldStep;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -