FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour MsgItem does not use FW_ReadImage
Posts: 375
Joined: Tue Feb 10, 2015 09:48 AM
MsgItem does not use FW_ReadImage
Posted: Mon Oct 15, 2018 01: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
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: MsgItem does not use FW_ReadImage
Posted: Mon Oct 15, 2018 07:47 PM
Antonino
In method New, change this
Code (fw): Select all Collapse
   // 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 (fw): Select all Collapse
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 (fw): Select all Collapse
/*
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

Continue the discussion