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

📄 pydlg.cpp

📁 汉字转拼音程序
💻 CPP
字号:
// PyDlg.cpp : implementation file
//

#include "stdafx.h"
#include "Py.h"
#include "PyDlg.h"
#include "Pinyin.h"

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

LPCTSTR lpszText = _T("天地不仁,以万物为刍狗;\r\n圣人不仁,以百姓为刍狗。\n\r不仁者,无心于爱也。\r\n范应元说:“夫春 \
夏生长,亦如刍狗之未陈,\r\n秋冬凋落, ...\r\n 刍狗,是以刍草束为狗,\r\n以供祭招,用过即弃之。\
它的见用和被弃,\r\n不是有心于爱憎,都是时势使然。\r\n因此,\r\n天地与圣人俱无心于");
/////////////////////////////////////////////////////////////////////////////
// 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()

/////////////////////////////////////////////////////////////////////////////
// CPyDlg dialog

CPyDlg::CPyDlg(CWnd* pParent /*=NULL*/)
	: ETSLayoutDialog(CPyDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CPyDlg)
	m_strChs = lpszText;
	m_strPy = _T("");
	//}}AFX_DATA_INIT
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CPyDlg::DoDataExchange(CDataExchange* pDX)
{
	ETSLayoutDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CPyDlg)
	DDX_Text(pDX, IDC_EDIT_CHS, m_strChs);
	DDX_Text(pDX, IDC_EDIT_PY, m_strPy);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CPyDlg, ETSLayoutDialog)
	//{{AFX_MSG_MAP(CPyDlg)
	ON_WM_SYSCOMMAND()
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	ON_BN_CLICKED(IDC_BUTTON_ENCODE, OnButtonEncode)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CPyDlg message handlers

BOOL CPyDlg::OnInitDialog()
{
	ETSLayoutDialog::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
	CPane leftPane = pane(VERTICAL)
		<< item(IDC_STATIC_CHS, ABSOLUTE_VERT)
		<< item (IDC_EDIT_CHS)
		;
	CPane rightPane = pane(VERTICAL)
		<< item(IDC_STATIC_PY, ABSOLUTE_VERT)
		<< item (IDC_EDIT_PY)
		;
	CPane midPane = pane(VERTICAL)
		<< itemGrowing(VERTICAL)
		<< item(IDC_BUTTON_ENCODE, NORESIZE)
		<< itemGrowing(VERTICAL)
		<< itemGrowing(VERTICAL)
		;

	CreateRoot(HORIZONTAL)
		<< leftPane
		<< midPane
		<< rightPane
		;

	UpdateLayout();

	CPinYin::Initialize(_T("py.lut"));

	return TRUE;  // return TRUE  unless you set the focus to a control
}

void CPyDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
	if ((nID & 0xFFF0) == IDM_ABOUTBOX)
	{
		CAboutDlg dlgAbout;
		dlgAbout.DoModal();
	}
	else
	{
		ETSLayoutDialog::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 CPyDlg::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
	{
		ETSLayoutDialog::OnPaint();
	}
}

// The system calls this to obtain the cursor to display while the user drags
//  the minimized window.
HCURSOR CPyDlg::OnQueryDragIcon()
{
	return (HCURSOR) m_hIcon;
}


void CPyDlg::OnButtonEncode() 
{
	// TODO: Add your control notification handler code here
	UpdateData(TRUE);

	m_strPy = CPinYin::GetFullSpell((LPCSTR)m_strChs).c_str();
	
	UpdateData(FALSE);
}

⌨️ 快捷键说明

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