Page 1 of 1

Bug in TBitmap [Fixed]

Posted: Sat Apr 01, 2017 7:39 pm
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

Re: Bug in TBitmap

Posted: Sun Apr 02, 2017 7:43 am
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

Re: Bug in TBitmap

Posted: Tue Apr 04, 2017 6:14 am
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

Re: Bug in TBitmap

Posted: Tue Apr 04, 2017 9:16 am
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

Re: Bug in TBitmap

Posted: Tue Apr 04, 2017 10:11 am
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
}

Re: Bug in TBitmap

Posted: Tue Apr 04, 2017 11:09 am
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

Re: Bug in TBitmap

Posted: Wed Apr 05, 2017 6:31 am
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

Re: Bug in TBitmap

Posted: Wed Apr 05, 2017 8:19 am
by Enrico Maria Giordano
Ok, I'm testing, thank you. All fine so far.

EMG