www.pudn.com > Daoli2.zip > SETUP.cpp


// SETUP.cpp : implementation file 
// 
 
#include "stdafx.h" 
#include "DAOLI2.h" 
#include "SETUP.h" 
#include "DAOLI2View.h" 
#include "MainFrm.h" 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
extern  bool DeListRules[RulesCounter]; 
extern  int polespeed; 
extern  int poleangle; 
///////////////////////////////////////////////////////////////////////////// 
// SETUP dialog 
static UINT rules[] = 
{ 
	IDS_STRRULES1,           //  
	IDS_STRRULES2, 
	IDS_STRRULES3, 
	IDS_STRRULES4, 
	IDS_STRRULES5,           // 
	IDS_STRRULES6, 
	IDS_STRRULES7, 
	IDS_STRRULES8, 
	IDS_STRRULES9,           //  
	IDS_STRRULES10, 
	IDS_STRRULES11,	 
}; 
 
 
SETUP::SETUP(CWnd* pParent /*=NULL*/) 
	: CDialog(SETUP::IDD, pParent) 
{ 
	//{{AFX_DATA_INIT(SETUP) 
	m_nspeed = 0; 
	//}}AFX_DATA_INIT 
} 
 
 
void SETUP::DoDataExchange(CDataExchange* pDX) 
{ 
	CDialog::DoDataExchange(pDX); 
	//{{AFX_DATA_MAP(SETUP) 
	DDX_Text(pDX, IDC_ANGLEEDIT, m_nangle); 
	DDV_MinMaxInt(pDX, m_nangle, -90, 90); 
	DDX_Text(pDX, IDC_SPEEDEDIT, m_nspeed); 
	DDV_MinMaxInt(pDX, m_nspeed, -180, 180); 
	//}}AFX_DATA_MAP 
} 
 
 
BEGIN_MESSAGE_MAP(SETUP, CDialog) 
	//{{AFX_MSG_MAP(SETUP) 
	ON_WM_PAINT() 
	ON_WM_VSCROLL() 
	ON_LBN_DBLCLK(IDC_RULESLIST, OnDblclkRuleslist) 
	ON_BN_CLICKED(IDC_ALLSELECT, OnAllselect) 
	ON_BN_CLICKED(IDC_ALLDESELECT, OnAlldeselect) 
	ON_LBN_DBLCLK(IDC_LIST2, OnDblclkList2) 
	//}}AFX_MSG_MAP 
END_MESSAGE_MAP() 
 
///////////////////////////////////////////////////////////////////////////// 
// SETUP message handlers 
 
BOOL SETUP::OnInitDialog()  
{ 
	 
	// TODO: Add extra initialization here 
    m_nspeed=polespeed; 
	m_nangle=poleangle; 
 
    // Be careful to call CDialog::OnInitDialog 
    //  only once in this function 
    CListBox* pLB1 = (CListBox*) GetDlgItem(IDC_RULESLIST); 
	CListBox* pLB2 = (CListBox*) GetDlgItem(IDC_LIST2); 
	CString s; 
	for(int i=0;iInsertString(-1, s); 
		if(bDlgRulesSel[i]) 
			pLB2->InsertString(-1,s); 
	} 
     
   
	CSpinButtonCtrl* pSpin1 = 
		(CSpinButtonCtrl*) GetDlgItem(IDC_ANGLESPIN); 
	pSpin1->SetRange(0, 180); 
	pSpin1->SetPos(m_nangle+90);  
 
	CSpinButtonCtrl* pSpin2 = 
		(CSpinButtonCtrl*) GetDlgItem(IDC_SPEEDSPIN); 
	pSpin2->SetRange(0, 360); 
	pSpin2->SetPos(m_nspeed+180);  
 
   	 
	return CDialog::OnInitDialog();  // return TRUE unless you set the focus to a control 
	              // EXCEPTION: OCX Property Pages should return FALSE 
} 
 
void SETUP::OnPaint()  
{ 
	CPaintDC dc(this); // device context for painting 
 
	 
	// TODO: Add your message handler code here 
 
	 
	// Do not call CDialog::OnPaint() for painting messages 
} 
 
void SETUP::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)  
{ 
	// TODO: Add your message handler code here and/or call default 
	 
    if (nSBCode == SB_ENDSCROLL) { 
        return; // Reject spurious messages 
    } 
    // Process scroll messages from IDC_SPIN1 only 
    if (pScrollBar->GetDlgCtrlID() == IDC_ANGLESPIN) 
	{ 
        CString strValue; 
        strValue.Format("%d", nPos-90); 
        ((CSpinButtonCtrl*) pScrollBar)->GetBuddy() 
                                       ->SetWindowText(strValue); 
    }  
	else if (pScrollBar->GetDlgCtrlID() == IDC_SPEEDSPIN) 
	{ 
        CString strValue; 
        strValue.Format("%d",nPos-180); 
        ((CSpinButtonCtrl*) pScrollBar)->GetBuddy() 
                                       ->SetWindowText(strValue); 
    }  
 
//	CDialog::OnVScroll(nSBCode, nPos, pScrollBar); 
} 
 
void SETUP::OnDblclkRuleslist()  
{ 
	// TODO: Add your control notification handler code here 
 
	CListBox* pLB1 = (CListBox*) GetDlgItem(IDC_RULESLIST); 
	CListBox* pLB2 = (CListBox*) GetDlgItem(IDC_LIST2); 
	int nSelect=pLB1->GetCurSel(); 
    if(!bDlgRulesSel[nSelect]) 
	{ 
		CString s; 
		s.Format(rules[nSelect]); 
		pLB2->InsertString(-1,s); 
		bDlgRulesSel[nSelect]=true; 
	} 
 
} 
 
void SETUP::OnAllselect()  
{ 
 
	// TODO: Add your control notification handler code here 
	CListBox* pLB2 = (CListBox*) GetDlgItem(IDC_LIST2); 
	CString s; 
	for(int i=0;iInsertString(-1,s); 
			bDlgRulesSel[i]=true; 
		} 
	} 
} 
 
void SETUP::OnAlldeselect()  
{ 
	for(int i=0;iGetCount(); 
	for(i=ruleCtr-1;i>=0;i--) 
	{ 
		pLB->DeleteString(i); 
	} 
	 
	 
} 
 
void SETUP::OnDblclkList2()  
{ 
	CString s1,s2; 
	// TODO: Add your control notification handler code here 
    //CListBox* pLB1 = (CListBox*) GetDlgItem(IDC_RULESLIST); 
	CListBox* pLB2= (CListBox*) GetDlgItem(IDC_LIST2); 
	int ncurSelect=pLB2->GetCurSel(); 
	pLB2->GetText(ncurSelect,s2); 
	for(int i=0;iDeleteString(ncurSelect); 
			bDlgRulesSel[i]=false; 
		} 
	}	 
} 
 
void SETUP::OnOK()  
{ 
	// TODO: Add extra validation here 
	for(int i=0;iInvalidate();	 
}