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

📄 windowtran.cpp

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

#include "stdafx.h"
#include "ImgGrabProc.h"
#include "WindowTran.h"

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

/////////////////////////////////////////////////////////////////////////////
// WindowTran dialog


WindowTran::WindowTran(CWnd* pParent /*=NULL*/)
	: CDialog(WindowTran::IDD, pParent)
{
	m_orgPoint.x=50;
	m_orgPoint.y =270;
	m_Low=10;
	//{{AFX_DATA_INIT(WindowTran)
	m_WindowWidth = 100;
	//}}AFX_DATA_INIT
}


void WindowTran::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(WindowTran)
	DDX_Text(pDX, IDC_EDIT1, m_WindowWidth);
	DDV_MinMaxInt(pDX, m_WindowWidth, 1, 254);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(WindowTran, CDialog)
	//{{AFX_MSG_MAP(WindowTran)
	ON_WM_PAINT()
	ON_EN_CHANGE(IDC_EDIT1, OnChangeEdit1)
	ON_WM_HSCROLL()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// WindowTran message handlers

void WindowTran::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");
	//Draw Transform Line
	CPen m_Drawpen;
	m_Drawpen.CreatePen (PS_SOLID,2,RGB(128,0,0));
	dc.SelectObject (&m_Drawpen);
	dc.MoveTo (m_orgPoint.x,m_orgPoint.y);
	dc.LineTo (m_orgPoint.x+m_pSlider1->GetPos(),m_orgPoint.y);
	dc.LineTo (m_orgPoint.x+m_pSlider1->GetPos(),m_orgPoint.y-m_pSlider1->GetPos());
	dc.LineTo (m_orgPoint.x+m_pSlider1->GetPos ()+m_WindowWidth,m_orgPoint.y-m_pSlider1->GetPos()-m_WindowWidth);
	dc.LineTo (m_orgPoint.x+m_pSlider1->GetPos ()+m_WindowWidth,m_orgPoint.y-255);
	dc.LineTo (m_orgPoint.x+255,m_orgPoint.y-255);
	dc.SelectObject (&m_pOldpen);
	//write lowpoint
	CString stringLow;
	stringLow.Format ("%d,%d",m_Low,m_Low);
	dc.TextOut (m_orgPoint.x+m_pSlider1->GetPos(),m_orgPoint.y-m_pSlider1->GetPos(),stringLow);
	//write hightPoint
	CString stringHigh;
	stringHigh.Format ("%d,%d",m_Low+m_WindowWidth,m_Low+m_WindowWidth);
	dc.TextOut(m_orgPoint.x+m_pSlider1->GetPos ()+m_WindowWidth,m_orgPoint.y-m_pSlider1->GetPos()-m_WindowWidth,stringHigh);
	// Do not call CDialog::OnPaint() for painting messages
}

BOOL WindowTran::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	m_pSlider1=(CSliderCtrl*)GetDlgItem(IDC_SLIDER1);
	m_pSlider1->SetRange (0,254);
	m_pSlider1->SetPos (10);
	m_pSlider1->SetTic (20);
	m_pSlider1->SetPageSize (40);
	m_pSlider1->SetLineSize (1);
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}



void WindowTran::OnChangeEdit1() 
{	
	int orgData=m_WindowWidth;//save orgdata
	UpdateData(TRUE);
	if (m_WindowWidth+m_pSlider1->GetPos ()>255){
		AfxMessageBox("The window has exceet 255");
		m_WindowWidth=orgData;
		UpdateData(FALSE);
	}
	CRect rect(m_orgPoint.x ,m_orgPoint.y-256,m_orgPoint.x+256,m_orgPoint.y+5);
	InvalidateRect(rect);

	// TODO: If this is a RICHEDIT control, the control will not
	// send this notification unless you override the CDialog::OnInitDialog()
	// function and call CRichEditCtrl().SetEventMask()
	// with the ENM_CHANGE flag ORed into the mask.
	
	// TODO: Add your control notification handler code here
	
}

void WindowTran::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) 
{
	int orgData=m_Low;
	m_Low=m_pSlider1->GetPos ();
	if (m_WindowWidth+m_pSlider1->GetPos ()>255){
		AfxMessageBox("The window has exceet 255");
		m_pSlider1->SetPos (orgData);
	}
	CRect rect(m_orgPoint.x ,m_orgPoint.y-256,m_orgPoint.x+256,m_orgPoint.y+5);
	InvalidateRect(rect);
	CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
}

⌨️ 快捷键说明

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