?
Solved

Hex editor - CEditView in a CFormView?

Posted on 1998-07-28
8
Medium Priority
?
380 Views
Last Modified: 2013-12-03
I have a formview that has various buttons and textboxes to accept input.

My program is going to display about 0x100 address lines and their
corresponding data in binary and ascii format (Like a Hex editor)

Right now the only way I can see to do this is to create a large textbox
entry and associate  a Cstring with it.  Then change the Cstring to
represent  all 0x100  address lines.
ie.
ADDRESS          BINARY         ASCII
  0                     00 00 00           . . .
  3                     00 00 00           . . .

CString  =   "0\t00 00 00\t. . .\n3\t00 00 00\t . . .\n"  etc...

Is there an easier or better way to go about doing this.. for instance
having a CeditView within my Cformview so that I could use
pDC->TextOut();

Thanks

PS A List Control would not fit well with my app.
For example, I want the user to be able to select indivual bytes and let
them convert it the number from hex to decimal.
0
Comment
Question by:vinny5
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
8 Comments
 

Author Comment

by:vinny5
ID: 1411216
Edited text of question
0
 
LVL 15

Expert Comment

by:Tommy Hui
ID: 1411217
Instead of maintaining the bytes in a string like that, why not store them in an array? Then you can display the array anyway you want by using calculating where the bytes should be displayed based on the font size and position. Then when the user clicks on the window, calculate the nearest byte and create an edit control at that location. Fill the edit control with the byte and allow the user to edit the byte. When editing is done, store the new value into the array and update the display.

0
 

Author Comment

by:vinny5
ID: 1411218
>Instead of maintaining the bytes in a string like that, why not store them in
>an array?
>Then you can display the array anyway you want by using
>calculating where the bytes should be displayed based on the font size and
>position.

I am already doing  this.  I have an array that will store all of my data... I just
display the array with a Cstring variable similiar to the one shown above.  
So unless I've mis-interpretted your answer it is still very similar to my solution.

>Then when the user clicks on the window, calculate the nearest
>byte and create an edit control at that location. Fill the edit control with the
>byte and allow the user to edit the byte. When editing is done, store the new
> value into the array and update the display.

While this is similar to a Hex editor it is quite different.  I don't want the user to
change the data. This really isn't what Im concerned with.  What I need to know is if
there is a better way of displaying the address lines and data without an
EditBox or RichEditControl.  Like having a CEditView within my CFormView

Thanks for your suggestion though and if no one comes up with anything better
I'll give you the points.
0
Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

 
LVL 6

Expert Comment

by:snoegler
ID: 1411219
I think what thui said is correct. If the values need not to be changed, why don't you do some-
thing like this:

for(row=0;row<nRows;row++) {
  for(col=0;col<nCols;col++) {
    CRect bounds;
    CString field;
    bounds.left=col*COL_WIDTH; // COL_WIDTH defined by you
    bounds.right=(col+1)*COL_WIDTH-1;
    bounds.top=row*ROW_HEIGHT;
    bounds.bottom=(row+1)*ROW_HEIGHT-1;
    field.Format("%02x",myarray[row][col]);
    pDC->ExtTextOut(bounds.left,bounds.top,ETO_CLIPPED,&bounds,-1,NULL,field);
  }
}
0
 

Author Comment

by:vinny5
ID: 1411222

1. I need a lot of input, thats what I wrote in my fist message "various textboxes and buttons.." This is why I need a formview. I just didn't want the user to change the data in the control that
displayed the byte values and adress lines.

2. Thanks, now I understand..  

If you want the points just hit answer question...
thanks

0
 

Author Comment

by:vinny5
ID: 1411220
pDC->ExtTextOut would be great if I wanted to print out the Address lines becuase I  have a CDC to work with.  But I NEED to use a FormView.  As far as I knew a CFormView was derived from CWnd not CDC.  RichEditControl is also derived from CWnd.  

You probably already know this so Im guessing that Im missing something...
Anway if you or thui want to send in a dummy answer I'll give you the points.

If you could explain how to get a DC from a RichEditControl that would be great too..


0
 
LVL 6

Expert Comment

by:snoegler
ID: 1411221
1st i don't understand why you are using a CFormView when you do not need input
2nd GetDC() works with all CWnd derivates. Alternatively you can implement an
OnPaint() handler, which defines its own CDC.
0
 
LVL 6

Accepted Solution

by:
snoegler earned 1400 total points
ID: 1411223
This offer i can't reject :)
0

Featured Post

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, I will show how to use the Ribbon IDs Tool Window to assign the built-in Office icons to a ribbon button.  This tool will help us to find the OfficeImageId that corresponds to our desired built-in Office icon. The tool is part of…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question