Solved

Hex editor - CEditView in a CFormView?

Posted on 1998-07-28
8
369 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
  • 4
  • 3
8 Comments
 

Author Comment

by:vinny5
Comment Utility
Edited text of question
0
 
LVL 15

Expert Comment

by:Tommy Hui
Comment Utility
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
Comment Utility
>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
 
LVL 6

Expert Comment

by:snoegler
Comment Utility
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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

Author Comment

by:vinny5
Comment Utility

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
Comment Utility
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
Comment Utility
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 350 total points
Comment Utility
This offer i can't reject :)
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This article shows how to make a Windows 7 gadget that accepts files dropped from the Windows Explorer.  It also illustrates how to give your gadget a non-rectangular shape and how to add some nifty visual effects to text displayed in a your gadget.…
This article shows how to make a Windows 7 gadget that extends its U/I with a flyout panel -- a window that pops out next to the gadget.  The example gadget shows several additional techniques:  How to automatically resize a gadget or flyout panel t…
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…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

771 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now