I would like to know how to open a binary file and then display the hexadecimal code in a text box.
void MainFrame::OpenFile(wxCommandEvent& WXUNUSED(event))
{
wxFileDialog *OpenDialog = new wxFileDialog(
this, _("Choose a file to open"), wxEmptyString, wxEmptyString,
_("All Files (*.*)|*.*"),
wxFD_OPEN, wxDefaultPosition);
// Creates a "open file" dialog with 4 file types
if (OpenDialog->ShowModal() == wxID_OK) // if the user click "Open" instead of "cancel"
{
CurrentDocPath = OpenDialog->GetPath();
// Sets our current document to the file the user selected
MainEditBox->LoadFile(CurrentDocPath); //Opens that file
SetTitle( wxString(OpenDialog->GetFilename()) );
}
}
I got that code in wxWidgets tutorial to open an ASCII file, but what if it is a binary data file and I want to display the hexadecimal code, or even better, save it as a wxString or a std::string.
Preferably, I want to display the hex code in the MainEditoBox textbox as if it were an hex editor.
Thanks in advance.
Note: I'm using wxWidgets GUI Toolkit.