EN_UPDATE never called on TEdit

EN_UPDATE never called on TEdit

Postby AntoninoP » Tue Dec 12, 2017 9: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: 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?
AntoninoP
 
Posts: 375
Joined: Tue Feb 10, 2015 9:48 am
Location: Albenga, Italy

Re: EN_UPDATE never called on TEdit

Postby Antonio Linares » Fri Dec 22, 2017 5:25 am

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
regards, saludos

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

Re: EN_UPDATE never called on TEdit

Postby AntoninoP » Thu Dec 28, 2017 1:19 pm

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
AntoninoP
 
Posts: 375
Joined: Tue Feb 10, 2015 9:48 am
Location: Albenga, Italy

Re: EN_UPDATE never called on TEdit

Postby Silvio.Falconi » Thu Dec 28, 2017 6: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 November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 7056
Joined: Thu Oct 18, 2012 7:17 pm

Re: EN_UPDATE never called on TEdit

Postby AntoninoP » Fri Dec 29, 2017 8: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.
AntoninoP
 
Posts: 375
Joined: Tue Feb 10, 2015 9:48 am
Location: Albenga, Italy

Re: EN_UPDATE never called on TEdit

Postby Antonio Linares » Sat Dec 30, 2017 9: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42089
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: EN_UPDATE never called on TEdit

Postby Silvio.Falconi » 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 November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 7056
Joined: Thu Oct 18, 2012 7:17 pm

Re: EN_UPDATE never called on TEdit

Postby nageswaragunupudi » 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
User avatar
nageswaragunupudi
 
Posts: 10632
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: EN_UPDATE never called on TEdit

Postby nageswaragunupudi » Sat Dec 30, 2017 4:08 pm

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.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10632
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: EN_UPDATE never called on TEdit

Postby Antonio Linares » Sat Dec 30, 2017 7:50 pm

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
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42089
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 106 guests