Page 1 of 1

Little problem in TWindow

PostPosted: Wed Feb 22, 2006 7:50 pm
by Enrico Maria Giordano
In the following sample try to put the mouse pointer over the btnbmp and then press ALT. You will see that the menu is not activated as it does then the mouse pointer is not over the btnbmp.

Code: Select all  Expand view
FUNCTION MAIN()

    LOCAL oWnd, oMenu, oBar

    MENU oMenu
        MENUITEM "Test"

        MENU
            MENUITEM "Test1"
            MENUITEM "Test2"
            MENUITEM "Test3"
            MENUITEM "Test4"
        ENDMENU
    ENDMENU

    DEFINE WINDOW oWnd;
           MENU oMenu

    DEFINE BUTTONBAR oBar 3D OF oWnd

    DEFINE BUTTON OF oBar;
           TOOLTIP "This is a test";
           NOBORDER

    ACTIVATE WINDOW oWnd

    RETURN NIL


A possible fix (but I don't know if it is the best one):

Code: Select all  Expand view
METHOD SysCommand( nWParam, nLParam ) CLASS TWindow

   local bKeyAction

   if ::oBar != nil //EMG
      AEval( ::oBar:aControls, { | oCtl | If( oCtl:ClassName() == "TBTNBMP", oCtl:LostFocus(), ) } ) //EMG
   endif //EMG

   if nWParam == 61696 // VK_F10
      if ( bKeyAction := SetKey( VK_F10 ) ) != nil
         Eval( bKeyAction, ProcName( 4 ), ProcLine( 4 ), Self )
         return 0
      endif
   endif

   if ::oSysMenu != nil .and. nWParam < 61440           // 0xF000
      ::oSysMenu:Command( nWParam )
   else
      do case
         case nWParam == SC_CLOSE .or. nWParam == SC_CLOSE_OPEN
              return ::End()
      endcase
   endif

return nil


EMG

PostPosted: Sun Feb 26, 2006 7:48 pm
by Antonio Linares
Enrico,

Thanks! :)

PostPosted: Fri Mar 03, 2006 1:02 pm
by Enrico Maria Giordano
And for the same reason you may need to add:

Code: Select all  Expand view
   if ::ClassName() = "TMDIFRAME"
      for i = 1 to Len( ::oWndClient:aWnd )
         if ::oWndClient:aWnd[ i ]:oBar != nil
            AEval( ::oWndClient:aWnd[ i ]:oBar:aControls, { | oCtl | If( oCtl:ClassName() == "TBTNBMP", oCtl:LostFocus(), ) } )
         endif
      next
   endif

   if ::ClassName() = "TDIALOG"
      AEval( ::aControls, { | oCtl | If( oCtl:ClassName() == "TBTNBMP", oCtl:LostFocus(), ) } )
   endif


EMG