I'm using a cImageContainer to display an image from memory, in a regular DF dialog.
Everything seems to work, but I'm not quite clear if I have the stream functions working so as to avoid memory leaks.
Code in question below:
//Assume that ucImage is a bitmap stored as a uChar[]
//Assume this is running in an otherwise unmodified cImageContainer class
//Note this is similar to procedure Read_Data in cDbImageContainer

uChar[] ucImage
Handle hImage
pointer pImage pStream
integer iRet
//...... stuff happens....
//At this point, ucImage is populated
Move (GlobalAlloc(GMEM_MOVABLE ior GMEM_ZEROINIT, (SizeOfArray(ucImage)) to hImage
Move (GlobalLock(hImage)) to pImage
Move (CopyMemory(pImage,(AddressOf(ucImage)),SizeOfArray(ucImage)) to iRet
Move (GlobalUnlock(hImage)) to iREt
Move 0 to pStream
//This is what I'm concerned about:
Move (Ole32_CreateStreamOnHGlobal(hImage,1,Addressof(pImage))) to iRet
If (iRet = S_OK) begin
    Get CreateImageFromStream of hImage pStream to iRet
According to the MSDN page for CreateStreamOnHGlobal, the "1" should cause the stream to free the global handle. But when does that happen?
A value that indicates whether the underlying handle for this stream object should be automatically freed when the stream object is released. If set to FALSE, the caller must free the hGlobal after the final release. If set to TRUE, the final release will automatically free the hGlobal parameter.
Does it happen when the DF object is destroyed? When the ImageContainer changes images?
I'm especially not sure as the cDbImageContainer does appear to free the handle (if it exists, as it stores it in a property) as part of Read_Data, but wouldn't that do something like freeing the wrong handle/freeing the handle to an active IStream?
As I said at the start, everything does appear to be working both with and without freeing the handle manually, I just wanted to make sure I was doing this correctly.