quote:
Originally posted by matty
You should add this by default
http://msdn.microsoft.com/en-us/library/aa383751(VS.85).aspx
Did you see how long that list is? I'll be more than happy if I could implement the most commonly used types, and it still won't be enough.
quote:
Originally posted by SmokingCookie
Wow, looks like I've missed something in the past 36 hours
@Matti: it might come in handy to have something like StructureType.AddDataType(); that accepts a type name, a size and how to write it into the DataBloc obect (ie: using writeDWORD(); or writeSTRING(), or to send a callback function along with it that receives the position and data to write.
That's exactly how I did it. The following comes straight from my implementation:
js code:
DataType.INT = new DataType({
size : 4,
read : function( databloc, position ) {
return databloc.ReadDWORD( position );
},
write : function ( databloc, position, value ) {
databloc.WriteDWORD( position, (1*value) & 0xFFFFFFFF );
}
});
The DWORD implementation maps to the INT functions but also removes the sign from the numbers, so
-2 becomes
0xFFFF FFFE.
On a totally unrelated note then... While I was playing with these signed/unsigned types, I saw that the
code member from NMHDR was defined as a UINT, but could also take signed values (e.g. LVN_COLUMNCLICK = -108) so to get around this, I defined
code as an INT instead. Anyone has a valid explanation for this behavior?
Source: NMHDR on MSDN