Hello,
I compared the version where bAction of IDCANCEL works and the version where don't.
I found this piece of code inside dialog.prg on method command:
- Code: Select all Expand view
case nID == IDCANCEL .and. ! ::lModal
if ::lValid()
::bValid = nil
::End()
return .T.
endif
return .F.
This piece of code does not send the FM_CLICK message, that is present in this case (just below):
- Code: Select all Expand view
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
As we can see if the ID is IDCANCEL it goes in the else part, where check if the id is IDOK, then if hWndCtl is not zero, in this case send the message...
so the case of IDCANCEL not modal should be something like (don't tested):
- Code: Select all Expand view
case nID == IDCANCEL .and. ! ::lModal
if 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
if ::lValid()
::bValid = nil
::End()
return .T.
endif
return .F.
endif
I compared the versione 15.03 with the 17.07, Maybe someone more expert can review this piece of code...
Antonino