PlanetSquires Forums

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: AfxMenu.inc  (Read 1164 times)

James Fuller

  • Senior Member
  • ***
  • Posts: 283
  • FF3 User
AfxMenu.inc
« on: August 05, 2016, 04:07: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
Logged

Josť Roca

  • Moderator
  • Guru Member
  • *****
  • Posts: 3225
Re: AfxMenu.inc
« Reply #1 on: August 05, 2016, 05:29:38 PM »

Change it to:

Code: [Select]
' ========================================================================================
' 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
' ========================================================================================