Bug in TBitmap [Fixed]

Post Reply
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Bug in TBitmap [Fixed]

Post 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
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: Bug in TBitmap

Post 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
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: Bug in TBitmap

Post 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.
Regards

G. N. Rao.
Hyderabad, India
Post Reply