TDialog:bValid bug

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

TDialog:bValid bug

Post by Enrico Maria Giordano »

This is the sample. Try to exit with ESC and you will get MsgInfo() two times:

Code: Select all

#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL oDlg

    LOCAL cVar := SPACE( 20 )

    DEFINE DIALOG oDlg

    @ 1, 1 GET cVar

    @ 3, 1 BUTTON "&Close";
           ACTION oDlg:End()

    ACTIVATE DIALOG oDlg;
             ON INIT oDlg:bValid := { || MsgInfo(), .T. };
             CENTER

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

Re: TDialog:bValid bug

Post by Enrico Maria Giordano »

This is a possible fix (but please double check it):

Code: Select all

METHOD KeyChar( nKey, nFlags ) CLASS TDialog

   if nKey == VK_ESCAPE
      if ::oWnd == nil
//         ::End()  //EMG
      else
         if ::oWnd:ChildLevel( TMdiChild() ) != 0
            ::End()
         else
            if ::oWnd:ChildLevel( TDialog() ) != 0
               ::End()
            #ifdef __HARBOUR__
            elseif Upper( ::oWnd:ClassName() ) == "TMDIFRAME" // To avoid ESC being ignored
               ::End()
            #endif
            else
               return Super:KeyChar( nKey, nFlags )
            endif
         endif
      endif
   else
      return Super:KeyChar( nKey, nFlags )
   endif

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

Post by Antonio Linares »

Enrico,

Thanks! :)

We have been messing lately with ESC and this looks as a side effect.
regards, saludos

Antonio Linares
www.fivetechsoft.com
Post Reply