PlanetSquires Forums

Support Forums => José Roca Software => Topic started by: James Fuller on August 05, 2016, 04:37:06 PM

Title: AfxMenu.inc
Post by: James Fuller on August 05, 2016, 04:37:06 PM
Jose,
  Take a look at the AfxConvertBufferToPARGB32 in AfxMenu.inc

IF info.hbmMask THEN
    RETURN AfxConvertToPARGB32(hDC, pargb, info.hbmMask, sizeIcon, cxRow)
    DeleteObject(info.hbmColor)
    DeleteObject(info.hbmMask)
END IF

It appears the DeleteObjects don't get called

James
Title: Re: AfxMenu.inc
Post by: José Roca on August 05, 2016, 05:59:38 PM
Change it to:


' ========================================================================================
' Converts a buffered bitmap to an PARGB32 bitmap.
' Parameters:
' - hPaintBuffer = The handle of the buffered paint context, obtained through BeginBufferedPaint.
' - hDC          = The Handle of the device context.
' - hIcon        = The icon handle.
' - sizeIcon     = The size of the icon.
' Return value: TRUE or FALSE.
' ========================================================================================
PRIVATE FUNCTION AfxConvertBufferToPARGB32 (BYVAL hPaintBuffer AS HPAINTBUFFER, BYVAL hDC AS HDC, BYVAL hIcon AS HICON, BYVAL sizeIcon AS SIZE) AS BOOLEAN
   IF hPaintBuffer = NULL OR hDC = NULL OR hIcon = NULL THEN RETURN FALSE
   DIM prgbQuad AS RGBQUAD PTR, cxRow AS LONG
   DIM hr AS HRESULT
   hr = GetBufferedPaintBits(hPaintBuffer, @prgbQuad, @cxRow)
   IF SUCCEEDED(hr) THEN
      DIM pargb AS DWORD PTR = CAST(DWORD PTR, prgbQuad)
      IF NOT AfxHasAlpha(pargb, sizeIcon, cxRow) THEN
         DIM info AS ICONINFO
         IF GetIconInfo(hicon, @info) THEN
            IF info.hbmMask THEN
               hr = AfxConvertToPARGB32(hDC, pargb, info.hbmMask, sizeIcon, cxRow)
               DeleteObject(info.hbmColor)
               DeleteObject(info.hbmMask)
            END IF
         END IF
      END IF
   END IF
   IF SUCCEEDED(hr) THEN RETURN TRUE ELSE RETURN FALSE
END FUNCTION
' ========================================================================================