Crash on TIconGroup

Crash on TIconGroup

Postby AntoninoP » Thu Jan 25, 2018 12:04 pm

Hello,
In our program we have an TIconGroup and we see that when it is empty it crashes if you press a key.
the method:
Code: Select all  Expand view
METHOD KeyDown( nKey, nFlags ) CLASS TIconGroup

   local nAt := ::nFocused
   local nLen := Len( ::aIcons )

   local cPrompt := ::aPrompts[ nAt ]

   do case
      case nKey == VK_UP .or. nKey == VK_LEFT
           if --nAT < 1
              nAt = nLen
           endif
           ::ChangeFocus( nAt )
           Eval( ::oVScroll:bGoUp )
           return 0

      case nKey == VK_DOWN .or. nKey == VK_RIGHT
           if ++nAT > nLen
              nAt = 1
           endif
           ::ChangeFocus( nAt )
           Eval( ::oVScroll:bGoDown )
           return 0

      case nKey == VK_HOME
           ::ChangeFocus( 1 )
           return 0

      case nKey == VK_END
           ::ChangeFocus( nLen )
           return 0

      case nKey == VK_RETURN
           Eval( ::aActions[ nAt ], Self )
           return 0

      case nKey == VK_F2
           if ::lAutoEdit
              ::lEdit := .t.
              ::EditPrompt( nAt, cPrompt,;
                           {|uVar| if( uVar != nil, ::aPrompts[ nAt ] := uVar, ), ::DrawIcon( nAt ) },;
                           GetSysColor( COLOR_WINDOWTEXT ), GetSysColor( COLOR_CAPTIONTEXT ) ) // ::nClrText, ::nClrPane
              return 0
           endif

   endcase

return ::Super:KeyDown( nKey, nFlags )

should be fixed in this way
Code: Select all  Expand view
METHOD KeyDown( nKey, nFlags ) CLASS TIconGroup

   local nAt := ::nFocused
   local nLen := Len( ::aIcons )

   local cPrompt
   if nLen = 0 //<-- added
      return   //<-- added
   endif       //<-- added
   if nAt = 0  //<-- added
      nAt:=1   //<-- added
   endif       //<-- added

   do case
      case nKey == VK_UP .or. nKey == VK_LEFT
           if --nAT < 1
              nAt = nLen
           endif
           ::ChangeFocus( nAt )
           Eval( ::oVScroll:bGoUp )
           return 0

      case nKey == VK_DOWN .or. nKey == VK_RIGHT
           if ++nAT > nLen
              nAt = 1
           endif
           ::ChangeFocus( nAt )
           Eval( ::oVScroll:bGoDown )
           return 0

      case nKey == VK_HOME
           ::ChangeFocus( 1 )
           return 0

      case nKey == VK_END
           ::ChangeFocus( nLen )
           return 0

      case nKey == VK_RETURN
           Eval( ::aActions[ nAt ], Self )
           return 0

      case nKey == VK_F2
           if ::lAutoEdit
               cPrompt := ::aPrompts[ nAt ]  //<-- moved
              ::lEdit := .t.
              ::EditPrompt( nAt, cPrompt,;
                           {|uVar| if( uVar != nil, ::aPrompts[ nAt ] := uVar, ), ::DrawIcon( nAt ) },;
                           GetSysColor( COLOR_WINDOWTEXT ), GetSysColor( COLOR_CAPTIONTEXT ) ) // ::nClrText, ::nClrPane
              return 0
           endif

   endcase

return ::Super:KeyDown( nKey, nFlags )


Personally I would have used the aCoors to select next icon based on keys... 8) :lol:
AntoninoP
 
Posts: 375
Joined: Tue Feb 10, 2015 9:48 am
Location: Albenga, Italy

Re: Crash on TIconGroup

Postby nageswaragunupudi » Thu Jan 25, 2018 3:30 pm

Fixed in FWH 18.01
Regards

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


Return to FiveWin for Harbour/xHarbour

Who is online

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