GUID variable handling is not consitent with the rest of the variable types
There is an issue with GUID handling, the following code demonstrates the problem:
Uses "Console"
' -- Classic Long variable
Dim lVar As Long
PrintL SizeOf(lVar), SizeOf(Long), "<-- should match, it does, GOOD"
' -- Long in UDT
Type tWithLong
longItem As Long
End Type
Dim lVarFromType As tWithLong
PrintL SizeOf(lVarFromType), SizeOf(tWithLong), "<-- should match, it does, GOOD"
' -- Classic GUID variable
Dim gVar As Guid
PrintL SizeOf(gVar), SizeOf(Guid), "<-- should both equal to 16, it doesn't :("
' -- GUID in UDT
Type tWithGUID
guidItem As Guid
End Type
Dim gVarFromType As tWithGUID
PrintL SizeOf(gVarFromType), SizeOf(tWithGUID), "<-- should both equal to 16, it doesn't :("
WaitKey
The most troubling part is the UDT integration, but the good news is that there is possible workaround. Instead of dimensioning UDT property AS GUID, you might use AS STRING * 16.
It will have the expected effect and the problem with incorrect UDT size will go away.
I should have implemented GUID assignment and data retrieving for standard GUID variables also when included inside UDT.
Example:
USES "CONSOLE"
' -- GUID in UDT
Type tWithGUID
guidItem As Guid
oID1 As Guid
oID2 As Guid
stringitem As String * 16
End Type
Dim gVarFromType As tWithGUID
gVarFromType.oID1 = Guid$("{01234567-89AB-CDEF-FEDC-BA9876543210}")
gVarFromType.oID2 = Guid$("The GUID we need is shown as {0123456789ABCDEFFEDCBA9876543210}")
'---Full UDT
PrintL SizeOf(gVarFromType), SizeOf(tWithGUID), "<-- should both equal to 32"
'---Single elements
PrintL SizeOf(gVarFromType.guidItem), SizeOf(gVarFromType.stringitem), "<-- should both equal to 16"
PrintL "GUID1", GuidTxt$(gVarFromType.oID1)
PrintL "GUID2", GuidTxt$(gVarFromType.oID2)
WaitKey
according to my tests the GUIDs work as expected.
I tried your example, where I get correct sizes 64 & 16, and also the José's GDI+ samples seem to behave as they should :)