|
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
|
|
|
|
|
I was getting an access violation if the control didn't have focus and I grabbed the scroll bar box and moved it. Here's why: in HexEditCtrl.cpp, line 1457, if GetFocus() returns NULL (which is happening in my program) the control gets an Access Violation and the program crashes. The fix is to simply call GetFocus separately and check its return value:
CWnd *pFocus = GetFocus();
if (pFocus != NULL) {
if ( pFocus->m_hWnd == m_hWnd )
{
...
If GetFocus returns NULL, just return.
|
|
|
|
|
Thanks very much for the report.
I've applied this fix to the source code. As soon as I get the required number of modifications, I will post the new control version here.
|
|
|
|
|
|
Somehow this reminds me of the good old HexEditCtrl. At least it has a very close similarity, even on code level.
Someone finaly wrote a OCX version of it?
|
|
|
|
|
Yeah but this one aint riddled with bugs. I found the other one impossible to use.
|
|
|
|
|
I backed up to the products level of the URL and found the links for the project and source.
http://www.softerra.com/en/products/hexeditor.php?sID=f9d3d852bee6fbc81c15a967af22d6ff
|
|
|
|
|
...any other broken linx out there ?
|
|
|
|
|
Can this problem corrected ?
Or where is it possible to get the software ?
|
|
|
|