Bug in TButton

Bug in TButton

Postby Enrico Maria Giordano » Thu Mar 02, 2006 5:42 pm

Running the following sample you can see that it shows the message "cVar2 is empty" if ALT-C is pressed (but not if the button is clicked):

Code: Select all  Expand view
#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL oDlg

    LOCAL oGet1, cVar1 := SPACE( 30 )
    LOCAL oGet2, cVar2 := SPACE( 30 )

    DEFINE DIALOG oDlg

    @ 1, 1 GET oGet1 VAR cVar1

    oGet1:bLostFocus = { || cVar2 := "Test", oGet2:Refresh() }

    @ 2, 1 GET oGet2 VAR cVar2

    @ 3, 1 BUTTON "&Close";
           ACTION IF( !EMPTY( cVar2 ), oDlg:End(), MSGINFO( "cVar2 is empty" ) )

    ACTIVATE DIALOG oDlg;
             CENTER

    ? cVar2

    RETURN NIL


A possible fix:

Code: Select all  Expand view
METHOD Click() CLASS TButton

   if ! ::lProcessing
      ::lProcessing = .t.

      if ::bAction != nil
         ::SetFocus()  ///EMG
         Eval( ::bAction )
      endif

      if ! ::lCancel .and. ::oWnd:hWnd != 0  // A.L. 21/04/03
         Super:Click()
      endif                 // A.L. 21/04/03

      // Hernan Ceccarelli added 10-Junio-2001
      if ( GetFocus() == ::hWnd )
         ::PostMsg( BM_SETSTYLE, BS_DEFPUSHBUTTON, 1 )
      else
         if ! ::lDefault
            ::PostMsg( BM_SETSTYLE, BS_PUSHBUTTON, 1 )
         endif
      endif
      // Hernan Ceccarelli added 10-Junio-2001

      ::lProcessing = .f.
   endif

return nil


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

Postby Antonio Linares » Thu Mar 02, 2006 6:32 pm

Thanks Enrico! :)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41469
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 125 guests