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

📄 hzlibview.cpp

📁 输入汗字显示16*16和24*24汉字字模
💻 CPP
字号:
// HZLibView.cpp : implementation of the CHZLibView class
//

#include "stdafx.h"
#include "HZLib.h"

#include "HZLibDoc.h"
#include "HZLibView.h"

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

/////////////////////////////////////////////////////////////////////////////
// CHZLibView

IMPLEMENT_DYNCREATE(CHZLibView, CFormView)

BEGIN_MESSAGE_MAP(CHZLibView, CFormView)
	//{{AFX_MSG_MAP(CHZLibView)
	ON_BN_CLICKED(IDC_BUTTON_ADD, OnButtonAdd)
	ON_BN_CLICKED(IDC_BUTTON_DISP, OnButtonDisp)
	ON_BN_CLICKED(IDC_BUTTON_24, OnButton24)
	ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
	//}}AFX_MSG_MAP
	// Standard printing commands
	ON_COMMAND(ID_FILE_PRINT, CFormView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_DIRECT, CFormView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_PREVIEW, CFormView::OnFilePrintPreview)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CHZLibView construction/destruction

CHZLibView::CHZLibView()
	: CFormView(CHZLibView::IDD)
{
	//{{AFX_DATA_INIT(CHZLibView)
	m_CharInput = _T("");
	m_HZnumber = 0;
	m_ZKsize = 0;
	m_realcount=0;
	//}}AFX_DATA_INIT
	// TODO: add construction code here

}

CHZLibView::~CHZLibView()
{
}

void CHZLibView::DoDataExchange(CDataExchange* pDX)
{
	CFormView::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CHZLibView)
	DDX_Control(pDX, IDC_EDIT_OUTPUT, m_CharDisp);
	DDX_Text(pDX, IDC_EDIT_INPUT, m_CharInput);
	DDX_Text(pDX, IDC_EDIT_NUMBER, m_HZnumber);
	DDX_Text(pDX, IDC_EDIT_SIZE, m_ZKsize);
	//}}AFX_DATA_MAP
}

BOOL CHZLibView::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs

	return CFormView::PreCreateWindow(cs);
}

void CHZLibView::OnInitialUpdate()
{
	CFormView::OnInitialUpdate();
	GetParentFrame()->RecalcLayout();
	ResizeParentToFit();

}

/////////////////////////////////////////////////////////////////////////////
// CHZLibView printing

BOOL CHZLibView::OnPreparePrinting(CPrintInfo* pInfo)
{
	// default preparation
	
	return DoPreparePrinting(pInfo);
}

void CHZLibView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add extra initialization before printing
}

void CHZLibView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add cleanup after printing
}

void CHZLibView::OnPrint(CDC* pDC, CPrintInfo* /*pInfo*/)
{
	// TODO: add customized printing code here
}

/////////////////////////////////////////////////////////////////////////////
// CHZLibView diagnostics

#ifdef _DEBUG
void CHZLibView::AssertValid() const
{
	CFormView::AssertValid();
}

void CHZLibView::Dump(CDumpContext& dc) const
{
	CFormView::Dump(dc);
}

CHZLibDoc* CHZLibView::GetDocument() // non-debug version is inline
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CHZLibDoc)));
	return (CHZLibDoc*)m_pDocument;
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CHZLibView message handlers

void CHZLibView::OnButtonAdd() 
{
	// TODO: Add your control notification handler code here
	CFile HZKlib;
	CFile SmaHZKlib;
	CFile HZK24;
	CFile SmaHZK24;
//	unsigned short nHZneima;
	unsigned char nHZquma;
	unsigned char nHZweima;
	unsigned char nZMtemp[32];
	unsigned char nZMtemp24[72];
	int nRec;
	int nOffset,noffset24;
	unsigned char nquma[100]={0};
	unsigned char nweima[100]={0};


	

	HZKlib.Open("HZK16",CFile::modeRead);
	HZK24.Open("HZK24F",CFile::modeRead);
	SmaHZKlib.Open("SmallHZKlib",CFile::modeCreate | CFile::modeWrite);
	SmaHZK24.Open("SmallHZK24",CFile::modeCreate|CFile::modeWrite);
	
	UpdateData(true);   
	
	nHZCount=m_CharInput.GetLength()/2;
	m_realcount=0;

	
	for(int i=0;i<nHZCount*2;i=i+2)
	{
		//nHZneima=m_CharInput.GetAt(i);
		//nHZneima=nHZneima+m_CharInput.GetAt(i+1)<<8;
		//区码=高字节-0xA0;位码=低字节-0xA0;汉字区位码的区码和位码的取值均在1~94之间。
		nHZquma=m_CharInput.GetAt(i)-0xA0;//计算机获得的是机内码;
		nHZweima=m_CharInput.GetAt(i+1)-0xA0;
		

		if(nquma[nHZquma]==0||nweima[nHZweima]==0)

		{
			nquma[nHZquma]=1;
		    nweima[nHZweima]=1;
			m_realcount++;

		    nRec=(nHZquma-1)*94+(nHZweima-1);//94*94汉字方阵中的序号
		    nOffset=nRec*32;//一个16X16点阵的汉字需要用32个字节来存放一个汉字
            noffset24=(94*(nHZquma-18)+(nHZweima-1)+188)*72;//24*24字库的取模方式!

		    HZKlib.Seek(nOffset,CFile::begin);
		    HZKlib.Read(nZMtemp,32);
		    SmaHZKlib.Write(nZMtemp,32);

			HZK24.Seek(noffset24,CFile::begin);
			HZK24.Read(nZMtemp24,72);
			SmaHZK24.Write(nZMtemp24,72);
		}
	

	}
	//SmaHZKlib.Seek(2*nHZCount,CFile::begin);
	//SmaHZKlib.Write((unsigned short*)&nrealcount,2);

	m_HZnumber=m_realcount;
	m_ZKsize=SmaHZKlib.GetLength();

	SmaHZKlib.Close();
	HZKlib.Close();
	UpdateData(false);


}

void CHZLibView::OnButtonDisp() 
{
// TODO: Add your control notification handler code here
	
	CFile HZKlib;
	CFile SmaHZKlib;
	unsigned char read[32];
    unsigned char buffer[65];
	CString temp;
	unsigned int i,j,length,highhex,lowhex;

	m_CharDisp.SetSel(0,-1);
	m_CharDisp.ReplaceSel("");

	SmaHZKlib.Open("SmallHZKlib",CFile::modeRead);
//	m_CharDisp.Empty();
for (j=0;j<m_realcount;j++)
{

	SmaHZKlib.Read(read,32);
       for (i=0;i<32;i++)
		{
		    highhex=read[i]/16;
	 	    lowhex=read[i]%16;
		    if (highhex>=0&&highhex<=9)
			{
			    buffer[2*i]=highhex+'0';
			}
		    else
			{
			    buffer[2*i]=highhex+'A'-10;	
			}
		    if (lowhex>=0&&lowhex<=9)
			{
			    buffer[2*i+1]=lowhex+'0';
			}
		    else
			{
		    	buffer[2*i+1]=lowhex+'A'-10;
			}
		}

		buffer[64]='\0';
		temp.Format("%s",buffer);
		
	     for(length=temp.GetLength()-2;length>0;length-=2)
		 {
		     temp.Insert(length,",0x");
		 };
	     temp.Insert(0,"0x");
		 temp+=',';

        m_CharDisp.SetSel(1000000,1000000);
		m_CharDisp.ReplaceSel(temp,true);
		m_CharDisp.SetSel(1000000,1000000);
		m_CharDisp.ReplaceSel("\15\12");
		//m_CharDisp=temp+m_CharDisp;
		//m_CharDisp+=' ';
}
   
	SmaHZKlib.Close();

	CString ncount;
	//i=m_CharDisp.GetLength();
	//ncount.Format("%d",i);
	//MessageBox(ncount);

	UpdateData(false);
	
}

void CHZLibView::OnButton24() 
{
	// TODO: Add your control notification handler code here
	

	CFile SmaHZK24;
	unsigned char read[72];
    unsigned char buffer[144];
	CString temp;
	unsigned int i,j,length,highhex,lowhex;
	
	m_CharDisp.SetSel(0,-1);
	m_CharDisp.ReplaceSel("");
	
	SmaHZK24.Open("SmallHZK24",CFile::modeRead);
	//	m_CharDisp.Empty();
	for (j=0;j<m_realcount;j++)
	{
		
		SmaHZK24.Read(read,72);
		for (i=0;i<72;i++)
		{
			highhex=read[i]/16;
			lowhex=read[i]%16;
			if (highhex>=0&&highhex<=9)
			{
				buffer[2*i]=highhex+'0';
			}
			else
			{
				buffer[2*i]=highhex+'A'-10;	
			}
			if (lowhex>=0&&lowhex<=9)
			{
				buffer[2*i+1]=lowhex+'0';
			}
			else
			{
				buffer[2*i+1]=lowhex+'A'-10;
			}
		}
		
		buffer[144]='\0';
		temp.Format("%s",buffer);
	
		
		for(length=temp.GetLength()-2;length>0;length-=2)
		{
			temp.Insert(length,",0x");
		};
		temp.Insert(0,"0x");
		temp+=',';
		
        m_CharDisp.SetSel(1000000,1000000);
		m_CharDisp.ReplaceSel(temp,true);
		m_CharDisp.SetSel(1000000,1000000);
		m_CharDisp.ReplaceSel("\15\12");
		
	}
	
	SmaHZK24.Close();
	
	UpdateData(false);

	
}

void CHZLibView::OnButton2() 
{
	// TODO: Add your control notification handler code here
	m_CharDisp.SetSel(0,-1);
	m_CharDisp.ReplaceSel("");
	UpdateData(false);
	
}

⌨️ 快捷键说明

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