FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index Bugs report & fixes / Informe de errores y arreglos Bug in TBitmap [Fixed]
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM
Bug in TBitmap [Fixed]
Posted: Sat Apr 01, 2017 07: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 (fw): Select all Collapse
#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
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM
Re: Bug in TBitmap
Posted: Sun Apr 02, 2017 07: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

Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Bug in TBitmap
Posted: Tue Apr 04, 2017 06:14 AM
Enrico,

It is working fine this way:
Code (fw): Select all Collapse
#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
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM
Re: Bug in TBitmap
Posted: Tue Apr 04, 2017 09:16 AM
Thank you. But this new sample, using resources, still doesn't work:

Code (fw): Select all Collapse
#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 (fw): Select all Collapse
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
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Bug in TBitmap
Posted: 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
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM
Re: Bug in TBitmap
Posted: Tue Apr 04, 2017 11:09 AM
Thank you. But still doesn't work with this new RC:

Code (fw): Select all Collapse
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
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Bug in TBitmap
Posted: Wed Apr 05, 2017 06: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 (fw): Select all Collapse
      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
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM
Re: Bug in TBitmap
Posted: Wed Apr 05, 2017 08:19 AM

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

EMG

Continue the discussion