FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour EN_UPDATE never called on TEdit
Posts: 375
Joined: Tue Feb 10, 2015 09:48 AM
EN_UPDATE never called on TEdit
Posted: Tue Dec 12, 2017 09:02 AM
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 (fw): Select all Collapse
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?
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: EN_UPDATE never called on TEdit
Posted: Fri Dec 22, 2017 05:25 AM
Antonino,

Could you try it this way ?

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


many thanks
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 375
Joined: Tue Feb 10, 2015 09:48 AM
Re: EN_UPDATE never called on TEdit
Posted: Thu Dec 28, 2017 01:19 PM
Yes, your fix works too...
here an example of bUpdate use:

Code (fw): Select all Collapse
#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
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: EN_UPDATE never called on TEdit
Posted: Thu Dec 28, 2017 06:02 PM

whatis the difference between tget and edit ?

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 375
Joined: Tue Feb 10, 2015 09:48 AM
Re: EN_UPDATE never called on TEdit
Posted: Fri Dec 29, 2017 08:18 AM

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.

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: EN_UPDATE never called on TEdit
Posted: Sat Dec 30, 2017 09:11 AM

Antonino, your explanation is perfectly fine :-)

This modification is included for next FWH 18.01

many thanks

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: EN_UPDATE never called on TEdit
Posted: Sat Dec 30, 2017 12:16 PM

why should we use the Edit class instead of tget?

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: EN_UPDATE never called on TEdit
Posted: Sat Dec 30, 2017 12:20 PM

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

Regards



G. N. Rao.

Hyderabad, India
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: EN_UPDATE never called on TEdit
Posted: Sat Dec 30, 2017 04:08 PM
Code (fw): Select all Collapse
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.
Regards



G. N. Rao.

Hyderabad, India
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: EN_UPDATE never called on TEdit
Posted: Sat Dec 30, 2017 07:50 PM
The proposed change should be modified this way:

Code (fw): Select all Collapse
      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
regards, saludos

Antonio Linares
www.fivetechsoft.com

Continue the discussion