|
Simple way of making this work in VB (partly):
Change the SCODE return value of SetData to HRESULT in the ODL and function definition.
I haven't got it fully working with the data yet (my variant becomes "empty")
PS, is there any reason there cursor keys don't work when not selecting anything?
|
|
|
|
|
Simply wondering if you got it to work with VB6..!
TIA.
|
|
|
|
|
I beleive that changing type from SCODE to HRESULT won't help, because VB is a scripting language and so it has some problems with pointer to VARIANT in the SetData method.
Eugene
|
|
|
|
|
Hi Eugene,
is there any chance that you can provide us a vb6-compatible version of your control? It would be great, because i didn't found any other (working) control. Or do you know a vb6-compatible control?
Thank you for any help.
best regards,
Oliver
|
|
|
|
|
hex editor control owns, cept for two bugs..
A) Will not work with bcb6, it is absolutely un-editible in bcb6 for some reason, though the code does compile. Like even if i compile the sample hex editor that you made, it wont be editible, it wont even show the first '0000' when you hit 'new'. wont load files either. wont display anything, wont let you edit anything. just blank whiteness.
B) Im not sure what this bug is. It is kinda weird, and the way i found it was kinda weird. If you select text like highlighted for copy,paste, drag cursor up while selecting text, constantly keep left click held while dragging up, and keep hitting a key like 'a' to erase all the text since everything is selected and gets replaced with 'a', if you keep doing that, after about 2 seconds an access violation will raise. Has somthing to do with the caretpos..
Other then these two bugs the OCX seems to work very well and has all features i need, but i cannot get these 2 bugs out of the way and it makes me want to sta myself in the head with a rusty flathead screwdriver so please fix =(
-JojoII
Thou shalt fear the rhythm of my algorithm.
|
|
|
|
|
|
I download the OCX and the demo. The HexEditorDemo.exe can run and work well.
I have compiled and built the demo successfully. It can run. But when load a file or New a file, it can not work. No errors warning. Nothing happend.
why?
thank you!Your code is very good!
|
|
|
|
|
I am having the same problem. The demo .exe works properly, but if I recompile the demo from source in C++Builder 6, it will not work. I have the same problem in my own program - I can call About() and the dialog will be shown, no problem, but calling SetData() seems to do nothing. Any help?
|
|
|
|
|
Hey man,
that's exactly the piece of code I needed. Thanx alot. My skillness in C++ is not sufficient to refund u, but I'll offer u a drink for sure when u come in Italy. Thanx again
|
|
|
|
|
I had use it as a subclass of Cwnd,it can work. But I don't know haw to resize the control when the View's size changed! Thinks!
|
|
|
|
|
Just resize your CWnd object when size of CView has changed... I can't see any problems here.
Eugene
|
|
|
|
|
|
Thanks! The link will be corrected
Eugene
|
|
|
|
|
It seems that the control doesn't work in Visual Basic 6.0. For SetData() method the compiler says "Unknown Automation type"
|
|
|
|
|
Unfortunately, you can't use the SetData() method in script languages. But, since you have the source code of the control, you can declare and implement another method that sets data but has compatible types for its parameters.
Eugene
|
|
|
|
|
Your control is definitely an improvement over several others that I have seen; however, there are some issues. You consistently (and incorrectly) use m_allowChangeSize. This feature does not work the way you shipped the control. You used the || operator instead of the && operator. Here are the following changes to correct this (Note: some line numbers are different since I made other changes as well).
Line 760: if ( (m_editMode & EDIT_INSERT) && m_allowChangeSize )
Line 778 if ( (m_editMode & EDIT_INSERT) && m_allowChangeSize )
Line 1056: if ( (m_editMode & EDIT_INSERT) && m_allowChangeSize )
Line 1252: pCmdUI->Enable(!IsSelectionEmpty() && ((m_editMode & EDIT_INSERT) && m_allowChangeSize));
Line 1793: if ( (m_editMode & EDIT_INSERT) && m_allowChangeSize )
Line 1777: if ( (m_editMode & EDIT_INSERT) && m_allowChangeSize )
Line 191: m_editMode = EDIT_BYTES /*| EDIT_INSERT */;
Line 831: case VK_INSERT:
if(m_allowChangeSize) <-- Insert this
Some other suggestions for furure updates (I changed most of these myself, so I have the code):
1. Different colors for address, data, and ascii
2. Allow ascii to be shown even when data is not in bytes
3. Chanaged values could also be another color
4. Coloring of a sentinel (one specific value that will be colored a certain color)
5. Address size (by this I mean, don't always assume that the user wants the address of bytes, in my case I wanted the address of WORD size registers.)
6. Boundschecker found a few errors and leaks, nothing major though
Thats it for now! Keep up the good work, most of the code is pretty well written.
|
|
|
|
|
Has anyone gotten this to work in a C# Form. I've been able to place it on the Form and gotten a "private AxHEXEDITLib.AxHexEdit ctlHexEditor;" although it's made the SetData method as:
public virtual System.Int32 SetData ( System.Object pData , System.Int32 dwStartAddr )
How do I pass a Byte [] to this function?
|
|
|
|
|
I'm also trying to use it from C#.
I cannot seem to get the SetData function to work.
Anyone had successfull experience with this control in C#. (especially SetData)
Any help is welcome.
TIA,
Dennis
|
|
|
|
|
|
Thanks for the link Eugene.
I wish I could use the control in C#, but I guess I'll have to look for another way to do it.
Dennis
|
|
|
|
|
OK, please let us know if you succeed.
Eugene
|
|
|
|
|
I have gotten this to work in a C# Form, but I had to do some changes in the OCX to succeed.
The problem is that the SetData method uses a pointer to the actual data and that cannot be passed between managed (C#) and unmanaged (the OCX) code. To solve it I changed the SetData method to take a copy of the data and added a GetData method to get the modified data back. Here's my changes:
HexEdit.odl
<small><br />
[id(9)] SCODE SetData(VARIANT data, long dwStartAddr);<br />
[id(10)] VARIANT GetData();<br />
</small>
HexEdit.h
<small><br />
...<br />
afx_msg SCODE SetData(const VARIANT FAR& data, long dwStartAddr);<br />
afx_msg VARIANT GetData();<br />
<br />
...<br />
dispidGetData = 10L,<br />
</small>
HexEdit.cpp
<small><br />
...<br />
DISP_FUNCTION(CHexEditCtrl, "SetData", SetData, VT_ERROR, VTS_VARIANT VTS_I4)<br />
DISP_FUNCTION(CHexEditCtrl, "GetData", GetData, VT_VARIANT, VTS_NONE)<br />
...<br />
<br />
SCODE CHexEditCtrl::SetData(const VARIANT FAR& data, long dwStartAddr) <br />
{<br />
if ( data.vt != (VT_ARRAY | VT_UI1) || ::SafeArrayGetDim(data.parray) != 1)<br />
{<br />
return E_INVALIDARG;<br />
}<br />
m_data = data;
...<br />
}<br />
<br />
VARIANT CHexEditCtrl::GetData() <br />
{<br />
VARIANT vaResult;<br />
VariantInit(&vaResult);<br />
vaResult = m_data;<br />
return vaResult;<br />
}<br />
</small>
Setting the data in C# is easy:
<br />
byte[] data = ...<br />
this.axHexEdit.SetData(data, 0);<br />
Getting the data back requires a type cast:
<br />
data = (byte[])this.axHexEdit.GetData();<br />
Works like a charm!
|
|
|
|
|
Thanks for the update. However, there must have been an update to the source. All of Johan Olsson changes can now be found in file HexEditCtl.cpp & .h
Hope that helps with the confusion.
|
|
|
|
|
Thankyou sir...
started making those changes myself, only to find you've already done it.
+5
|
|
|
|
|
Hi,
Thanks for the fix for the hexedit component.
One thing though, every time I copy the modified data from the hexedit component back into the original buffer, then try and show the new buffer in hexedit component at a later time, it crashes with a couple of different errors.
One time I got an Array is locked exception, the next time I got a corrupt memory exception.
Again, the usage pattern is
axHexEdit.SetData(buffer, 0);
//User modifies the data
if (modified)
buffer = (byte[])this.axHexEdit.GetData();
// Sometime later user requests to hexedit the buffer.
//Crashes
axHexEdit.SetData(buffer, 0);
Any ideas?
Thanks,
Rich
|
|
|
|