Solved

Hex editor - CEditView in a CFormView?

Posted on 1998-07-28
8
376 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
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

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

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Suggested Solutions

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.…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

696 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