Page 1 of 1

EN_UPDATE never called on TEdit

PostPosted: Tue Dec 12, 2017 9:02 am
by AntoninoP
Hello,
developing a program, I see that the that the bUpdate of TEdit is never called, I found the problem on METHOD Command( nWParam, nLParam ) CLASS TDialog:
Code: Select all  Expand view
METHOD Command( nWParam, nLParam ) CLASS TDialog

   local oWnd, nNotifyCode, nID, hWndCtl, oCtrl

   nNotifyCode = nHiWord( nWParam )
   nID         = nLoWord( nWParam )
   hWndCtl     = nLParam

   do case
      case ::oPopup != nil
           ::oPopup:Command( nID )

      case hWndCtl == 0 .and. ::oMenu != nil .and. ;
           If( nNotifyCode == BN_CLICKED, nID != IDCANCEL, .f. )
           ::oMenu:Command( nID )

      case GetClassName( hWndCtl ) == "ToolbarWindow32"
           oWndFromHwnd( hWndCtl ):Command( nWParam, nLParam )
           return .T. // otherwise a child dialog gets closed

      case ::oMenu != nil .and. nId != 2 .and. nNotifyCode != BN_CLICKED .and. ;
           nNotifyCode != CBN_SELCHANGE
           if nNotifyCode == 1
              ::oMenu:Command( nID )
           endif

      case nID == IDCANCEL .and. ! ::lModal
           if ::lValid()
              ::bValid = nil
              ::End()
              return .T.
           endif  
           return .F.

      case nID != 0
           do case
              case nNotifyCode == BN_CLICKED
                   if hWndCtl != 0 .and. nID != IDCANCEL
                      oWnd := oWndFromhWnd( hWndCtl )
                      if ValType( ::nResult ) == "O" // latest control which had focus
                         // There is a pending Valid, it is not a clicked button
                         if oWnd != nil
                            if ! oWnd:lCancel
                               if ::nResult:nID != nID .and. ! ::nResult:lValid()
                                  return nil
                               endif
                            endif
                         else
                            if ::nResult:nID != nID .and. ! ::nResult:lValid()
                               return nil
                            endif
                         endif
                      endif

                      if AScan( ::aControls, { |o| o:nID == nID } ) > 0
                         SendMessage( hWndCtl, FM_CLICK, 0, 0 )
                      elseif nID == IDOK
                         ::End( IDOK )
                      endif
                   else
                      if nID == IDOK
                         ::GoNextCtrl( GetFocus() )
                         if ! ::lModal
                            return 0
                         endif
                      elseif hWndCtl != 0 .and. ; // There is a control for IDCANCEL
                             AScan( ::aControls, { |o| o:nID == nID } ) > 0
                             SendMessage( hWndCtl, FM_CLICK, 0, 0 )
                             return .F.
                      else
                         ::End( IDCANCEL )
                      endif
                   endif

              case nNotifyCode == CBN_SELCHANGE
                   SendMessage( hWndCtl, FM_CHANGE, 0, 0 )

              case nNotifyCode == CBN_CLOSEUP
                   SendMessage( hWndCtl, FM_CLOSEUP, 0, 0 )

           endcase

      case GetClassName( hWndCtl ) == "Edit"
           oCtrl := oWndFromHwnd( hWndCtl )
           if oCtrl != nil .and. oCtrl:ClassName() == "TEDIT"
              oCtrl:Command( nWParam, nLParam )
              return nil
           endif
   endcase

return nil


The problem is that the edit has nID != 0 then it goes in the case before...
There is 2 possible solutions: move the case GetClassName( hWndCtl ) == "Edit" before the case nID!=0, or it inside the other do case, in this way only Edit with ID !=0 will works, ie every edit control (in FiveWin there is not possible ID=0)...

maybe this fix can be included in the next release?

Re: EN_UPDATE never called on TEdit

PostPosted: Fri Dec 22, 2017 5:25 am
by Antonio Linares
Antonino,

Could you try it this way ?

Code: Select all  Expand view
     case GetClassName( hWndCtl ) == "ToolbarWindow32" .or. GetClassName( hWndCtl ) == "Edit"
           oWndFromHwnd( hWndCtl ):Command( nWParam, nLParam )
           return .T. // otherwise a child dialog gets closed


many thanks

Re: EN_UPDATE never called on TEdit

PostPosted: Thu Dec 28, 2017 1:19 pm
by AntoninoP
Yes, your fix works too...
here an example of bUpdate use:

Code: Select all  Expand view
#include <FiveWin.ch>

proc main
    LOCAL oDlg, oEdit, oStatic
    LOCAL cEdit := "", cStatic := ""
    DEFINE DIALOG oDlg TITLE "Test bUpade"
    @ 10, 10 EDIT oEdit VAR cEdit SIZE 100,10 PIXEL
    @ 20, 10 SAY oStatic VAR cStatic SIZE 100,10 PIXEL CENTER BORDER
    oEdit:bUpdate := {|| oStatic:SetText(cEdit) }
    ACTIVATE DIALOG oDlg
 


bUpdate is called every time the edit is changed, but differently of KeyDown or KeyChar it is called after the update.
Maybe can be useful for TGET too

Re: EN_UPDATE never called on TEdit

PostPosted: Thu Dec 28, 2017 6:02 pm
by Silvio.Falconi
whatis the difference between tget and edit ?

Re: EN_UPDATE never called on TEdit

PostPosted: Fri Dec 29, 2017 8:18 am
by AntoninoP
Maybe someone else can explain it better, from what I saw the TGet uses the Get from harbour/XHarbour to manage the input, it means use of Picture and fixed size The Edit is the windows control without filter, no picture and dynamic size.

Re: EN_UPDATE never called on TEdit

PostPosted: Sat Dec 30, 2017 9:11 am
by Antonio Linares
Antonino, your explanation is perfectly fine :-)

This modification is included for next FWH 18.01

many thanks

Re: EN_UPDATE never called on TEdit

PostPosted: Sat Dec 30, 2017 12:16 pm
by Silvio.Falconi
why should we use the Edit class instead of tget?

Re: EN_UPDATE never called on TEdit

PostPosted: Sat Dec 30, 2017 12:20 pm
by nageswaragunupudi
In all our controls, we have only bChange and lUpdate.
We do not have bUpdate. (TEdit is an exception)

The functionality sought to be implemented as bUpdate is better provided to the programmers through bChange.

We only take care of changes with bChange or ON CHANGE clause.

Kindly keep the issue of consistent usage across all controls in mind while implementing any changes

Re: EN_UPDATE never called on TEdit

PostPosted: Sat Dec 30, 2017 4:08 pm
by nageswaragunupudi
Code: Select all  Expand view
GetClassName( hWndCtl ) == "Edit"

This is true for all the 3 classes TEdit, TGet and TMultiGet.
Any changes affect all these 3 classes.
It is desirable to test the effect of these changes on all the three classes thoroughly before implementation.

Re: EN_UPDATE never called on TEdit

PostPosted: Sat Dec 30, 2017 7:50 pm
by Antonio Linares
The proposed change should be modified this way:

Code: Select all  Expand view
     case GetClassName( hWndCtl ) == "ToolbarWindow32" .or. GetClassName( hWndCtl ) == "Edit"
           if ( oCtrl := oWndFromHwnd( hWndCtl ) ) != nil
              oCtrl:Command( nWParam, nLParam )
              return .T. // otherwise a child dialog gets closed
           endif