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

📄 dialogselecttest.cpp

📁 The Lite Evaluation/Demonstration Kit is intended to illustrate use of the AN3042. The AN3042 is c
💻 CPP
字号:
// DialogSelectTest.cpp : implementation file
//

#include "stdafx.h"
#include "testmenu.h"

#include "maskedBitmap.h"

#include "testmenuDoc.h"
#include "testmenuView.h"

#include "DialogSelectTest.h"
#include "MainFrm.h"

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


extern PROPERTIES g_properties;	// Global properties

/////////////////////////////////////////////////////////////////////////////
// CDialogSelectTest dialog


CDialogSelectTest::CDialogSelectTest(CWnd* pParent /*=NULL*/)
	: CDialog(CDialogSelectTest::IDD, pParent)
{
	//{{AFX_DATA_INIT(CDialogSelectTest)
//	m_check1 = FALSE;
//	m_check2 = FALSE;
	//}}AFX_DATA_INIT
}


void CDialogSelectTest::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDialogSelectTest)
	DDX_Control(pDX, IDC_SLIDER2, m_slider2);
	DDX_Control(pDX, IDC_SLIDER1, m_slider1);
	// DDX_Check(pDX, IDC_CHECK1, m_check1);
	// DDX_Check(pDX, IDC_CHECK2, m_check2);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CDialogSelectTest, CDialog)
	//{{AFX_MSG_MAP(CDialogSelectTest)
	ON_BN_CLICKED(IDC_RADIO1, OnRadio1)
	ON_BN_CLICKED(IDC_RADIO2, OnRadio2)
	ON_BN_CLICKED(IDC_RADIO3, OnRadio3)
	ON_BN_CLICKED(IDC_RADIO4, OnRadio4)
	ON_BN_CLICKED(IDC_RADIO5, OnRadio5)
	ON_BN_CLICKED(IDC_RADIO8, OnRadio8)
	ON_BN_CLICKED(IDC_RADIO9, OnRadio9)
	ON_BN_CLICKED(IDC_RADIO10, OnRadio10)
	ON_BN_CLICKED(IDC_RADIO11, OnRadio11)
	ON_BN_CLICKED(IDC_CHECK1, OnCheck1)
	ON_BN_CLICKED(IDC_CHECK2, OnCheck2)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

//	TB_THUMBTRACK (IDC_SLIDER1, OnThumbTrack_Slider1)


/////////////////////////////////////////////////////////////////////////////
// CDialogSelectTest message handlers

void CDialogSelectTest::SetTestNumButtons (enum MainMode mm, int testNumButton)
{
	if (mm == AUTOMATIC)
    {
		CheckRadioButton (IDC_RADIO1, IDC_RADIO2, IDC_RADIO1);      // Set the Automatic button

        // Grey out the Test Num buttons
        GetDlgItem(IDC_RADIO3) -> EnableWindow(FALSE);
        GetDlgItem(IDC_RADIO4) -> EnableWindow(FALSE);
        GetDlgItem(IDC_RADIO5) -> EnableWindow(FALSE);
    }
	else
    {
		CheckRadioButton (IDC_RADIO1, IDC_RADIO2, IDC_RADIO2);      // Set the Manual button

        // 'Black in' the Test Num buttons
        GetDlgItem(IDC_RADIO3) -> EnableWindow(TRUE);
        GetDlgItem(IDC_RADIO4) -> EnableWindow(TRUE);
        GetDlgItem(IDC_RADIO5) -> EnableWindow(TRUE);

        CheckRadioButton (IDC_RADIO3, IDC_RADIO5, testNumButton);   // Set the proper Test Num button
    }

    CheckRadioButton (IDC_RADIO8, IDC_RADIO11, g_properties.nDMAszButton);  // Set the correct DMA size button
}

	

void CDialogSelectTest::handleButtonTestNum(int button)
{
    AfxGetMainWnd()->SendMessage (WM_USER, 0, button);
	SetTestNumButtons(g_properties.eMainMode, g_properties.nTestNum);
}


////////////////////////////////////////////////////
//  Buttons associated with Mode grouping...
////////////////////////////////////////////////////

void CDialogSelectTest::OnRadio1() 
{
	g_properties.eMainMode = AUTOMATIC;
	handleButtonTestNum (g_properties.nTestNum);
}

void CDialogSelectTest::OnRadio2() 
{
	g_properties.eMainMode = MANUAL;
	handleButtonTestNum (IDC_RADIO3);   // Always start Manual mode with test number 1
}


////////////////////////////////////////////////////
//  Buttons associated with Test Number grouping...
////////////////////////////////////////////////////

void CDialogSelectTest::OnRadio3() 
{
	handleButtonTestNum(IDC_RADIO3);
}

void CDialogSelectTest::OnRadio4() 
{
	handleButtonTestNum(IDC_RADIO4);
}

void CDialogSelectTest::OnRadio5() 
{
	handleButtonTestNum(IDC_RADIO5);
}


void CDialogSelectTest::OnCheck1() 
{
    CButton* pCheck = (CButton*) GetDlgItem (IDC_CHECK1);
    g_properties.nEtoEto3042 = pCheck->GetCheck();

    AfxGetMainWnd()->SendMessage (WM_USER, 0, IDC_CHECK1);  // Tell the rest of the app the check mark changed.
}

void CDialogSelectTest::OnCheck2() 
{
	
}


////////////////////////////////////////////////////
//  Buttons associated with 'DMA length' grouping...
////////////////////////////////////////////////////

void CDialogSelectTest::handleButtonDMAsz(int button)
{
    
    g_properties.nDMAszButton = button;
    CheckRadioButton (IDC_RADIO8, IDC_RADIO11, button);
    handleButtonTestNum(g_properties.nTestNum);  // Tell the rest of the app something has changed.
}


// 16
void CDialogSelectTest::OnRadio8() 
{
    g_properties.nPktSz = 16;
	handleButtonDMAsz(IDC_RADIO8);
}

// 32
void CDialogSelectTest::OnRadio9() 
{
    g_properties.nPktSz = 32;
	handleButtonDMAsz(IDC_RADIO9);
}

// Slider 1
void CDialogSelectTest::OnRadio10() 
{
    CSliderCtrl* pSlider1 = (CSliderCtrl*) GetDlgItem (IDC_SLIDER1);
    g_properties.nSlider1 = g_properties.nPktSz = DMAsizeMAX + 4 - (pSlider1->GetPos() * 4);

    handleButtonDMAsz(IDC_RADIO10);
}

// Slider 2
void CDialogSelectTest::OnRadio11() 
{
    CSliderCtrl* pSlider2 = (CSliderCtrl*) GetDlgItem (IDC_SLIDER2);
    g_properties.nSlider2 = g_properties.nPktSz = DMAsizeMAX + 4 - (pSlider2->GetPos() * 4);

	handleButtonDMAsz(IDC_RADIO11);
}


// Two cooperative Close (Cancel) functions
void CDialogSelectTest::OnCancel() 
{
	// TODO: Add extra cleanup here

	DestroyWindow();
	// CDialog::OnCancel();
}

void CDialogSelectTest::PostNcDestroy ()
{
	((CMainFrame*) AfxGetMainWnd())->pDialogSelectTest = NULL;
	delete this;
}



// This routine is going away since all the controls are now live (they take effect immediately without
//  the need for an OK or Apply button).
void CDialogSelectTest::OnOK() 
{
}


BOOL CDialogSelectTest::OnInitDialog() 
{
	char buf[20];

	CDialog::OnInitDialog();		// call the base class' OnInitDialog
	
	SetTestNumButtons(g_properties.eMainMode, g_properties.nTestNum);

    // CheckRadioButton (IDC_RADIO8, IDC_RADIO11, g_properties.nDMAszButton);  // Check the current DMA length button

    // Initialize the sliders from the demo's global data.
    CSliderCtrl* pSlider1 = (CSliderCtrl*) GetDlgItem (IDC_SLIDER1);
    pSlider1->SetRange (DMAsizeMIN/4, DMAsizeMAX/4);
    pSlider1->SetPos (DMAsizeMAX/4 + 1 - g_properties.nSlider1/4);

	CEdit* pEdit2 = (CEdit*) GetDlgItem (IDC_EDIT2);
	sprintf (buf, "%d", g_properties.nSlider1); 
	pEdit2->SetWindowText (buf);

    
	CSliderCtrl* pSlider2 = (CSliderCtrl*) GetDlgItem (IDC_SLIDER2);
    pSlider2->SetRange (DMAsizeMIN/4, DMAsizeMAX/4);
    pSlider2->SetPos (DMAsizeMAX/4 + 1 - g_properties.nSlider1/4);

	CEdit* pEdit3 = (CEdit*) GetDlgItem (IDC_EDIT3);
	sprintf (buf, "%d", g_properties.nSlider2); 
	pEdit3->SetWindowText (buf);

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


BOOL CDialogSelectTest::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) 
{
	char buf[20];

    CSliderCtrl* pSlider1 = (CSliderCtrl*) GetDlgItem (IDC_SLIDER1);
    g_properties.nSlider1 = DMAsizeMAX + 4 - (pSlider1->GetPos() * 4);

	CEdit* pEdit2 = (CEdit*) GetDlgItem (IDC_EDIT2);
	sprintf (buf, "%d", g_properties.nSlider1); 
	pEdit2->SetWindowText (buf);


    CSliderCtrl* pSlider2 = (CSliderCtrl*) GetDlgItem (IDC_SLIDER2);
    g_properties.nSlider2= DMAsizeMAX + 4 - (pSlider2->GetPos() * 4);

	CEdit* pEdit3 = (CEdit*) GetDlgItem (IDC_EDIT3);
	sprintf (buf, "%d", g_properties.nSlider2); 
	pEdit3->SetWindowText (buf);


    if (g_properties.nDMAszButton == IDC_RADIO10)
    {
        g_properties.nPktSz = g_properties.nSlider1;
    }
    else if (g_properties.nDMAszButton == IDC_RADIO11)
    {
        g_properties.nPktSz = g_properties.nSlider2;
    }


    return CDialog::OnNotify(wParam, lParam, pResult);
}

⌨️ 快捷键说明

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