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

📄 linerdlg.cpp

📁 《医学图象的远程传输系统》
💻 CPP
字号:
// LinerDlg.cpp : implementation file
//

#include "stdafx.h"
#include "ImgGrabProc.h"
#include "LinerDlg.h"

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

#define DotCalculate(a,x,b) (a*x+b)
/////////////////////////////////////////////////////////////////////////////
// LinerDlg dialog


LinerDlg::LinerDlg(CWnd* pParent /*=NULL*/)
	: CDialog(LinerDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(LinerDlg)
	m_fa = 0;
	m_fb = 0;
	//}}AFX_DATA_INIT
	m_pSliderA=0;
	m_pSliderB=0;
	m_orgPoint.x=50;
	m_orgPoint.y =270;
	m_fa=1;
	m_fb=-100;
}


void LinerDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(LinerDlg)
	DDX_Text(pDX, IDC_EDIT1, m_fa);
	DDX_Text(pDX, IDC_EDIT2, m_fb);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(LinerDlg, CDialog)
	//{{AFX_MSG_MAP(LinerDlg)
	ON_WM_PAINT()
	ON_WM_HSCROLL()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// LinerDlg message handlers

BOOL LinerDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	m_pSliderA=(CSliderCtrl*)GetDlgItem(IDC_SLIDER1);
	m_pSliderA->SetRange (-2,10);
	m_pSliderA->SetPos (1);
	m_pSliderA->SetTicFreq (1);
	m_pSliderA->SetPageSize (1);
	m_pSliderA->SetLineSize (0.5);
	m_pSliderB=(CSliderCtrl*)GetDlgItem(IDC_SLIDER2);	
	m_pSliderB->SetRange (-255,255);
	m_pSliderB->SetPos (-100);
	m_pSliderB->SetTicFreq (30);
	m_pSliderB->SetPageSize (20);
	m_pSliderB->SetLineSize (5);

	//delete &m_Newpen;
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void LinerDlg::OnPaint() 
{
	CPaintDC dc(this); // device context for painting
	CPen m_Newpen;
	CPen* m_pOldpen;
	m_Newpen.CreatePen (PS_SOLID,2,RGB(0,0,0));
	m_pOldpen=dc.SelectObject (&m_Newpen);
	dc.MoveTo (m_orgPoint.x,m_orgPoint.y);
	dc.LineTo (m_orgPoint.x,m_orgPoint.y-255);
	dc.MoveTo (m_orgPoint.x,m_orgPoint.y);
	dc.LineTo (m_orgPoint.x +255,m_orgPoint.y);
	dc.SetBkMode (TRANSPARENT);
	dc.TextOut (m_orgPoint.x +253,m_orgPoint.y-8,">");
	dc.TextOut (m_orgPoint.x-3,m_orgPoint.y-263,"^");
	dc.TextOut (m_orgPoint.x-5,m_orgPoint.y+5,"0");  
	dc.TextOut (m_orgPoint.x +250,m_orgPoint.y +5,"255");
	dc.TextOut (m_orgPoint.x -25,m_orgPoint.y-263,"255");
	dc.SelectObject (&m_pOldpen);
	for (int i=0;i<255;i++){
		if (DotCalculate(m_pSliderA->GetPos(),i,m_pSliderB->GetPos())<256&&
			DotCalculate(m_pSliderA->GetPos(),i,m_pSliderB->GetPos())>0){
			
		dc.MoveTo (m_orgPoint.x+i,m_orgPoint.y-
			DotCalculate(m_pSliderA->GetPos(),i,m_pSliderB->GetPos()));
		dc.LineTo (m_orgPoint.x+i+1,m_orgPoint.y-
			DotCalculate(m_pSliderA->GetPos(),i+1,m_pSliderB->GetPos()));
		}
	}
}

void LinerDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) 
{	
	m_fa=m_pSliderA->GetPos ();
	m_fb=m_pSliderB->GetPos ();
	UpdateData(FALSE); 
	CRect rect(m_orgPoint.x ,m_orgPoint.y-256,m_orgPoint.x+256,m_orgPoint.y);
	InvalidateRect(rect);
	CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
}

⌨️ 快捷键说明

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