Page 1 of 1

Bug in TBitmap [Fixed]

Posted: Wed May 23, 2018 10:50 pm
by Enrico Maria Giordano
Please try the following sample (with the manifest file). Click on the checkbox and you'll see that it doesn't change its status. It works fine if the bitmap exists.

Code: Select all

#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL oDlg

    LOCAL lVar := .F.

    DEFINE DIALOG oDlg;
           RESOURCE "TEST"

    REDEFINE BITMAP;
             ID 101 OF oDlg;
             FILE "NONEXISTENT.BMP"

    REDEFINE CHECKBOX lVar;
             ID 102 OF oDlg

    ACTIVATE DIALOG oDlg;
             CENTER

    RETURN NIL

Code: Select all

1 24 "c:\fwh\samples\winxp\WindowsXP.Manifest"

TEST DIALOG 0, 0, 300, 300
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
FONT 8, "MS Sans Serif"
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
{
 CONTROL "", 101, "TBitmap", WS_CHILD | WS_VISIBLE, 10, 10, 57, 62
 CONTROL "TCheckBox", 102, "BUTTON", BS_AUTOCHECKBOX | BS_LEFTTEXT | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 120, 30, 46, 13
}
EMG

Re: Bug in TBitmap

Posted: Thu May 24, 2018 10:38 am
by Enrico Maria Giordano
This is a fix that seems to work:

Code: Select all

::LoadImage( cResName, If( cBmpFile != nil .and. File( cBmpFile ), AllTrim( cBmpFile ), nil ) )
EMG

Re: Bug in TBitmap

Posted: Tue May 29, 2018 5:31 am
by nageswaragunupudi
The problem is because the following lines in the Paint() method

Code: Select all

   if Empty( ::hBitmap ) .and. ! Empty( ::cBmpFile )
      ::LoadBmp( ::cBmpFile )
   endif
 
keep calling LoadImage() repeatedly.

This is fixed by inserting these lines before present line no. 833 ( FWH18.03)

Code: Select all

      if ::hBitmap == 0
         ::cResName  := ::cBmpFile := nil
      endif
 
in the method LoadImage().

Thank you for pointing out this bug.