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.
The applications is SDI, with a view based off of
The data is loaded into a
CString object. I used
CString because of its easy memory management
Empty() 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.
There are probably quite a few. Meh.
July 24, 2003 - Fixed the package, fixed drawing to use a memory dc making scrolling smooth, attempted to fix mousewheel scrolling (unable to confirm, no mouse to test with), used window color instead of plain white for background, disabled printing, fixed signed/unsigned warnings.