MsgItem does not use FW_ReadImage

MsgItem does not use FW_ReadImage

Postby AntoninoP » Mon Oct 15, 2018 1:40 pm

Hello,
In our program we are moving the icon set from BMP to PNG, and we see that the MsgItem does not load the new images.
Looking the code I see that It does not use neither ::ReadBitmap nor FW_ReadBitmap but use ReadBitmap (not method)...

I have the 18.01.

In our code we use this workaround:
if !empty(oMsgBar:aItems[6]:hBitmap1)
PalBmpFree(oMsgBar:aItems[6]:hBitmap1)
endif
oMsgBar:aItems[6]:hBitmap1 := oMsgBar:ReadImage("DOWNLOAD_PNG")


Maybe FiveTech wants change the TMsgItem:New to use the new function...
Bye
AntoninoP
 
Posts: 375
Joined: Tue Feb 10, 2015 9:48 am
Location: Albenga, Italy

Re: MsgItem does not use FW_ReadImage

Postby cnavarro » Mon Oct 15, 2018 7:47 pm

Antonino
In method New, change this
Code: Select all  Expand view

   // Add this code

   ::SetBitmap( cBmp1, cBmp2 )
   if !Empty( ::hBitmap1 )
      DEFAULT nWidth := nBmpWidth( ::hBitmap1 ) + 7
   endif
   if !Empty( ::hBitmap2 )
      DEFAULT nWidth := nBmpWidth( ::hBitmap2 ) + 7
   endif

   // Remove this code
   //if cBmp1 != nil
      //if File( cBmp1 )
      //   ::hBitmap1  = ReadBitmap( 0, cBmp1 )
      //   ::hPalette1 = 0
      //else
      //   ::hBitmap1  = LoadBitmap( GetResources(), cBmp1 )
      //   ::hPalette1 = 0
      //endif
      //if ::hBitmap1 == 0
      //   ::hBitmap1 := nil
      //else
      //   DEFAULT nWidth := nBmpWidth( ::hBitmap1 ) + 7
      //endif
   //endif

   //if cBmp2 != nil
      //if File( cBmp2 )
      //   ::hBitmap2  = ReadBitmap( 0, cBmp2 )
      //   ::hPalette2 = 0
      //else
      //   ::hBitmap2  = LoadBitmap( GetResources(), cBmp2 )
      //   ::hPalette2 = 0
      //endif
      //if ::hBitmap2 == 0
      //   ::hBitmap2 := nil
      //else
      //   DEFAULT nWidth := nBmpWidth( ::hBitmap2 ) + 7
      //endif
   //endif
 


In Method SetBitmap, change this

Code: Select all  Expand view

METHOD SetBitmap( cBmpEnabled, cBmpDisabled ) CLASS TMsgItem

   local aBmpPal

   if ! Empty( cBmpEnabled )
      // Remove this code
      /*
      if File( cBmpEnabled )
         DeleteObject( ::hBitmap1 )
         ::hBitmap1 = ReadBitmap( 0, cBmpEnabled )
      else
        DeleteObject( ::hBitmap1 )
        ::hBitmap1 = LoadBitmap( GetResources(), cBmpEnabled )
      endif
      */


     // Add this code
      PalBmpFree( ::hBitmap1, ::hPalette1 )
      aBmpPal     := FW_ReadImage( Self, cBmpEnabled, , )
      ::hBitmap1  := aBmpPal[ 1 ]
      ::hPalette1 := aBmpPal[ 2 ]

   endif
   if ::hBitmap1 == 0
      ::hBitmap1 := nil
   endif

   if ! Empty( cBmpDisabled )
      // Remove this code
      /*
      if File( cBmpDisabled )
         DeleteObject( ::hBitmap2 )
         ::hBitmap2 = ReadBitmap( 0, cBmpDisabled )
      else
         DeleteObject( ::hBitmap2 )
         ::hBitmap2 = LoadBitmap( GetResources(), cBmpDisabled )
      endif
      */


     // Add this code
      PalBmpFree( ::hBitmap2, ::hPalette2 )
      aBmpPal     := FW_ReadImage( Self, cBmpDisabled, , )
      ::hBitmap2  := aBmpPal[ 1 ]
      ::hPalette2 := aBmpPal[ 2 ]

   endif
   if ::hBitmap2 == 0
      ::hBitmap2 := nil
   endif

   ::Refresh()

return nil


 


An in your code, so

Code: Select all  Expand view


/*
if !empty(oMsgBar:aItems[6]:hBitmap1)
PalBmpFree(oMsgBar:aItems[6]:hBitmap1)
endif
oMsgBar:aItems[6]:hBitmap1 := oMsgBar:ReadImage("DOWNLOAD_PNG")
*/


   oMsgBar:aItems[6]:SetBitmap( "DOWNLOAD_PNG", )

 


Please try, and tell me if run ok
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
User avatar
cnavarro
 
Posts: 6500
Joined: Wed Feb 15, 2012 8:25 pm
Location: España


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 84 guests