A problem in TAB handling

A problem in TAB handling

Postby Enrico Maria Giordano » Wed Nov 09, 2011 11:22 pm

In the following sample, try to hit TAB on the keyboard: the focus doesn't go to the button:

Code: Select all  Expand view
#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL oDlg, oBrw

    USE CUSTOMER

    DEFINE DIALOG oDlg;
           SIZE 800, 600

    @ 0, 0 LISTBOX oBrw FIELDS;
           SIZE 400, 200

    @ 250,20 BUTTON "Chiudi";
             ACTION oDlg:End();
             PIXEL

    ACTIVATE DIALOG oDlg;
             CENTER

    CLOSE

    RETURN NIL


EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: A problem in TAB handling

Postby Antonio Linares » Thu Nov 10, 2011 1:18 am

Enrico,

These changes are required in window.prg:

Code: Select all  Expand view
METHOD GoNextCtrl( hCtrl ) CLASS TWindow

   local hCtlNext, nAt

   if Upper( ::ClassName() ) != "TDIALOG" .or. GetClassName( hCtrl ) $ "TWBROWSE"
      nAt = AScan( ::aControls, { | o | o:hWnd == hCtrl } )
      if nAt != 0
         nAt = If( nAt < Len( ::aControls ), nAt + 1, 1 )
         while ! lAnd( GetWindowLong( ::aControls[ nAt ]:hWnd, GWL_STYLE ), WS_TABSTOP )
            nAt = If( nAt < Len( ::aControls ), nAt + 1, 1 )
         end
         SetFocus( ::aControls[ nAt ]:hWnd )
         return nil
      endif
   endif

   if ! Empty( ::aControls ) .and. hCtrl == ::LastActiveCtrl():hWnd
      if ! Empty( ::oWnd ) .and. ;
         ( ( Upper( ::oWnd:ClassName() ) $ "TFOLDER;TPAGES;TFOLDEREX" ) )
         hCtlNext = NextDlgTab( ::oWnd:oWnd:hWnd, ::oWnd:hWnd )
         ::hCtlFocus = hCtrl
         SetFocus( hCtlNext )
      endif
   else
      SendKey( VK_TAB )
   endif

return nil
regards, saludos

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

Re: A problem in TAB handling

Postby ukservice » Thu Nov 10, 2011 8:27 am

Antonio,

It is included in current revised FWH build?.
FWH 11.11, Harbour 3.1 and Borland C++ 5.82
User avatar
ukservice
 
Posts: 417
Joined: Tue Feb 23, 2010 3:09 pm
Location: John

Re: A problem in TAB handling

Postby Antonio Linares » Thu Nov 10, 2011 8:42 am

John,

Not yet. We are pending to know the users, that reported problems, tests results
regards, saludos

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

Re: A problem in TAB handling

Postby ukservice » Thu Nov 10, 2011 8:45 am

Great.

Please, indicate when it´s ready.

Thank you.
FWH 11.11, Harbour 3.1 and Borland C++ 5.82
User avatar
ukservice
 
Posts: 417
Joined: Tue Feb 23, 2010 3:09 pm
Location: John

Re: A problem in TAB handling

Postby Enrico Maria Giordano » Thu Nov 10, 2011 9:44 am

My sample is working now but the problem seems wider:

Code: Select all  Expand view
#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL oDlg, oBrw

    USE CUSTOMER

    DEFINE DIALOG oDlg;
           SIZE 800, 600

    @ 0, 0 LISTBOX oBrw FIELDS;
           SIZE 400, 200

    @ 250,20 BTNBMP PROMPT "Chiudi";
             ACTION oDlg:End();
             PIXEL

    ACTIVATE DIALOG oDlg;
             CENTER

    CLOSE

    RETURN NIL


EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: A problem in TAB handling

Postby byte-one » Thu Nov 10, 2011 10:05 am

I have tested with new code, but not functioning! The TAB steps outside from the TFOLDEX and the dialog from TFOLDEX becomes never the focus. It seems also, when a combobox is in the dialog, the TAB stops and the app hangs. (sendkey()??)
Regards,
Günther
---------------------------------
office@byte-one.com
User avatar
byte-one
 
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria

Re: A problem in TAB handling

Postby Antonio Linares » Thu Nov 10, 2011 11:27 am

Ok, it seems clear why the hangs that Günther reports: If the user has pressed a Tab and we send another tab, then we go into a loop and the app hangs...

So, for now, this seems to be the code to use. Please test it and report your results, thanks! :-)

Code: Select all  Expand view
METHOD GoNextCtrl( hCtrl ) CLASS TWindow

   local hCtlNext, nAt
   
   if ! Empty( ::aControls ) .and. hCtrl == ::LastActiveCtrl():hWnd .and. ;
      ! Empty( ::oWnd ) .and. ( ( Upper( ::oWnd:ClassName() ) $ "TFOLDER;TPAGES;TFOLDEREX" ) )
      hCtlNext = NextDlgTab( ::oWnd:oWnd:hWnd, ::oWnd:hWnd )
      ::hCtlFocus = hCtrl
      SetFocus( hCtlNext )
   else
      nAt = AScan( ::aControls, { | o | o:hWnd == hCtrl } )
      if nAt != 0
         nAt = If( nAt < Len( ::aControls ), nAt + 1, 1 )
         while ! lAnd( GetWindowLong( ::aControls[ nAt ]:hWnd, GWL_STYLE ), WS_TABSTOP )
            nAt = If( nAt < Len( ::aControls ), nAt + 1, 1 )
         end
         SetFocus( ::aControls[ nAt ]:hWnd )
      endif
   endif

return nil
regards, saludos

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

Re: A problem in TAB handling

Postby byte-one » Thu Nov 10, 2011 12:55 pm

Antonio, now is functioning, but the TAB-order from the controls not in all cases are as in the RC defined and the dotted rectangle is not shown on the first stop at listbox,etc.. GoPrevCtrl() is OK. You should go back to 11/9 for this methods for the moment!?

Another point in Class TWindow:
I have adapted the method SayRect() similar to method Say(). Can you add this?

Code: Select all  Expand view
//----------------------------------------------------------------------------//

METHOD SayRect( nRow, nCol, cText, nClrFore, nClrBack, nWidth, oFont, lTransparent, nAlign, nHeight ) CLASS TWindow

   DEFAULT nClrFore := ::nClrText,;
           nClrBack := ::nClrPane,;
           oFont    := ::oFont,;
           lTransparent := .t.,;
           nWidth   := 200,;
           nHeight  := 20

   if ValType( nClrFore ) == "C"      //  xBase Color string
      nClrBack = nClrFore
      nClrFore = nGetForeRGB( nClrFore )
      nClrBack = nGetBackRGB( nClrBack )
   endif

   ::GetDC()

       nAlign := GetTextAlign( ::hDC )
           nHeight  := If( oFont != nil, oFont:nHeight*1.5, nHeight )

   WSayRect( ::hWnd, ::hDC, nRow, nCol, cText, nClrFore, nClrBack, nWidth, ;
         If( oFont != nil, oFont:hFont, 0 ), lTransparent, nAlign, nHeight )

   ::ReleaseDC()

return nil
*/

//----------------------------------------------------------------------------//

HB_FUNC( WSAYRECT )
{
   HWND hWnd        = ( HWND ) hb_parnl( 1 );
   HDC  hDC         = ( HDC ) hb_parnl( 2 );
   WORD wRow        = hb_parni( 3 );
   WORD wCol        = hb_parni( 4 );
   LPSTR szText     = ( LPSTR ) hb_parc( 5 );
   COLORREF clrFore = ( hb_pcount() > 5 ) ? hb_parnl( 6 ): 0;
   COLORREF clrBack = ( hb_pcount() > 6 ) ? hb_parnl( 7 ): RGB( 255, 255, 255 );
   WORD wRectLen    = hb_parni( 8 );
  HFONT hFont      = ( HFONT ) hb_parnl( 9 );
   BOOL bTransparent = hb_parl( 10 );
   UINT uiAlign     = hb_parnl( 11 ), uiOldAlign;
   WORD wRectHight    = hb_parni( 12 );
   HFONT hOldFont;
   BOOL bDestroyDC  = FALSE;
   RECT rct;
   #ifdef UNICODE
      LPWSTR pW;
   #endif
   COLORREF clrForeOld, clrBackOld;

   if( ! hDC )
   {
      bDestroyDC = TRUE;
      hDC = GetDC( hWnd );
   }

   SetTextColor( hDC, clrFore );
   SetBkColor( hDC, clrBack );

   if( bTransparent )
      SetBkMode( hDC, TRANSPARENT );
   else
      SetBkMode( hDC, OPAQUE );

   if( hFont )
      hOldFont = ( HFONT ) SelectObject( hDC, hFont );

   if( uiAlign )
      uiOldAlign = SetTextAlign( hDC, uiAlign );

   rct.top    = wRow;
   rct.bottom = rct.top + wRectHight;
   rct.left   = wCol;
   rct.right  = rct.left + wRectLen;

   #ifndef UNICODE
      DrawText( hDC, szText, lstrlen( szText ), &rct, DT_WORDBREAK);
   #else
      pW = AnsiToWide( szText );
      DrawText( hDC, pW, strlen( szText ), &rct, DT_WORDBREAK);
      _xfree( pW );
   #endif

  if( uiAlign )
      SetTextAlign( hDC, uiOldAlign );

   if( hFont )
      SelectObject( hDC, hOldFont );

   SetTextColor( hDC, clrForeOld );
   SetBkColor( hDC, clrBackOld );

   if( bDestroyDC )
      ReleaseDC( hWnd, hDC );
}

//----------------------------------------------------------------------------//
Regards,
Günther
---------------------------------
office@byte-one.com
User avatar
byte-one
 
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria

Re: A problem in TAB handling

Postby carlos vargas » Thu Nov 10, 2011 8:42 pm

Antonio, he preparado un video
http://www.donboscocorp.com/carlos/falla2.rar
he modificado el metodo segun tu indicacion
Code: Select all  Expand view

METHOD GoNextCtrl( hCtrl ) CLASS TWindow
   local hCtlNext, nAt

   ???ProcName()

   if !Empty( ::aControls ) .and. hCtrl == ::LastActiveCtrl():hWnd .and. ;
      !Empty( ::oWnd ) .and. ( ( Upper( ::oWnd:ClassName() ) $ "TFOLDER;TPAGES;TFOLDEREX" ) )
      hCtlNext := NextDlgTab( ::oWnd:oWnd:hWnd, ::oWnd:hWnd )
      ???1, hCtrl
      ::hCtlFocus := hCtrl
      SetFocus( hCtlNext )
   ELSE

      nAt := AScan( ::aControls, { | o | o:hWnd == hCtrl } )
      ???"2->", Len( ::aControls ), hCtrl, nAt
      if nAt != 0
         nAt := If( nAt < Len( ::aControls ), nAt + 1, 1 )
         while ! lAnd( GetWindowLong( ::aControls[ nAt ]:hWnd, GWL_STYLE ), WS_TABSTOP )
            nAt = If( nAt < Len( ::aControls ), nAt + 1, 1 )
         end
         ???"entro", nAt, ::aControls[ nAt ]:hWnd
         SetFocus( ::aControls[ nAt ]:hWnd )
      endif
   endif

return nil
 


he agregado unas lineas para poder depurar y ver como se disparan las acciones,
eh aqui mis observaciones:
*cuando estamos en un dialogo sencillo, todo funciona muy bien.
al pasar de un get a otro se dispara el evento gonextctrl una sola vez cada salto.

*cuanto estamos en un dialogo, el salto entre get y get dispara dos veces el metodo gonexctrl.
*en el caso del checkbox observa que con enter no funciona el salto al siguiente control.
*al llegar al ultimo get, y presionar enter el proximo control a tomar foco serian unos botones (son tres consecutivos ya que los get que tiene cada boton estan desabilitatos)
Last edited by carlos vargas on Thu Nov 10, 2011 10:48 pm, edited 1 time in total.
Salu2
Carlos Vargas
Desde Managua, Nicaragua (CA)
User avatar
carlos vargas
 
Posts: 1719
Joined: Tue Oct 11, 2005 5:01 pm
Location: Nicaragua

Re: A problem in TAB handling

Postby carlos vargas » Thu Nov 10, 2011 10:48 pm

Salu2
Carlos Vargas
Desde Managua, Nicaragua (CA)
User avatar
carlos vargas
 
Posts: 1719
Joined: Tue Oct 11, 2005 5:01 pm
Location: Nicaragua

Re: A problem in TAB handling

Postby Antonio Linares » Fri Nov 11, 2011 12:58 am

Carlos,

En vez de usar ?? ó MsgInfo(), usa LogFile( cFileName, { Valores, ... } ) para hacer el seguimiento, pues si usas un medio que altere el foco esta afectando al comportamiento por defecto.
regards, saludos

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

Re: A problem in TAB handling

Postby carlos vargas » Fri Nov 11, 2011 2:00 am

ok Antonio, lo hare y te comento los resultados.
aunque ??? es un comando preprocesado para usar la funcion OutputDebugString
no tengo claro si este tipo de depuración afecta el foco o algo asi :-)

Code: Select all  Expand view

#xcommand ???<xData> [, <xDataN> ]              => KDSDebug( <xData> ) ;
                                                                      [; KDSDebug( <xDataN>) ]

FUNCTION KDSDebug( xVal, lReturn )
   DEFAULT lReturn := FALSE

   OutPutDebugStringC( "Depuración: " + CStr( xVal ) + IIf( lReturn, FINL, "" )  )

RETURN NIL

#pragma BEGINDUMP

#include "hbapi.h"
#include "hbapiitm.h"
#include "hbapierr.h"

#include "windows.h"

HB_FUNC( OUTPUTDEBUGSTRINGC )
{
    PHB_ITEM szMsg = hb_param( 1, HB_IT_STRING );

    if( szMsg != NULL )
    {
        OutputDebugStringA( hb_itemGetC( szMsg ) );
        OutputDebugStringA( "\n" );
    }
    hb_retc( "" );
}

#pragma ENDDUMP
 
Salu2
Carlos Vargas
Desde Managua, Nicaragua (CA)
User avatar
carlos vargas
 
Posts: 1719
Joined: Tue Oct 11, 2005 5:01 pm
Location: Nicaragua


Re: A problem in TAB handling

Postby byte-one » Mon Nov 14, 2011 1:12 pm

I ask also!?? Any news? The last changes are not so good!
Regards,
Günther
---------------------------------
office@byte-one.com
User avatar
byte-one
 
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: nageswaragunupudi and 51 guests