Bug in TBitmap [Fixed]

Bug in TBitmap [Fixed]

Postby Enrico Maria Giordano » Sat Apr 01, 2017 7:39 pm

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  Expand view  RUN
#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: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Bug in TBitmap

Postby Enrico Maria Giordano » Sun Apr 02, 2017 7:43 am

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

Re: Bug in TBitmap

Postby Antonio Linares » Tue Apr 04, 2017 6:14 am

Enrico,

It is working fine this way:
Code: Select all  Expand view  RUN
#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
Antonio Linares
Site Admin
 
Posts: 42117
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Bug in TBitmap

Postby Enrico Maria Giordano » Tue Apr 04, 2017 9:16 am

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

Code: Select all  Expand view  RUN
#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  Expand view  RUN
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
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Bug in TBitmap

Postby Antonio Linares » Tue Apr 04, 2017 10:11 am

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
Antonio Linares
Site Admin
 
Posts: 42117
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Bug in TBitmap

Postby Enrico Maria Giordano » Tue Apr 04, 2017 11:09 am

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

Code: Select all  Expand view  RUN
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
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Bug in TBitmap

Postby Antonio Linares » Wed Apr 05, 2017 6:31 am

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

viewtopic.php?f=6&t=33870

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

Code: Select all  Expand view  RUN
     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
User avatar
Antonio Linares
Site Admin
 
Posts: 42117
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Bug in TBitmap

Postby Enrico Maria Giordano » Wed Apr 05, 2017 8:19 am

Ok, I'm testing, thank you. All fine so far.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia


Return to Bugs report & fixes / Informe de errores y arreglos

Who is online

Users browsing this forum: No registered users and 0 guests