www.pudn.com > NanDlg_CHtransform.rar > NanDlgDlg.cpp


// NanDlgDlg.cpp : implementation file 
// 
 
#include "stdafx.h" 
#include "NanDlg.h" 
#include "NanDlgDlg.h" 
#include "nanpy.h" 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
 
///////////////////////////////////////////////////////////////////////////// 
// CAboutDlg dialog used for App About 
 
class CAboutDlg : public CDialog 
{ 
public: 
	CAboutDlg(); 
 
// Dialog Data 
	//{{AFX_DATA(CAboutDlg) 
	enum { IDD = IDD_ABOUTBOX }; 
	//}}AFX_DATA 
 
	// ClassWizard generated virtual function overrides 
	//{{AFX_VIRTUAL(CAboutDlg) 
	protected: 
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support 
	//}}AFX_VIRTUAL 
 
// Implementation 
protected: 
	//{{AFX_MSG(CAboutDlg) 
	//}}AFX_MSG 
	DECLARE_MESSAGE_MAP() 
}; 
 
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) 
{ 
	//{{AFX_DATA_INIT(CAboutDlg) 
	//}}AFX_DATA_INIT 
} 
 
void CAboutDlg::DoDataExchange(CDataExchange* pDX) 
{ 
	CDialog::DoDataExchange(pDX); 
	//{{AFX_DATA_MAP(CAboutDlg) 
	//}}AFX_DATA_MAP 
} 
 
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) 
	//{{AFX_MSG_MAP(CAboutDlg) 
		// No message handlers 
	//}}AFX_MSG_MAP 
END_MESSAGE_MAP() 
 
///////////////////////////////////////////////////////////////////////////// 
// CNanDlgDlg dialog 
 
CNanDlgDlg::CNanDlgDlg(CWnd* pParent /*=NULL*/) 
	: CDialog(CNanDlgDlg::IDD, pParent) 
{ 
	//{{AFX_DATA_INIT(CNanDlgDlg) 
	m_inputstring = _T(""); 
	m_showlist = _T(""); 
	//}}AFX_DATA_INIT 
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32 
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); 
} 
 
void CNanDlgDlg::DoDataExchange(CDataExchange* pDX) 
{ 
	CDialog::DoDataExchange(pDX); 
	//{{AFX_DATA_MAP(CNanDlgDlg) 
	DDX_Control(pDX, IDC_EDIT1, m_edit1); 
	DDX_Control(pDX, IDC_EDIT2, m_edit2); 
	DDX_Control(pDX, IDC_SHOW, m_char); 
	DDX_Text(pDX, IDC_EDIT2, m_inputstring); 
	DDX_Text(pDX, IDC_EDIT1, m_showlist); 
	//}}AFX_DATA_MAP 
} 
 
BEGIN_MESSAGE_MAP(CNanDlgDlg, CDialog) 
	//{{AFX_MSG_MAP(CNanDlgDlg) 
	ON_WM_SYSCOMMAND() 
	ON_WM_PAINT() 
	ON_WM_QUERYDRAGICON() 
	ON_EN_CHANGE(IDC_EDIT2, OnChangeEdit2) 
	ON_BN_CLICKED(IDC_BUTTON1, OnButton1) 
	ON_BN_CLICKED(IDC_BUTTON3, OnButton3) 
	ON_BN_CLICKED(IDC_BUTTON4, OnButton4) 
	//}}AFX_MSG_MAP 
END_MESSAGE_MAP() 
 
///////////////////////////////////////////////////////////////////////////// 
// CNanDlgDlg message handlers 
 
BOOL CNanDlgDlg::OnInitDialog() 
{ 
	CDialog::OnInitDialog(); 
 
	// Add "About..." menu item to system menu. 
 
	// IDM_ABOUTBOX must be in the system command range. 
	ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX); 
	ASSERT(IDM_ABOUTBOX < 0xF000); 
 
	CMenu* pSysMenu = GetSystemMenu(FALSE); 
	if (pSysMenu != NULL) 
	{ 
		CString strAboutMenu; 
		strAboutMenu.LoadString(IDS_ABOUTBOX); 
		if (!strAboutMenu.IsEmpty()) 
		{ 
			pSysMenu->AppendMenu(MF_SEPARATOR); 
			pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu); 
		} 
	} 
 
	// Set the icon for this dialog.  The framework does this automatically 
	//  when the application's main window is not a dialog 
	SetIcon(m_hIcon, TRUE);			// Set big icon 
	SetIcon(m_hIcon, FALSE);		// Set small icon 
	 
	// TODO: Add extra initialization here 
	PYcontabl(); 
	return TRUE;  // return TRUE  unless you set the focus to a control 
} 
 
void CNanDlgDlg::OnSysCommand(UINT nID, LPARAM lParam) 
{ 
	if ((nID & 0xFFF0) == IDM_ABOUTBOX) 
	{ 
		CAboutDlg dlgAbout; 
		dlgAbout.DoModal(); 
	} 
	else 
	{ 
		CDialog::OnSysCommand(nID, lParam); 
	} 
} 
 
// If you add a minimize button to your dialog, you will need the code below 
//  to draw the icon.  For MFC applications using the document/view model, 
//  this is automatically done for you by the framework. 
 
void CNanDlgDlg::OnPaint()  
{ 
	if (IsIconic()) 
	{ 
		CPaintDC dc(this); // device context for painting 
 
		SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0); 
 
		// Center icon in client rectangle 
		int cxIcon = GetSystemMetrics(SM_CXICON); 
		int cyIcon = GetSystemMetrics(SM_CYICON); 
		CRect rect; 
		GetClientRect(&rect); 
		int x = (rect.Width() - cxIcon + 1) / 2; 
		int y = (rect.Height() - cyIcon + 1) / 2; 
 
		// Draw the icon 
		dc.DrawIcon(x, y, m_hIcon); 
	} 
	else 
	{ 
		CDialog::OnPaint(); 
	} 
} 
 
// The system calls this to obtain the cursor to display while the user drags 
//  the minimized window. 
HCURSOR CNanDlgDlg::OnQueryDragIcon() 
{ 
	return (HCURSOR) m_hIcon; 
} 
 
void CNanDlgDlg::OnChangeEdit2()  
{ 
	// 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. 
	//UpdateData(TRUE); 
	 
	//UpdateData(FALSE); 
	// TODO: Add your control notification handler code here 
    CString mstr; 
	m_edit2.GetWindowText(mstr); 
		if(((mstr[0]>='a')&&(mstr[0]<='z'))&&(mstr[0]!='v')&&(mstr[0]!='i')&&(mstr[0]!='u')) 
		{ 
			if(mstr[mstr.GetLength()-1]==' ') 
			{ 
				//寻找到匹配的,c指向头,判断有几个要显示,用i来表示 
				//numb〉10,则dd[10][3],小于则dd[i][3] 
				//读入numb个或10个,显示出来 
				//numb应该为全局变量] 
				 char temp[6]; 
				 for(int j=0;j<6;j++) 
				 { 
					 temp[j]='\0'; 
				 } 
				 for(int i=0;i=10) 
				 { 
					 //d=showPY(c,10); 
                     char dd[10][3]; 
                     char pp[10]={'0','1','2','3','4','5','6','7','8','9'}; 
					 char *tempc=c; 
	                 for(int j=0;j<=9;j++) 
					 { 
		                 dd[j][1]=*(tempc); 
		                 dd[j][2]=*(tempc+1); 
		                 dd[j][0]=pp[j]; 
						 tempc+=8; 
					 } 
					 d=&dd[0][0]; 
				 } 
				 else if(numb==0) 
				 { 
                     mstr.Remove(' '); 
			         UpdateData(TRUE); 
                     m_showlist+=mstr; 
                     m_inputstring=_T(""); 
                     UpdateData(FALSE); 
				 } 
		 		 else 
				 { 
					 //d=showPY(c,numb); 
					 char dd[10][3]; 
					 char *tempc=c; 
                     char pp[10]={'0','1','2','3','4','5','6','7','8','9'}; 
	                 for(int j=0;j='0')&&(mstr[mstr.GetLength()-1]<='9')) 
			{ 
				//c+mstr[mstr.GetLength()-1]的字显示在edit1中 
				//char *c=&b[0][0]; 
				if((mstr[mstr.GetLength()-1]-'0')<=numb) 
				{ 
				char ddd[2]; 
			    ddd[0]=*(c+8*(mstr[mstr.GetLength()-1]-'0')); 
				ddd[1]=*(c+8*(mstr[mstr.GetLength()-1]-'0')+1); 
				c=&b[0][0]; 
				numb=0; 
                UpdateData(TRUE); 
				m_showlist+=ddd[0]; 
                m_showlist+=ddd[1]; 
                m_inputstring=_T(""); 
				m_char.SetWindowText(""); 
                UpdateData(FALSE); 
				} 
				else 
				{ 
                mstr.Remove(' '); 
			    UpdateData(TRUE); 
                m_showlist+=mstr; 
                m_inputstring=_T(""); 
                UpdateData(FALSE); 
				} 
			} 
		} 
		else 
		{    
			if(mstr[mstr.GetLength()-1]==' ') 
			{ 
			    mstr.Remove(' '); 
			    UpdateData(TRUE); 
                m_showlist+=mstr; 
                m_inputstring=_T(""); 
                UpdateData(FALSE); 
			} 
		} 
} 
 
 
void CNanDlgDlg::OnButton1() //清空键 
{ 
	// TODO: Add your control notification handler code here 
	UpdateData(TRUE); 
    m_inputstring=_T(""); 
    m_char.SetWindowText(""); 
    UpdateData(FALSE); 
} 
 
void CNanDlgDlg::OnButton3() //-> 
{ 
	// TODO: Add your control notification handler code here 
	//如果i〉10,则做 
	//首先i—10,c+10,然后根据i的大小显示输入框 
	//然后使得向左箭头能使用 
	if(numb>10) 
	{ 
		numb-=10; 
		c+=80; 
		count++; 
        char dd[10][3]; 
		char *tempc=c; 
		char *d; 
        char pp[10]={'0','1','2','3','4','5','6','7','8','9'}; 
		if(numb<10) 
		{ 
	    for(int j=0;j