Hex Viewer / Editor - Page 3
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 3 of 5 FirstFirst 12345 LastLast
Results 31 to 45 of 67

Thread: Hex Viewer / Editor

  1. #31
    Join Date
    Jun 2005
    Location
    JHB South Africa
    Posts
    3,772

    Re: Hex Viewer / Editor

    Quote Originally Posted by WizBang
    Nice to see an update on this

    Anyway, I saw this in your BinaryToHex function:
    Code:
    Do
      sPart = Mid(sBinVal, iPos, 4)
      sHex = sHex & BinToHex(sPart)
      iPos = iPos + 4
      If iPos > ilg Then Exit Do
    Loop
    It doesn't take full advantage of the Do...Loop structure.


    Also found two bugs:
    1) If you click File >> Open... but cancel, the file you are looking at is no longer "enabled", and you have to open it again.
    2) The scrollbar (nice feature I've been waiting for) always seems to scroll past the end of the file until the valid part goes off the screen. Is that on purpose for some reason?

    I'll try to take a more in-depth look a bit later...keep up the good work!
    Wow you find them Fast....

    Bug 1) Oops didn't notice this.. Fixed it (No need to repost Just for this...)

    Bug 2) This actualy is not a bug.. I let it scroll till at least the Last Byte of the file is on the top line... (To take full advantage of the fact you can extend the size of the file...)

    The Hex_Dex_Functions module is Curtacy JonnPoet... (Stated in file too) I borrowed his module to use some of the functions he worked out, but I dont use them all, and should remove the unused functions. And try to tweek the ones i do use... Thanks for that one... And again Thanks to JonnyP for the Module....

    AND Thanks to you Wizbang, and all the others, for all the help.. In reality its because of people like you that Great Software gets developed..
    And its because of places like CG that Great Code gets shared and Tweeked to perfection...
    Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
    WPF Articles : 3D Animation 1 , 2 , 3
    Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
    Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
    All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.

  2. #32
    Join Date
    Dec 2001
    Posts
    6,332

    Re: Hex Viewer / Editor

    Quote Originally Posted by GremlinSA
    Bug 2) This actualy is not a bug.. I let it scroll till at least the Last Byte of the file is on the top line... (To take full advantage of the fact you can extend the size of the file...)
    I figured you might have a reason for it. Anyway, you need to have some way to distinguish between the end of the file and the "nothingness" afterward. Right now it looks like the end of the file has a bunch of zeros in it. Since appended data would only be placed just after the current end of the file anyway, you would only need to allow the cursor to be placed after the last byte. So having it scroll like that isn't necessary for the UI to make it work. Therefore I'm guessing it's a matter of how you are actually enabling the appending of new data. If you need it to scroll that way, suppose you leave that part blank, instead of filling it with zeros? How does it operate if the user pastes data into the middle of the extra zero's? From a user's point of view, it can be confusing/misleading the way it is as of now.
    Please remember to rate the posts and threads that you find useful.
    How can something be both new and improved at the same time?

  3. #33
    Join Date
    Jun 2005
    Location
    JHB South Africa
    Posts
    3,772

    Re: Hex Viewer / Editor

    Okay .. I made a small Change in the code.. Any Hex data that is not in the file is now colored green.. So it's still there for editing but a diffrent color -- Also scrolling to the end of the file with the srollbar will put the markers at the end of the file..

    Ahh pasting data at the end of the file... I let the user paste data at any point in the extra area.. (Maybe you need your data at a specific file pos (Files that use pointers??).)

    I think the diffrent colors could now resolve this problem..

    Still adding the coloring to the editting code.. at this moment..

    (also found a small bug in the scroller... If you scroll to the bottom sometimes it erorrs out.. (Picked this up with the coloring code )

    Thanks....

    Gremmy..

    Will post when got a Colourfull update..


    --- Edit ---

    Reattached file in previous post -- No need for new post..
    Last edited by GremlinSA; January 24th, 2006 at 05:52 AM.
    Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
    WPF Articles : 3D Animation 1 , 2 , 3
    Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
    Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
    All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.

  4. #34
    Join Date
    Jun 2005
    Location
    JHB South Africa
    Posts
    3,772

    Re: Hex Viewer / Editor

    Right...

    The Final Project... (I hope)

    Cleaned it up a bit...

    Coloring happens at all the right places... The Screen jitter is now taken care off..

    Position is updated correctly as well..

    Some redundant code is removed..

    Enjoy.....

    Gremmy..

    --- Edit ----

    New file in later post....
    Last edited by GremlinSA; February 1st, 2006 at 06:11 PM.
    Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
    WPF Articles : 3D Animation 1 , 2 , 3
    Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
    Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
    All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.

  5. #35
    Join Date
    Dec 2001
    Posts
    6,332

    Re: Hex Viewer / Editor

    Hate to have to tell you, but I ran into an error already. I just opened a file, scrolled to the bottom, and it had an error in the Read_Data sub.

    I do like the use of the Enums and UDT's though. That's new, yes?
    Please remember to rate the posts and threads that you find useful.
    How can something be both new and improved at the same time?

  6. #36
    Join Date
    Jun 2005
    Location
    JHB South Africa
    Posts
    3,772

    Re: Hex Viewer / Editor

    Quote Originally Posted by WizBang
    Hate to have to tell you, but I ran into an error already. I just opened a file, scrolled to the bottom, and it had an error in the Read_Data sub.

    I do like the use of the Enums and UDT's though. That's new, yes?
    Wow but you do find them Fast...

    I had to open three diferent files to get that error... (a Big Zip file did it for me).. was a problem with the code i used to put the cursor on the last byte of the file... (Looks like Big files still tend to slip over the top when scrolling to the end )
    But i found it and compensated for it.. I've debuged the scrollling code for so long i think even my wife is seeing black and yellow poka dots when she closes her eyes..

    The UDT's and Enums have been there for a while.. (I think Ver 6 or 7) but yes they are new... While in the read_data sub... See how i sorted out the Flicker problem...

    Thanks for all the help...
    Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
    WPF Articles : 3D Animation 1 , 2 , 3
    Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
    Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
    All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.

  7. #37
    Join Date
    Dec 2001
    Posts
    6,332

    Re: Hex Viewer / Editor

    OK. I'll give it a shot. I guess I should also have mentioned that the file I opened was the zip file of project itself! As for the cause, my initial thought is that since the scrolling is trying to go line-by-line, if a file's size puts the last byte in a particular place in the line, the scrollbar's max value gets rounded up.

    I still don't like the thing scrolling up to the top that way. If the user wants to append zeros, why couldn't they place the cursor at the end, and use an editing function like "Insert Bytes...", or paste, etc? Seems to me it makes more sense to someone editing a file with a Hex editor. That's my opinion of course. Maybe others will chime in with their thoughts.
    Please remember to rate the posts and threads that you find useful.
    How can something be both new and improved at the same time?

  8. #38
    Join Date
    Dec 2001
    Posts
    6,332

    Re: Hex Viewer / Editor

    Well, here we go again...

    I opened the project's zip, scrolled to the bottom - no error...except: The entire thing turns green, not just the "fake" zero's part. Then clicking the up arrow of the scrollbar, the cursor turns to an I-Bar Only when the "ghost zero's" are off the screen does the rest turn black again. That makes it far more difficult to know where the real file's end is. However, if I drag the scrollbar button up, then release, all the bytes stay green and stay that way until I go back to the bottom and use the up arrow.

    Maybe the "rendering code" needs a different approach?
    Please remember to rate the posts and threads that you find useful.
    How can something be both new and improved at the same time?

  9. #39
    Join Date
    Jun 2005
    Location
    JHB South Africa
    Posts
    3,772

    Re: Hex Viewer / Editor

    Quote Originally Posted by WizBang
    OK. I'll give it a shot.

    I still don't like the thing scrolling up to the top that way. If the user wants to append zeros, why couldn't they place the cursor at the end, and use an editing function like "Insert Bytes...", or paste, etc? Seems to me it makes more sense to someone editing a file with a Hex editor. That's my opinion of course. Maybe others will chime in with their thoughts.
    Okay made a Big change here ... Scrolls only Half way up... So you got a at least half a screen of real data... Changed the color from green to a Light grey.

    Quote Originally Posted by WizBang
    I opened the project's zip, scrolled to the bottom - no error...except: The entire thing turns green, not just the "fake" zero's part. Then clicking the up arrow of the scrollbar, the cursor turns to an I-Bar Only when the "ghost zero's" are off the screen does the rest turn black again. That makes it far more difficult to know where the real file's end is. However, if I drag the scrollbar button up, then release, all the bytes stay green and stay that way until I go back to the bottom and use the up arrow.

    Maybe the "rendering code" needs a different approach?
    .. Took your advice... and reworked alot of the code in the rendering. Also not to sure about the color problem you had, Could not for the life of me get it to happen.. (tried 7 different files), Must be a difference in control versions ???

    But i think the reworked code should not cause this anymore..

    Also sorted out a lot of little coding nigglies that bugged me, (Lot more Form Variables and Less sub/Function variables.. (Cut out about 2K of near duplicate code)

    It also looks like the Paste/ Fill / Delete popups are now running a dash faster..

    I hope I'm not expecting too much from you, because writing this little app i've already far surpassed what i was expecting from it when i did the first post, And i've learnt so much, Looking for better methods to do some of the old tried and trusted (Long winded) methods.

    Agian Hopefully the Last Update...

    ------ EDIT ---------

    Nope.... Newfile on later post....
    Last edited by GremlinSA; February 3rd, 2006 at 08:51 PM.
    Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
    WPF Articles : 3D Animation 1 , 2 , 3
    Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
    Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
    All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.

  10. #40
    Join Date
    Dec 2001
    Posts
    6,332

    Re: Hex Viewer / Editor

    Seems like there's still something with the color code stuff.

    I opened the zip for the project in the editor, dragged the scrollbar all the way to the bottom, and it did have the half page of "ghost bytes" properly colored. However, the moment I clicked the up arrow of the scrollbar, everything turned to the color of the ghost bytes, and stayed that way. I closed the file, and opened one again - the bytes all remained in the same incorrect color.

    That's as far as I went with the testing.

    <EDIT>
    It just so happens that I wanted to edit a file only a few moments ago, so I thought I'd give the editor a try on it. The integrity of the file didn't matter, as it was a test of something I'm working on. I opened the file, and did a search for the part to edit. I got an error immediately. It was because the scrollbar is using an integer for the Max property. This can be fixed easily by setting a Long variable to the value of the property, and using that instead. Since I was now in Debug mode, I altered the code to CLng(Scroll_Pos.Max), which got around it.

    Anyway, I then was able to edited the first of two parts of the file. However, once I hit Ctrl+G to locate the next part, the "Functions" menu was disabled, meaning I could not save the changes to the file. After editing the second part, I went back to see the first part just in case, and it had reverted back to the original! So, in order to edit the file, I needed to make one change at a time, and save each before even locating the next.

    I also found it quite distracting to have the colors change whenever I navigated off the boxes to use the scrollbar, so I set the TabStop property to False, which resolved that in a hurry. It also gets rid of that annoying blinking scrollbar button

    This was my first actual practical application of the editor.
    Last edited by WizBang; February 2nd, 2006 at 03:38 PM.
    Please remember to rate the posts and threads that you find useful.
    How can something be both new and improved at the same time?

  11. #41
    Join Date
    Jun 2005
    Location
    JHB South Africa
    Posts
    3,772

    Re: Hex Viewer / Editor

    I have no cooking clue as to why you got the color problem... I've now steptraced the proggy and cannot for the life of me find it... (I think i need to set up a system simular to yours to find it... Can you let me know what system, OS, and VB + SP numbers you got... (also i'm using Richtx32.ocx ver 6.0.81.69), maybe theres something different in there....

    I'm going to look at it in the morning.. as see if i cant sort it out then ....

    I re wrote some of the Sort code and left 1 line out... the File write command... so that was easy...

    Also another bug i found while checking it... Try pressing Backspace in the Asci Side... 1 extra line of code in there ....

    The scroller needs a whole new coding.... until you mentioned it, I forgot that the scroller is a Integer. I use it's value * 16 ( One line in narrow mode..) giving a total file size of 512K (524288) .. Just as well i wasn't using the value for actual.. )

    Unless you got a beter Idea, I'm thinking of checking the File size and adjusting the scrolers multiplier according to the file size... in steps... something like
    Code:
      File-Size 	Multiplier
     <524,272 	16
     <8,388,352 	256
     <134,213,632 	4096 
     <536,854,528 	16384
     <2,147,418,112 	65536
    Ahh and setting the Scrollers TabStop property has taken care of a lot of other little funnies that were happening...

    Will let you know...
    Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
    WPF Articles : 3D Animation 1 , 2 , 3
    Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
    Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
    All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.

  12. #42
    Join Date
    Dec 2001
    Posts
    6,332

    Re: Hex Viewer / Editor

    I'd think it must be coding that causes the color problem, since the color is changing, and that only happens via code. My RTB version is 6.00.8804, so I guess your number was parsed differently. I copied it directly off the file properties dialog. The file date is 5/22/2000. Your number seems to equate to 6.00.8169, which I find is from 6/24/1998. Still, I'd be more than surprized if the version has anything to do with it.

    Maybe later I'll put a watch on the color code, and see what shows up.

    Unless you got a beter Idea, I'm thinking of checking the File size and adjusting the scrolers multiplier according to the file size... in steps...
    That further complicates scrolling. I'd again recommend the Long variable (Currency seems like overkill IMHO). Just set it anytime you set the Max, and use it in place of the property.
    Please remember to rate the posts and threads that you find useful.
    How can something be both new and improved at the same time?

  13. #43
    Join Date
    Jun 2005
    Location
    JHB South Africa
    Posts
    3,772

    Re: Hex Viewer / Editor

    Quote Originally Posted by WizBang
    I'd think it must be coding that causes the color problem, since the color is changing, and that only happens via code. My RTB version is 6.00.8804, so I guess your number was parsed differently. I copied it directly off the file properties dialog. The file date is 5/22/2000. Your number seems to equate to 6.00.8169, which I find is from 6/24/1998. Still, I'd be more than surprized if the version has anything to do with it.
    I guess your right. Just updated rt.....ocx - To .9782 (2004). No difference on my side... Still runs 100%.. so yes there is a problem in my coding but where and why ... I dont know... (Maybe in the read_data sub, i must explisitly set the black color... )

    Quote Originally Posted by WizBang
    Maybe later I'll put a watch on the color code, and see what shows up.
    If you could do that for me it would be wonderfull... I'll really appreciate it..

    Quote Originally Posted by WizBang
    That further complicates scrolling. I'd again recommend the Long variable (Currency seems like overkill IMHO). Just set it anytime you set the Max, and use it in place of the property.
    I've decided to leave the maxfile size at the 2 Gig limit.. (Anything bigger than that.. is actually madness..) bring everything back to Long.. (Also the API File Reads need a slightly different method to read past the 2gig limit. (And i dont think it's worth adding a second Variable to monitor for 'lpDistanceToMoveHigh' variable..)

    For the scroller i need to be able to Convert the scrollers Integer to a Long, unless theres a sroller with Long variables.. it's the only method i can think of.. (PS. i checked my Dos Hex editor (Norton's DE) and they use a multiplier in much the same way as i proposed..)


    Thanks again for all your help...
    Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
    WPF Articles : 3D Animation 1 , 2 , 3
    Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
    Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
    All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.

  14. #44
    Join Date
    Dec 2001
    Posts
    6,332

    Re: Hex Viewer / Editor

    Quote Originally Posted by GremlinSA
    For the scroller i need to be able to Convert the scrollers Integer to a Long, unless theres a sroller with Long variables.. it's the only method i can think of.. (PS. i checked my Dos Hex editor (Norton's DE) and they use a multiplier in much the same way as i proposed..)
    Like I posted earlier, you can just use a Long variable. No mystery involved.

    Here's the way I edited the code when I was in Debug:
    Code:
    Private Sub Next_Block()
    If File_Change Then Write_Data (File_Pos)
    File_Pos = File_Pos + Tot_Count
    If File_Pos > (CLng(Scroll_Pos.Max) * 16) Then
        File_Pos = (CLng(Scroll_Pos.Max) * 16)
    End If
    Read_Data File_Pos
    End Sub
    However, it would be more efficiant to use a Long. Either declare one form-wide, or in the subs that need it, like this:
    Code:
    Private Sub Next_Block()
    If File_Change Then Write_Data (File_Pos)
    Dim I As Long
    I = Scroll_Pos.Max
    File_Pos = File_Pos + Tot_Count
    If File_Pos > I * 16 Then
        File_Pos = I * 16
    End If
    Read_Data File_Pos
    End Sub
    That's all there is to it, though the Next_Search_Block sub needs the fix too.
    Please remember to rate the posts and threads that you find useful.
    How can something be both new and improved at the same time?

  15. #45
    Join Date
    Jun 2005
    Location
    JHB South Africa
    Posts
    3,772

    Re: Hex Viewer / Editor

    Quote Originally Posted by WizBang
    Like I posted earlier, you can just use a Long variable. No mystery involved.

    Here's the way I edited the code when I was in Debug:
    Code:
    Private Sub Next_Block()
    If File_Change Then Write_Data (File_Pos)
    File_Pos = File_Pos + Tot_Count
    If File_Pos > (CLng(Scroll_Pos.Max) * 16) Then
        File_Pos = (CLng(Scroll_Pos.Max) * 16)
    End If
    Read_Data File_Pos
    End Sub
    However, it would be more efficiant to use a Long.
    I adjusted the code like that.. But still 1 small problem ... Integer max = 32767... Scroll_Pos.Max * 16 = a limit of 524K..

    So if you open a file of 600K you can only view the first 524K..

    Any Luck on finding why the color goes funny.. (try taking the hexD.visible = True / False out )

    Grem...
    Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
    WPF Articles : 3D Animation 1 , 2 , 3
    Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
    Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
    All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.

Page 3 of 5 FirstFirst 12345 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center