📄 showlatin.cpp
字号:
// ShowLatin.cpp : implementation file
//
#include "stdafx.h"
#include "Test_Font.h"
#include "ShowLatin.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CShowLatin dialog
CShowLatin::CShowLatin(CWnd* pParent /*=NULL*/)
: CDialog(CShowLatin::IDD, pParent)
{
//{{AFX_DATA_INIT(CShowLatin)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
m_pLatin = new char[2048 * 2];
m_pUnicode = new TCHAR[2048];
m_nCurr = 0;
UINT8 LATIN[3][4];
int i, j, k, index;
LATIN[0][0] = 0x81;
LATIN[0][1] = 0x20;
LATIN[0][2] = 0x91;
LATIN[0][3] = 0x37;
LATIN[1][0] = 0xF0;
LATIN[1][1] = 0x20;
LATIN[1][2] = 0xF0;
LATIN[1][3] = 0x29;
// LATIN[2][0] = 0xF8;
// LATIN[2][1] = 0xA1;
// LATIN[2][2] = 0xFE;
// LATIN[2][3] = 0xFE;
index = 0;
for (i=0; i<2; i++)
{
for (j=LATIN[i][0]; j<= LATIN[i][2]; j++)
{
for (k=LATIN[i][1]; k<= LATIN[i][3]; k++)
{
m_pLatin[index++] = j;
m_pLatin[index++] = k;
}
}
}
m_pLatin[index] = 0;
m_nChar = index / 2;
MultiByteToWideChar(CP_ACP | CP_OEMCP, 0, m_pLatin, index, m_pUnicode, 2048);
/*
char cInvalid[2];
TCHAR tcInValid;
cInvalid[0] = '?';
cInvalid[1] = 0;
MultiByteToWideChar(CP_ACP | CP_OEMCP, 0, cInvalid, 1, &tcInValid, 1);
for (i=0; i<m_nChar; i++)
{
if (m_pUnicode[i] == tcInValid)
{
memmove(&m_pUnicode[i], &m_pUnicode[i + 1], (m_nChar - i + 1) * 2);
i--;
m_nChar--;
}
}
*/
}
void CShowLatin::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CShowLatin)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CShowLatin, CDialog)
//{{AFX_MSG_MAP(CShowLatin)
ON_WM_PAINT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CShowLatin message handlers
BOOL CShowLatin::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
LOGFONT lf;
memset(&lf, 0, sizeof(LOGFONT)); // Clear out structure.
lf.lfHeight = FONT_HEIGHT;
lstrcpy(lf.lfFaceName, _T("Arial"));
m_font.CreateFontIndirect(&lf); // Create the font.
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
BOOL CShowLatin::DestroyWindow()
{
// TODO: Add your specialized code here and/or call the base class
if (m_pLatin)
{
delete m_pLatin;
m_pLatin = NULL;
}
if (m_pUnicode)
{
delete m_pUnicode;
m_pUnicode = NULL;
}
return CDialog::DestroyWindow();
}
void CShowLatin::DrawPage(int nIndex)
{
CClientDC dc(this);
CFont* def_font = dc.SelectObject(&m_font);
TCHAR* ptcSpace = _T(" ");
TCHAR tcClear[CHAR_IN_LINE * 4 +1];
TCHAR tcChar[CHAR_IN_LINE+1];
memset(tcClear, 0, CHAR_IN_LINE * 8 + 2);
memcpy(tcClear, ptcSpace, CHAR_IN_LINE * 8);
for (int j=0; j<LINE_IN_PAGE; j++)
{
dc.ExtTextOut(5, 5 + FONT_HEIGHT * j, ETO_OPAQUE, NULL, tcClear, NULL);
}
for (int i=0; i<LINE_IN_PAGE; i++)
{
if ((nIndex >= m_nChar) || (nIndex < 0))
{
break;
}
memcpy(tcChar, m_pUnicode+nIndex, CHAR_IN_LINE * 2);
nIndex += CHAR_IN_LINE;
tcChar[CHAR_IN_LINE] = 0;
dc.ExtTextOut(5, 5 + FONT_HEIGHT * i, ETO_OPAQUE, NULL, tcChar, NULL);
}
dc.SelectObject(def_font);
}
void CShowLatin::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
DrawPage(m_nCurr);
// Do not call CDialog::OnPaint() for painting messages
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -