Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Hex editor - CEditView in a CFormView?

Posted on 1998-07-28
8
Medium Priority
?
382 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
Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

 
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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

This article describes how to add a user-defined command button to the Windows 7 Explorer toolbar.  In the previous article (http://www.experts-exchange.com/A_2172.html), we saw how to put the Delete button back there where it belongs.  "Delete" is …
For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
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…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

610 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