Solved

Hex editor - CEditView in a CFormView?

Posted on 1998-07-28
8
370 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
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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Windows Installer 4 69
C# Performance testing with Visual Studio Profession 2015 2 39
dialer.exe 4 58
ClickOnce Install - Shortcut Question 3 73
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.…
If you have ever found yourself doing a repetitive action with the mouse and keyboard, and if you have even a little programming experience, there is a good chance that you can use a text editor to whip together a sort of macro to automate the proce…
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…
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

896 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

15 Experts available now in Live!

Get 1:1 Help Now