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

📄 page1.cpp

📁 上位机磁盘mass storage传输应用
💻 CPP
字号:
// Page1.cpp : implementation file
//

#include "stdafx.h"
#include "SDisk.h"
#include "Page1.h"
#include "SDiskDlg.h"
#include "SDUsbMassStorage.h"
#include "GUIDs.h"
//CBWDATA FORMATLASTBLOCK={00, 00, 00, 0x7c, 0xE0, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
extern DWORD DISK0SECTORS;//by derek

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

/////////////////////////////////////////////////////////////////////////////
// CPage1 property page

IMPLEMENT_DYNCREATE(CPage1, CPropertyPage)

CPage1::CPage1() : CPropertyPage(CPage1::IDD)
{
	//{{AFX_DATA_INIT(CPage1)
	m_Format = FALSE;
	m_ChangePW = FALSE;
	m_Area1 = 0.0f;
	m_Area2 = 0.0f;

	TotalSize = 0.0f;
	TotalSectors = 0;
	m_Sectors1 = m_Sectors2 =0;

	m_OldPW = _T("");
	m_NewPW = _T("");
	m_NewPWCheck = _T("");
	//}}AFX_DATA_INIT
}

CPage1::~CPage1()
{
}

void CPage1::DoDataExchange(CDataExchange* pDX)
{
	CPropertyPage::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CPage1)
	DDX_Control(pDX, IDOK2, m_OK2);
	DDX_Control(pDX, IDC_SLIDER1, m_Slider1);
	DDX_Check(pDX, IDC_CHECK1, m_Format);
	DDX_Check(pDX, IDC_CHECK2, m_ChangePW);
	DDX_Text(pDX, IDC_EDIT1, m_Area1);
	DDX_Text(pDX, IDC_EDIT2, m_Area2);
	DDX_Text(pDX, IDC_EDIT3, m_OldPW);
	DDV_MaxChars(pDX, m_OldPW, 8);
	DDX_Text(pDX, IDC_EDIT4, m_NewPW);
	DDV_MaxChars(pDX, m_NewPW, 8);
	DDX_Text(pDX, IDC_EDIT5, m_NewPWCheck);
	DDV_MaxChars(pDX, m_NewPWCheck, 8);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CPage1, CPropertyPage)
	//{{AFX_MSG_MAP(CPage1)
	ON_NOTIFY(NM_OUTOFMEMORY, IDC_SLIDER1, OnOutofmemorySlider1)
	ON_NOTIFY(NM_CUSTOMDRAW, IDC_SLIDER1, OnCustomdrawSlider1)
	ON_NOTIFY(NM_RELEASEDCAPTURE, IDC_SLIDER1, OnReleasedcaptureSlider1)
	ON_EN_CHANGE(IDC_EDIT1, OnChangeEdit1)
	ON_BN_CLICKED(IDOK2, OnOk2)
	ON_BN_CLICKED(IDOK3, OnOk3)
	ON_WM_SHOWWINDOW()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CPage1 message handlers

void CPage1::OnOutofmemorySlider1(NMHDR* pNMHDR, LRESULT* pResult) 
{
	// TODO: Add your control notification handler code here
	
	*pResult = 0;
}

void CPage1::OnCustomdrawSlider1(NMHDR* pNMHDR, LRESULT* pResult) 
{
	// TODO: Add your control notification handler code here
	DWORD pos = m_Slider1.GetPos();
//	pos++;//Derek 11.21 修正一下
	if (pos < 2)
	{
		pos = 2;
		//return;
	}
	if (pos > 98)
	{
		pos = 100;
		//return;
	}
	m_Area1 = pos * TotalSize /100;
	m_Area2 = (100 - pos)* TotalSize / 100;
//#ifndef ADD_PARTITION
	m_Sectors1 = pos * TotalSectors /100;
	m_Sectors2 = TotalSectors - m_Sectors1;
/*#else
	m_Sectors1 = pos * (TotalSectors - DISK0SECTORS) /100;//by derek
	m_Sectors2 = TotalSectors - m_Sectors1 - DISK0SECTORS;
#endif*/
	UpdateData(0);
	
	*pResult = 0;
}

void CPage1::OnReleasedcaptureSlider1(NMHDR* pNMHDR, LRESULT* pResult) 
{
	// TODO: Add your control notification handler code here
	
	*pResult = 0;
}

void CPage1::OnCancel() 
{
	// TODO: Add extra cleanup here
	
	// CPropertyPage::OnCancel();
	CSDiskDlg *pSDiskDlg = (CSDiskDlg*)theApp.m_pMainWnd;
	pSDiskDlg->OnCancel();
}

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

BOOL CPage1::OnInitDialog() 
{
	CPropertyPage::OnInitDialog();
	
	// TODO: Add extra initialization here
	m_Slider1.SetLineSize(100);
	m_Slider1.SetPos(100);
	if (TotalSectors > 0)
		m_Slider1.SetPos(m_Sectors1*100 / TotalSectors);
	else
		m_Slider1.SetPos(100);
	UpdateData(0);
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CPage1::OnOK() 
{
	// TODO: Add extra validation here
	
	CPropertyPage::OnOK();
}

void CPage1::OnOk2() 
{
	// TODO: Add your control notification handler code here
	
}

void CPage1::OnOk3() 
{
	// TODO: Add your control notification handler code here
	
}

void CPage1::OnShowWindow(BOOL bShow, UINT nStatus) 
{
	CPropertyPage::OnShowWindow(bShow, nStatus);
	
	// TODO: Add your message handler code here
	
}

⌨️ 快捷键说明

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