CyberPeter 11 Posted March 6, 2023 Is anybody aware of a (relatively) simple Hex View 'component' based on VCL ? I don't need much. Just a fancy view of a block of data that my application provides (Buffer). The typical hex edit look. Select something in the data block and the corresponding text block on the right gets highlighted as well. Perhaps some tweaking, colors, font etc. No file IO, no editing, no search functionality etc. Mapping a structure against the data is a wet dream for later. At the moment I simply display text in a TMemo but if there's something out there that I can use without reinventing the wheel, that would be nice. I don't like to install a component per se, I much rather prefer to instantiate a class, but I use C++ Builder (11.3) so that would rule out Delphi then (?) Or better, perhaps I can build a Lib/a from pas files and include that in my project (assuming that works - no experience with Delphi really). I realize most people here use Delphi, not C++ Builder, but there is enough synergy I think to wager this question ? I have been searching without much success. This is a last sanity check before I give up and move on to something else 🙂 Share this post Link to post
CyberPeter 11 Posted March 6, 2023 Thank you for the suggestion KodeZwerg. I actually did run into this one, a long time ago, so I didn't really consider it this time, during my search. But I should. I'll look into it shortly. I also found a conversion of this particular component into c++ via an automated tool. I tried it in CB2009 and while it compiled, it did not work properly. I will look into it again however. It's dated, so I hope it compiles, not being very Delphi savvy (if at all) and hence clumsy at trying to 'fix' it. I do seem to recall the hex view selection not being smooth across bytes, rather one (or more) individual bytes (cells) are selected with space in between. Share this post Link to post
dummzeuch 1517 Posted March 6, 2023 5 hours ago, CyberPeter said: I much rather prefer to instantiate a class, but I use C++ Builder (11.3) so that would rule out Delphi then (?) Isn't C++ Builder also capable of compiling and using Delphi code? If I remember correctly it uses the VCL without any modifications. But I don't know specifics, I only ever wrote one C++ Builder program. Share this post Link to post
CyberPeter 11 Posted March 6, 2023 1 minute ago, dummzeuch said: Isn't C++ Builder also capable of compiling and using Delphi code? Yes, it looks that way. Playing with it now. I thought it only supported it in components that need to be installed. Share this post Link to post
CyberPeter 11 Posted March 6, 2023 5 hours ago, KodeZwerg said: Does ATBinHex fit your needs? Well, I can get it to work ! Of course with Styles it's going to stick out like a sore thumb And I'm not wild about the selection functionality: But it's certainly a candidate. I'd have to inherit from TStream then to integrate it in a project where data is read into a buffer. If there are other candidates, I'd like to know, I'm not 'in love' (yet) with this one 😉 Share this post Link to post
aehimself 399 Posted March 6, 2023 VCL styling issue can easily be fixed: TStyleManager.Engine.RegisterStyleHook(TATBinHEX, TScrollingStyleHook); And of course: ATBinHex.Color := TStyleManager.ActiveStyle.GetStyleColor(scEdit); ATBinHex.TextColorHexBack := TStyleManager.ActiveStyle.GetStyleColor(scEdit); ATBinHex.Font.Color := TStyleManager.ActiveStyle.GetStyleFontColor(sfEditBoxTextNormal); ATBinHex.TextColorHex := TStyleManager.ActiveStyle.GetStyleFontColor(sfEditBoxTextNormal); ATBinHex.TextColorHex2 := TStyleManager.ActiveStyle.GetStyleFontColor(sfEditBoxTextNormal); Share this post Link to post
GPRSNerd 12 Posted March 6, 2023 21 minutes ago, aehimself said: VCL styling issue can easily be fixed: TStyleManager.Engine.RegisterStyleHook(TATBinHEX, TScrollingStyleHook); And of course: ATBinHex.Color := TStyleManager.ActiveStyle.GetStyleColor(scEdit); ATBinHex.TextColorHexBack := TStyleManager.ActiveStyle.GetStyleColor(scEdit); ATBinHex.Font.Color := TStyleManager.ActiveStyle.GetStyleFontColor(sfEditBoxTextNormal); ATBinHex.TextColorHex := TStyleManager.ActiveStyle.GetStyleFontColor(sfEditBoxTextNormal); ATBinHex.TextColorHex2 := TStyleManager.ActiveStyle.GetStyleFontColor(sfEditBoxTextNormal); Where did you put this additional code? In the component or in the program in the FormShow() or FormCreate() event? Share this post Link to post
aehimself 399 Posted March 6, 2023 The first one is in my "uFixVCLStyles" unit initialization section. The second block is in the window / form constructor. Unfortunately coloring won't change if a different style is selected runtime and an ATBinHex component is already visible, but you can solve this by handling the CM_STYLECHANGED message and put the recoloring code in there. Share this post Link to post
Bill Meyer 337 Posted March 6, 2023 Have not used this, but may be worth a look: https://github.com/zhugecaomao/HexEditor Share this post Link to post
CyberPeter 11 Posted March 6, 2023 12 hours ago, aehimself said: VCL styling issue can easily be fixed: ... Oh, thanks for that !! I'll check it out. Share this post Link to post
CyberPeter 11 Posted March 6, 2023 10 hours ago, David Champion said: While very impressive, it seems a bit excessive for my needs (assuming I'd be allowed to integrate that in another app) Share this post Link to post
CyberPeter 11 Posted March 6, 2023 2 hours ago, Bill Meyer said: Have not used this, but may be worth a look: https://github.com/zhugecaomao/HexEditor I wish the author had included a few screenshots. I'll have a look, thanks for the suggestion. Share this post Link to post
Bill Meyer 337 Posted March 6, 2023 1 minute ago, CyberPeter said: I wish the author had included a few screenshots. I'll have a look, thanks for the suggestion. Would have been nice. Of those I found, it was the most recently updated. Share this post Link to post
CyberPeter 11 Posted March 7, 2023 14 hours ago, aehimself said: TStyleManager.Engine.RegisterStyleHook(TATBinHEX, TScrollingStyleHook); This is going to be harder for me, not being versed in Delphi. I looked it up and it appears TATBinHex needs to inherit from TStyleHook https://docwiki.embarcadero.com/Libraries/Sydney/en/Vcl.Themes.TStyleHook I'm already glad I managed to 'fix' the *.pas files enough so that I could build them into a lib/a file 🙂 Could you share the changed *.pas file where this change is made ? Things are looking better with the suggested color changes. I just wish the binary selection was contiguous, not be per byte/cell. Share this post Link to post
CyberPeter 11 Posted March 7, 2023 5 hours ago, Bill Meyer said: Have not used this, but may be worth a look: https://github.com/zhugecaomao/HexEditor Too many errors when trying to build with C++ Builder 11.3 Not knowing much about Delphi syntax this currently is too much an uphill battle, especially because the result (look / feel) is a big unknown. Share this post Link to post
Bill Meyer 337 Posted March 7, 2023 50 minutes ago, CyberPeter said: Too many errors when trying to build with C++ Builder 11.3 Not knowing much about Delphi syntax this currently is too much an uphill battle, especially because the result (look / feel) is a big unknown. Yes, understood. As far as I know, C++ Builder supports a subset of Delphi, not everything. But that knowledge is from years ago. Share this post Link to post
CyberPeter 11 Posted March 7, 2023 (edited) 1 hour ago, Bill Meyer said: Yes, understood. As far as I know, C++ Builder supports a subset of Delphi I'm convinced Delphi would run into the same problems. The code is simply too old (2007) and hence dates back from before proper Unicode implementation etc. For a Delphi developer it's probably not that difficult to update the code. Edited March 7, 2023 by CyberPeter Share this post Link to post
Bill Meyer 337 Posted March 7, 2023 1 hour ago, CyberPeter said: I'm convinced Delphi would run into the same problems. The code is simply too old (2007) and hence dates back from before proper Unicode implementation etc. For a Delphi developer it's probably not that difficult to update the code. The author has provided email addresses, and it may be worth dropping a note. Some projects have been updated in the last 30 days. Share this post Link to post
CyberPeter 11 Posted March 7, 2023 4 minutes ago, Bill Meyer said: Some projects have been updated in the last 30 days. Oh .. I notice he has something recent as well: https://github.com/zhugecaomao/BCHexEditor Will have a look Share this post Link to post
CyberPeter 11 Posted March 7, 2023 2 hours ago, CyberPeter said: Oh .. I notice he has something recent as well: https://github.com/zhugecaomao/BCHexEditor Will have a look It compiles fine but for whatever strange reason I can't instantiate the TBCHexEditor class ? The error suggests pure virtual functions ? In a component class ? I don't think so. That one has got me puzzled. There is also a TBCHexEditorEx class that I haven't tried yet. The total absence of any documentation is annoying. No idea what the difference between the two versions is ? Meanwhile my day (and concentration) is almost at an end. Share this post Link to post
aehimself 399 Posted March 7, 2023 7 hours ago, CyberPeter said: Could you share the changed *.pas file where this change is made ? I didn't change the component source, just cloned the repo from GitHub and installed it in Delphi. All the code I mentioned is in my application. It's a good thing because it's completely detached from the component. It's bad, because those have to be included in each application you use ATBinHex in. You can make a class helper with a public .Recolor method so you easily can recolor each instance after the style changed. You also can take it one step further, create your own ATBinHex descandant, and use AllocHWND to listen for CM_STYLECHANGED and recolor automatically. You still have to register the style hook somewhere else though. I continuously got AVs if I included it in the helper class constructor / unit initialization section. 8 hours ago, CyberPeter said: I looked it up and it appears TATBinHex needs to inherit from TStyleHook You need ScrollingStyleHook, otherwise scrollbars won't be themed AFAIK. Share this post Link to post
CyberPeter 11 Posted March 7, 2023 4 minutes ago, aehimself said: You need ScrollingStyleHook, otherwise scrollbars won't be themed AFAIK. Right. The thing is, Builder doesn't like my code and I don't understand why ? Vcl::Themes::TStyleManager::Engine->RegisterStyleHook(TATBinHex, TScrollingStyleHook) ; [C++ Error] main.cpp(30, 54): 'TATBinHex' does not refer to a value [C++ Error] main.cpp(30, 65): 'TScrollingStyleHook' does not refer to a value I thought the pas file needed to change but if you say that is not the case then I'm not sure what to do with this. Obviously I'm not fully up to speed on Styles in custom components. The Embarcadero documentation tends to be horrible for c++ Builder users. Share this post Link to post
aehimself 399 Posted March 7, 2023 You probably need to include ATBinHex and Vcl.Forms in your uses (include) list. Being a Delphi-only guy I'm afraid I'll not be able to give you the exact code for C++ projects 😞 Share this post Link to post