[译]简单的十六进制编辑器
By robot-v1.0
本文链接 https://www.kyfws.com/applications/simple-hex-editor-zh/
版权声明 本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
- 2 分钟阅读 - 918 个词 阅读量 0[译]简单的十六进制编辑器
原文地址:https://www.codeproject.com/Articles/4570/Simple-Hex-Editor
原文作者:PaulFrazee
译文由本站 robot-v1.0 翻译
前言
A simple hex editor
一个简单的十六进制编辑器
介绍(Introduction)
对于程序员而言,最有用的工具之一就是好的Hex编辑器.所以,我决定把一个放在一起.还有更多功能,例如查找功能,还有很多空间,但是它仍然是一个很好的十六进制编辑器.这是如何实现自定义文档视图的一个很好的例子.(One of the most useful tools for programmers is a good Hex editor. So, I decided to throw one together. There is lots of room for more features, such as find functionality, but it is still a good hex editor. It is a good example of how to implement custom document views.)
描述(Description)
该应用程序是SDI,其视图基于(The applications is SDI, with a view based off of) CScrollView
.数据加载到(. The data is loaded into a) CString
目的.我用了(object. I used) CString
由于其易于进行内存管理((because of its easy memory management () GetBuffer()
和(and) Empty()
是我所需要的).视图类手动绘制文本数据两次,左侧为ASCII,右侧为十六进制.简单的突出显示和光标控制被写入视图类,而数据操作则由数据接口处理.这确实是我自己的经验,但我认为对于类似的程序员来说,这可能是一个方便的例子.(were all I needed). The view class manually draws the text data twice, in ASCII on the left and in hex on the right. Simple highlighting and cursor control is written into the view class, while data manipulation is handled by the data interface. It was really more for my own experience, but I decided that it might be a handy example for fellow programmers on a similar path.)
兴趣点(Points of interest)
滚动可能会也可能不会按照预期的方式实现.我找不到很好的文档来说明如何使其完美工作,因此我将原点设置在左上方,并自己计算了可见线.也许有更好的方法(如果有的话,告诉我),但是最终结果是我只绘制所需的东西,从而使渲染速度足够快,可以使用.我还设法避免擦除屏幕上除滚动以外的所有内容.(The scrolling may or may not be implemented the way it was intended. I couldn’t find very good documentation on how to get it working perfectly, so I set the origins to the top left and simply calculated the visible lines myself. There may be a better way to do that (if there is, tell me), but the end result is that I only draw what I need, making the rendering fast enough to be usable. I also managed to avoid erasing the screen for everything except scrolling.)
已知错误(Known bugs)
可能有很多.嗯(There are probably quite a few. Meh.)
更新(Updates)
许可
本文以及所有相关的源代码和文件均已获得The Code Project Open License (CPOL)的许可。
C++ VC6 Windows Visual-Studio Dev 新闻 翻译