Hex edit control

The HexEdit control is a plain hex editor wrapped in a CEdit derived class called
CHexEdit. Where ever you use a CEdit class you can replace it with the CHexEdit class.
CHexEdit supports the following features:

  1. Addressdisplay can be short or long or turned off.
  2. Hexdisplay can have any width between 1 and 256 bytes or turned off
  3. Asciidisplay can have any width between 1 and 256 bytes or turned off
  4. Editing in hex or ascii mode
  5. cut/copy/paste support (text and/or binary format, binary compatible with DevStudio)

Undo is in the context menu but not implemented right now. Horizontal scrolling is also
not supported right now.

Public Methods

GetData

int GetData(LPBYTE p, int
len);
Use GetData to retrieve the
modified data from the control.
Parameter LPBYTE p pointer to the databuffer
  int len length of the databuffer
Return value number of bytes copied  
Remarks the GetData Method copies the
data to the buffer provided with the parameter p.

SetData

void SetData(LPBYTE p, int
len);
Use SetData to set the content
that the control displays for editing
Parameter LPBYTE p pointer to the databuffer
  int len length of the databuffer
Return value none  
Remarks the SetData Method copies the
data from the buffer provided with the parameter p into a internal working copy.

GetSel

CSize GetSel(void);
Use GetSel to retrieve the
range of bytes the user has selected.
Parameter none  
Return value
CSize
where cx contains the start and cy contains
the end of the selection.
Remarks if nothing is selected both cx
and cy are -1

SetSel

void SetSel(int s, int e);
Use SetSel to set the
selection.
Parameter int s start of selection
  int e end of selection
Return value
none
 
Remarks to clear any selection set both
s and e to -1

SetBPR

void SetBPR(int bpr);
Use SetBPR to set the number
of bytes per row that will be displayed.
Parameter int bpr number of bytes to display per row
Return value
none
 
Remarks SetBPR stands for
SetBytesPerRow

SetOptions

void SetOptions(BOOL a,
BOOL h, BOOL c, BOOL w);
Used to set various options.
Parameter BOOL a addressdisplay on/off
  BOOL h hexdisplay on/off
  BOOL c asciidisplay on/off
  BOOL w address is short (FALSE) or long (TRUE)
Return value
none
 
Remarks  

 

Download demo project – 32 KB

Download source – 8 KB

More by Author

Get the Free Newsletter!

Subscribe to Developer Insider for top news, trends & analysis

Must Read