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 »

TBitmap disables nomodal oDlg valid. This is a sample. Try to hit ESC on the first and on the second dialogs. The first will close (it shouldn't), the second not.

Code: Select all

#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL oDlg

    DEFINE DIALOG oDlg

    TBitmap():New()

    ACTIVATE DIALOG oDlg;
             ON INIT oDlg:bValid := { || !GetKeyState( VK_ESCAPE ) };
             CENTER NOMODAL

    SYSWAIT( 2 )

    oDlg:End()

    DEFINE DIALOG oDlg

    ACTIVATE DIALOG oDlg;
             ON INIT oDlg:bValid := { || !GetKeyState( VK_ESCAPE ) };
             CENTER NOMODAL

    SYSWAIT( 2 )

    RETURN NIL
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 »

The same problem there is with TButton but not with TGet.

Any workaround? How to get nomodal dialog's VALID clause to work with any controls?

EMG
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Bug in TBitmap

Post by Antonio Linares »

Enrico,

It is working fine this way:

Code: Select all

#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL oDlg, oBmp

    DEFINE DIALOG oDlg

    oBmp := TBitmap():New()

    oBmp:nDlgCode = DLGC_WANTALLKEYS

    ACTIVATE DIALOG oDlg;
             CENTER NOMODAL ;
             VALID ! GetKeyState( VK_ESCAPE )

    SYSWAIT( 2 )

    oDlg:End()

    DEFINE DIALOG oDlg

    ACTIVATE DIALOG oDlg;
             ON INIT oDlg:bValid := { || !GetKeyState( VK_ESCAPE ) };
             CENTER NOMODAL

    SYSWAIT( 2 )

    RETURN NIL
regards, saludos

Antonio Linares
www.fivetechsoft.com
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 »

Thank you. But this new sample, using resources, still doesn't work:

Code: Select all

#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL oDlg

    DEFINE DIALOG oDlg;
           RESOURCE "TEST"

    TBitmap():Redefine( 101, , , oDlg ):nDlgCode = DLGC_WANTALLKEYS

    ACTIVATE DIALOG oDlg;
             ON INIT oDlg:bValid := { || !GetKeyState( VK_ESCAPE ) };
             CENTER NOMODAL

    SYSWAIT( 2 )

    oDlg:End()

    DEFINE DIALOG oDlg

    ACTIVATE DIALOG oDlg;
             ON INIT oDlg:bValid := { || !GetKeyState( VK_ESCAPE ) };
             CENTER NOMODAL

    SYSWAIT( 2 )

    RETURN NIL

Code: Select all

TEST DIALOG 69, 74, 180, 65
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION
FONT 11, "Arial"
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
{
 CONTROL "", -1, "BUTTON", BS_GROUPBOX | WS_CHILD | WS_VISIBLE, 10, 5, 160, 35
 CONTROL "", 101, "TBitmap", WS_CHILD | WS_VISIBLE, 20, 17, 16, 15
}
EMG
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Bug in TBitmap

Post by Antonio Linares »

Please invert the order in the RC:

Here it is working fine this way
TEST DIALOG 69, 74, 180, 65
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION
FONT 11, "Arial"
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
{
CONTROL "", 101, "TBitmap", WS_CHILD | WS_VISIBLE, 20, 17, 16, 15
CONTROL "", -1, "BUTTON", BS_GROUPBOX | WS_CHILD | WS_VISIBLE, 10, 5, 160, 35
}
regards, saludos

Antonio Linares
www.fivetechsoft.com
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 »

Thank you. But still doesn't work with this new RC:

Code: Select all

TEST DIALOG 69, 74, 180, 65
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION
FONT 11, "Arial"
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
{
 CONTROL "", 101, "TBitmap", WS_CHILD | WS_VISIBLE, 20, 17, 16, 15
 CONTROL "", -1, "BUTTON", BS_GROUPBOX | WS_CHILD | WS_VISIBLE, 10, 5, 160, 35
 CONTROL "&Annulla", 201, "BUTTON", BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 70, 45, 40, 15
}
EMG
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Bug in TBitmap

Post by Antonio Linares »

It seems as this behavior and the one reported by Miacord are based on the same bug:

http://forums.fivetechsupport.com/viewt ... =6&t=33870

I have found a workaround for it. In class TDialog these lines should be added in Method Command()

Code: Select all

      case nID == IDCANCEL .and. ! ::lModal
           if ::lValid()
              ::bValid = nil 
              ::End()
              return .T.
           endif   
           return .F.
just above case nID != 0

I appreciate if you test it as it is difficult to know what side effects may bring so it has to be tested my many users before including it in FWH
regards, saludos

Antonio Linares
www.fivetechsoft.com
Post Reply