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

📄 hexeditor.cpp

📁 游戏修改器 大家可以看看呵呵 老牌子的 但是可能别人已经发过了
💻 CPP
字号:
// HexEditor.cpp : implementation file
//

#include "stdafx.h"
//#include "fpe.h"
#include "HexEditor.h"

#include "MemEdit.h"

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

extern BOOL g_BlockModified;//
extern BYTE g_BlockBuffer[256];//

/////////////////////////////////////////////////////////////////////////////
// CHexEditor

CHexEditor::CHexEditor()
{
}

CHexEditor::~CHexEditor()
{
}


BEGIN_MESSAGE_MAP(CHexEditor, CEdit)
	//{{AFX_MSG_MAP(CHexEditor)
	ON_WM_CHAR()
	ON_WM_KEYDOWN()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CHexEditor message handlers

void CHexEditor::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags) 
{
	POINT pt = GetCaretPos();
	int nCharWidth;
	int n = CharFromPos(pt);
	int nLineIndex = HIWORD(n);
	int nCharIndex = LOWORD(n);
	if((nCharIndex+1) % 3 == 0)
	{
		pt = PosFromChar(nCharIndex+1);
		SetCaretPos(pt);
	}
	else
	{
		if(nChar >= 'a' && nChar <= 'f')
			nChar -= 'a' - 'A';

		if((nChar >= '0' && nChar <= '9') ||
			(nChar >= 'A' && nChar <= 'F'))
		{
			//CEdit::OnChar(nChar, nRepCnt, nFlags);

			HideCaret();//隐藏系统的脱字^符号

			CDC *pdc = GetDC();
			pdc->SelectObject(GetFont());
			GetCharWidth32(pdc->m_hDC, nChar, nChar, &nCharWidth); 
			pdc->TextOut(pt.x, pt.y, (CHAR *)&nChar, 1);
			ReleaseDC(pdc);

			pt.x += nCharWidth;
			ShowCaret();
			SetCaretPos(pt);			

			// 由于不进行CEdit::OnChar(...)调用,此处不会触发
			// EN_CHANGE消息, 因此以下动作需要在此进行
			g_BlockModified = true;
			GetParent()->GetDlgItem(IDC_BTN_MEMWRITE)->EnableWindow(true);///////

			// 同上描述, 由于不进行CEdit::OnChar(...)调用,
			// 外部进行m_editHex.GetLine调用时, 获取的文本并非
			// 修改后的, 因此CDlgEditMemory::OnBtnWrite()中注释掉
			// 的部分无法工作. 需要进行以下处理. 以确保写内存正确.
			char hex[8] = {0};
			sprintf(hex, "%02X", g_BlockBuffer[nCharIndex/3]);
			hex[nCharIndex % 3] = nChar;
			g_BlockBuffer[nCharIndex/3] =
				(hex[0] - '0' - (hex[0] >= 'A' ? 7:0)) * 16 +
				(hex[1] - '0' - (hex[1] >= 'A' ? 7:0));
		}
	}
}

void CHexEditor::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) 
{
	if(nChar == VK_DELETE)
		return;
	
	CEdit::OnKeyDown(nChar, nRepCnt, nFlags);
}

POINT CHexEditor::MyGetCaretPos()
{
	return GetCaretPos();
}

void CHexEditor::MySetCaretPos(POINT pt)
{
	int n = CharFromPos(pt);
	int nLineIndex = HIWORD(n);
	int nCharIndex = LOWORD(n);

	pt = PosFromChar(nCharIndex);
	SetCaretPos(pt);
}

⌨️ 快捷键说明

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