Duda en TCBROWSE

Post Reply
User avatar
karinha
Posts: 4882
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Duda en TCBROWSE

Post by karinha »

oBrw:nLineStyle := 3


Maestros, porque oBrw:nLineStyle := 4 ó 5 ó 6 ó 7 ó 8, no funciona?

Tengo que modificar algo en la classe TCBROWSE.PRG??

Best regards, saludos.
João Santos - São Paulo - Brasil
User avatar
karinha
Posts: 4882
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Post by karinha »

Nada Maestros? No hay solución?

Saludos.
João Santos - São Paulo - Brasil
User avatar
mmercado
Posts: 782
Joined: Wed Dec 19, 2007 7:50 am
Location: Salamanca, Gto., México

Re: Duda en TCBROWSE

Post by mmercado »

Hola João:
karinha wrote:Maestros, porque oBrw:nLineStyle := 4 ó 5 ó 6 ó 7 ó 8, no funciona?
En TCBrowse solo hay 4 estilos de linea posibles:
1 negras
2 grises
3 3D
4 punteadas

En TSBrowse son 5
1 todas
2 solo verticales
3 solo horizontales
4 3D
5 Punteadas

Saludos

Manuel Mercado
User avatar
karinha
Posts: 4882
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Post by karinha »

Gracias por responder maestro Manuel.

Entonces, és una falla de la classe TCBROWSE.PRG??

La classe TWBROWSE, bién como tu magnifica TSBROWSE, nos permite usar asta la opcíon 8 -> 0 a 8.

En la classe TCBROWSE.PRG, nos és posible usar la opción 0, 5, 6, 7, 8??

No hay nada que se pueda hacer para mejorar esto?

Best regards, saludos y muchas gracias.
João Santos - São Paulo - Brasil
User avatar
mmercado
Posts: 782
Joined: Wed Dec 19, 2007 7:50 am
Location: Salamanca, Gto., México

Post by mmercado »

karinha wrote:En la classe TCBROWSE.PRG, nos és posible usar la opción 0, 5, 6, 7, 8??
La opción 0 (sin lineas) la aplica por defecto, las demás no son posibles
karinha wrote:No hay nada que se pueda hacer para mejorar esto?
Solo modificando el programa tcbfuncs.c

Un abrazo.

Manuel Mercado
User avatar
karinha
Posts: 4882
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Post by karinha »

mmercado wrote:
karinha wrote:En la classe TCBROWSE.PRG, nos és posible usar la opción 0, 5, 6, 7, 8??
La opción 0 (sin lineas) la aplica por defecto, las demás no son posibles
karinha wrote:No hay nada que se pueda hacer para mejorar esto?
Solo modificando el programa tcbfuncs.c

Un abrazo.

Manuel Mercado
Magnifica explicación maestro Manuel, pelo no tengo el minino conocimiento de la linguage C.

Podria ayudarme? Donde cambio para funcionar perfecto?

Un gran saludo desde Brasil, és mui querido por acá.

Best regards.

Code: Select all

#include <WinTen.h>
#include <Windows.h>
#include <ClipApi.h>

void WndDrawBox( HDC, LPRECT, HPEN, HPEN );
void DrawBitmap( HDC, HBITMAP, WORD wCol, WORD wRow, WORD wWidth, \
                 WORD wHeight, DWORD dwRaster );
void DrawMasked( HDC, HBITMAP, WORD wCol, WORD wRow );
void FrameDot( HDC hDC, RECT * pRect );

#ifdef __FLAT__
   DWORD MoveTo( HDC hdc, int x, int y );
#endif

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

CLIPPER TCDRAWCELL( PARAMS ) // ( hWnd, hDC, nRow, nColumn , nWidth ,
                      //   uData, nAlign , nClrFore, nClrBack ,
                      //   hFont, nBitmap, dwRaster, nLinesStyle )

{
   HWND hWnd        = ( HWND ) _parnl( 1 ) ;
   HDC  hDC         = ( HDC ) _parnl( 2 ) ;
   int  nRow        = _parni( 3 ) ;
   int  nColumn     = _parni( 4 ) ;
   int  nWidth      = _parni( 5 ) ;
   LPSTR cData      = _parc( 6 ) ;
   int  nLen        = _parclen( 6 ) ;
   UINT nAlign      = _parni( 7 ) ;
   COLORREF clrFore = ( PCOUNT() > 7 ? _parnl( 8 ): 0 );
   COLORREF clrBack = ( PCOUNT() > 8 ? _parnl( 9 ): RGB( 255, 255, 255 ) );
   HFONT hFont      = ( HFONT ) _parnl( 10 ) ;
   int     nBitMap  = _parni( 11 ) ;
   HBITMAP hBitMap  = ( HBITMAP ) _parnl( 6 ) ;  // redefine parm 6 as possible bitmap
   //DWORD dwRaster   = ( PCOUNT() > 11 ? _parnl( 12 ) : 0x5A0049 );
   HFONT hOldFont ;
   BOOL bDestroyDC  = FALSE ;
   HPEN hGrayPen, hWhitePen, hOldPen;
   TEXTMETRIC tm ;
   RECT rct ;
   int LineCount, HeaderHeight ;
   WORD  wLineStyle = _parni( 13 );
   HBRUSH hBrush;

   if( wLineStyle )
   {
      switch( wLineStyle )
      {
         case 1: // BLACK
              hGrayPen  = ( HPEN ) GetStockObject( BLACK_PEN );
              hWhitePen = hGrayPen;
              break;

         case 2: // GRAY
              hGrayPen  = CreatePen( PS_SOLID, 1, GetSysColor( COLOR_BTNSHADOW ) ) ; // RGB( 128, 128, 128 ) );
              hWhitePen = hGrayPen;
              break;

         case 3: // 3D
              hGrayPen  = CreatePen( PS_SOLID, 1, GetSysColor( COLOR_BTNSHADOW ) ) ; // RGB( 128, 128, 128 ) );
              hWhitePen = CreatePen( PS_SOLID, 1, GetSysColor( COLOR_BTNHIGHLIGHT ) ); // GetStockObject( WHITE_PEN );
              break;

         case 4: // DOTTED
              break;
      }
   }

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

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

   GetClientRect( hWnd, &rct ) ;
   GetTextMetrics( hDC, &tm ) ;

   tm.tmHeight++;

   /* Calculate number of lines available to this Client Rect. */
   LineCount = ( ( rct.bottom - rct.top ) / tm.tmHeight ) - 1 ;

   /* Add the extra space that will be left over on the bottom of the screen
      to the header. */
   // HeaderHeight = ( ( rct.bottom - rct.top ) - ( LineCount * tm.tmHeight ) ) ;

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

   if( nRow == 0 )
      rct.top = 0 ;
   else
      rct.top = ( tm.tmHeight * nRow );

   if( rct.top + tm.tmHeight <= rct.bottom )
   {
      rct.bottom = rct.top + tm.tmHeight;

      /* Don't let left side go beyond rct.right of Client Rect. */
      if( nColumn - ( rct.right - rct.left) <= 0 )
      {
         rct.left   = nColumn ;

           /* if nWidth == -1, it indicates the last column so go to limit,
            Don't let right side go beyond rct.right of Client Rect. */
         if( ( nWidth != -1 ) && ((rct.left + nWidth - rct.right) <= 0) )
            rct.right  = rct.left + nWidth ;

         rct.right += 2;

         ExtTextOut( hDC, rct.left, rct.top + 1, ETO_OPAQUE | ETO_CLIPPED, \
                     &rct, "", 0, 0  ) ;

         rct.left += 2 ;
         rct.right -= 4 ;

         if(nBitMap)
         {

         // use this next code to use ROPs, disable the 4 lines code below
         // also uncomment the dwRaster code in the begining of the function
	      // if ( nBitMap == 1 )
         //   dwRaster = 0;
         // DrawBitmap( hDC, hBitMap,  rct.top + 1, rct.left - 1, \
         //         rct.right - rct.left + 1,  rct.bottom - rct.top - 1, dwRaster );

              // DrawBitmap( hDC, hBitMap,  rct.top + 1, rct.left - 1, \
              //     rct.right - rct.left + 1,  rct.bottom - rct.top - 1, 0 );
              hBrush = CreateSolidBrush( clrBack );
              FillRect( hDC, &rct, hBrush );
              DeleteObject( hBrush );
              DrawMasked( hDC, hBitMap, rct.top, rct.left );

              // if ( nBitMap == 2 )
              //     InvertRect( hDC,  &rct) ;
         }
      else
      {
          if( nRow )
             rct.top++;
	      DrawText( hDC, cData, nLen, &rct, nAlign | DT_VCENTER | \
                   DT_SINGLELINE | DT_NOPREFIX ) ;
          if( nRow )
             rct.top--;
      }

         rct.left -= 2 ;
         rct.right += 1 ;
         rct.bottom -= 1 ;

         if( wLineStyle )
         {
            if( wLineStyle != 3 ) // 3D
            {
               // rct.top--;
               rct.bottom++;
               if( rct.left > 0 )
                  rct.left--;
            }
            if( wLineStyle == 4 ) // DOTTED
               FrameDot( hDC, &rct );
            else
               WndDrawBox( hDC, &rct, hWhitePen, hGrayPen ) ;
         }
      }
   }

   if( ! nRow )
   {
      WndDrawBox( hDC, &rct, hWhitePen, ( HPEN ) GetStockObject( BLACK_PEN ) );
      hOldPen = ( HPEN ) SelectObject( hDC, hGrayPen );
      MoveTo( hDC, rct.left, rct.bottom - 1 );
      LineTo( hDC, rct.right, rct.bottom - 1 );
      MoveTo( hDC, rct.right - 1, rct.bottom - 1 );
      LineTo( hDC, rct.right - 1, rct.top );
      SelectObject( hDC, hOldPen );
   }

   if( wLineStyle )
   {
      switch( wLineStyle )
      {
         case 1: // BLACK
              break;    // it is a system resource, so do nothing

         case 2: // GRAY
              DeleteObject( hGrayPen );  // We just use this one
              break;

         case 3: // 3D
              DeleteObject( hGrayPen );
              DeleteObject( hWhitePen );
              break;

         case 4: // DOTTED
              break;                    // do nothing
      }
   }

   if( hFont )
      SelectObject( hDC, hOldFont ) ;

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

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

#ifdef __HARBOUR__
   CLIPPER TCBRWSCROLL( PARAMS )  //
#else
   CLIPPER TCBRWSCROL( PARAMS )  //
#endif
{
   HWND hWnd   = ( HWND ) _parnl( 1 );
   int wRows   = _parni( 2 );    // 04-22-00
   HFONT hFont = ( HFONT ) _parnl( 3 );
   HFONT hOldFont;
   HDC hDC     = GetDC( hWnd );
   RECT rct;
   TEXTMETRIC tm;

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

   GetClientRect( hWnd, &rct );
   GetTextMetrics( hDC, &tm );

   tm.tmHeight++;

   rct.top    += tm.tmHeight;
   rct.bottom -= ( ( rct.bottom - rct.top ) % tm.tmHeight );
   ScrollWindowEx( hWnd, 0, -( tm.tmHeight * wRows ), 0, &rct, 0, 0, 0 );

   if( hFont )
      SelectObject( hDC, hOldFont );

   ReleaseDC( hWnd, hDC );
}

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

static WORD near GetWindowRow( HWND hWnd, HDC hDC, WORD wGraphRow, \
                               HFONT hFont ) // -> wTextRow
{
   TEXTMETRIC tm;
   RECT rct;
   WORD wRow;
   BOOL bDCDestroy = FALSE;
   HFONT hOldFont;
	int LineCount, HeaderHeight ;

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

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

   GetTextMetrics( hDC, &tm );
   GetClientRect( hWnd, &rct );

   tm.tmHeight++;

   /* Calculate number of lines available to this Client Rect. */
   LineCount = ( ( rct.bottom - rct.top ) / tm.tmHeight ) - 1 ;

   /* Add the extra space that will be left over on the bottom of the screen
      to the header. */
   // HeaderHeight = ( ( rct.bottom - rct.top ) - ( LineCount * tm.tmHeight ) ) ;

   /*   wRow = ( wGraphRow - rct.top ) / tm.tmHeight;*/
   // if( wGraphRow - rct.top <= HeaderHeight )
   //   wRow = 0 ;
   // else
      wRow = ( ( wGraphRow - rct.top ) / tm.tmHeight );

   if( hFont )
      SelectObject( hDC, hOldFont );

   if( bDCDestroy )
      ReleaseDC( hWnd, hDC );

   return wRow;
}

CLIPPER NTCWROW( PARAMS )        // hWnd, hDC, nGraphRow, hFont -> nTextRow
{
   _retni( GetWindowRow( ( HWND ) _parnl( 1 ), ( HDC ) _parnl( 2 ),
                         _parni( 3 ), ( HFONT ) _parnl( 4 ) ) );
}

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

#ifdef __HARBOUR__
   CLIPPER ATCBRWPOSRECT( PARAMS ) // ( hWnd, nRow, nCol, nWidth, hFont )
#else
   CLIPPER ATCBRWPOSR( PARAMS ) // ect( hWnd, nRow, nCol, nWidth, hFont )
#endif
{
   HWND hWnd        = ( HWND ) _parnl( 1 );
   WORD wRow        = _parni( 2 );
   WORD wCol        = _parni( 3 );
   WORD wWidth      = _parni( 4 );
   HFONT hFont      = ( HFONT ) _parnl( 5 );
   HDC hDC          = GetDC( hWnd );
   HFONT hOldFont;
   WORD wMaxRight;
   TEXTMETRIC tm;
   RECT rct;
   int LineCount, HeaderHeight ;

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

   GetWindowRect( hWnd, &rct );
   wMaxRight = rct.right;

   GetTextMetrics( hDC, &tm );

   tm.tmHeight++;

   /* Calculate number of lines available to this Client Rect. */
   LineCount = ( ( ( rct.bottom - rct.top ) -
                 GetSystemMetrics( SM_CYHSCROLL ) ) / tm.tmHeight ) - 1 ;

   /* Add the extra space that will be left over on the bottom of the screen
      to the header. */
   // HeaderHeight = ( ( rct.bottom - rct.top ) -
   //                 GetSystemMetrics( SM_CYHSCROLL ) -
   //                 ( LineCount * tm.tmHeight ) ) ;

   // rct.top    += HeaderHeight + ( tm.tmHeight * ( wRow - 1 ) ) ;
   rct.top    += ( tm.tmHeight * wRow ) + 1;
   rct.bottom = rct.top + tm.tmHeight;
   rct.left   += wCol;
   rct.right  = rct.left + wWidth;

   if( hFont )
      SelectObject( hDC, hOldFont );

   ReleaseDC( hWnd, hDC );

   _reta( 4 );

   #ifdef __XPP__
      #define _storni( x, y, z ) STORNI( x, params, y, z )
   #endif

   _storni( rct.top,    -1, 1 );
   _storni( rct.left,   -1, 2 );
   _storni( rct.bottom, -1, 3 );
   _storni( ( wMaxRight <= rct.right ) ? wMaxRight - 18: rct.right, -1, 4 );
}

//---------------------------------------------------------------------------//
João Santos - São Paulo - Brasil
User avatar
mmercado
Posts: 782
Joined: Wed Dec 19, 2007 7:50 am
Location: Salamanca, Gto., México

Post by mmercado »

karinha wrote:Podria ayudarme? Donde cambio para funcionar perfecto?
Dime que estilo de línea quieres para poder indicarte _, por ejemplo:

nLineStyle 5 = Solo lineas verticales

Saludos.

Manuel Mercado
User avatar
karinha
Posts: 4882
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Post by karinha »

mmercado wrote:
karinha wrote:Podria ayudarme? Donde cambio para funcionar perfecto?
Dime que estilo de línea quieres para poder indicarte _, por ejemplo:

nLineStyle 5 = Solo lineas verticales

Saludos.

Manuel Mercado
Buenos dias maestro, desculpe la demora...

Lo que necisito, és que el BROWSE no muestre LAS LINEAS HORIZONTALES.

Gracias.
João Santos - São Paulo - Brasil
User avatar
mmercado
Posts: 782
Joined: Wed Dec 19, 2007 7:50 am
Location: Salamanca, Gto., México

Post by mmercado »

karinha wrote:Lo que necisito, és que el BROWSE no muestre LAS LINEAS HORIZONTALES
Aquí tienes tcbfuncs.c modificado:

nLineStyle 5 = Muestra solo lineas verticales
nLineStyle 6 = Muestra solo lineas horizontales

Code: Select all

#include <WinTen.h>
#include <Windows.h>
#include <ClipApi.h>

void WndDrawBox( HDC, LPRECT, HPEN, HPEN );
void DrawBitmap( HDC, HBITMAP, WORD wCol, WORD wRow, WORD wWidth, \
                 WORD wHeight, DWORD dwRaster );
void DrawMasked( HDC, HBITMAP, WORD wCol, WORD wRow );
void FrameDot( HDC hDC, RECT * pRect );

#ifdef __FLAT__
   DWORD MoveTo( HDC hdc, int x, int y );
#endif

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

HB_FUNC( TCDRAWCELL ) // ( PARAMS ) // ( hWnd, hDC, nRow, nColumn , nWidth ,
                      //   uData, nAlign , nClrFore, nClrBack ,
                      //   hFont, nBitmap, dwRaster, nLinesStyle )

{
   HWND hWnd        = ( HWND ) _parnl( 1 ) ;
   HDC  hDC         = ( HDC ) _parnl( 2 ) ;
   int  nRow        = _parni( 3 ) ;
   int  nColumn     = _parni( 4 ) ;
   int  nWidth      = _parni( 5 ) ;
   LPSTR cData      = _parc( 6 ) ;
   int  nLen        = _parclen( 6 ) ;
   UINT nAlign      = _parni( 7 ) ;
   COLORREF clrFore = ( PCOUNT() > 7 ? _parnl( 8 ): 0 );
   COLORREF clrBack = ( PCOUNT() > 8 ? _parnl( 9 ): RGB( 255, 255, 255 ) );
   HFONT hFont      = ( HFONT ) _parnl( 10 ) ;
   int     nBitMap  = _parni( 11 ) ;
   HBITMAP hBitMap  = ( HBITMAP ) _parnl( 6 ) ;  // redefine parm 6 as possible bitmap
   //DWORD dwRaster   = ( PCOUNT() > 11 ? _parnl( 12 ) : 0x5A0049 );
   HFONT hOldFont ;
   BOOL bDestroyDC  = FALSE ;
   HPEN hGrayPen, hWhitePen, hOldPen;
   TEXTMETRIC tm ;
   RECT rct ;
   int LineCount, HeaderHeight ;
   WORD  wLineStyle = _parni( 13 );
   HBRUSH hBrush;

   if( wLineStyle )
   {
      switch( wLineStyle )
      {
         case 1: // BLACK
              hGrayPen  = ( HPEN ) GetStockObject( BLACK_PEN );
              hWhitePen = hGrayPen;
              break;

         case 2: // GRAY
              hGrayPen  = CreatePen( PS_SOLID, 1, GetSysColor( COLOR_BTNSHADOW ) ) ; // RGB( 128, 128, 128 ) );
              hWhitePen = hGrayPen;
              break;

         case 3: // 3D
              hGrayPen  = CreatePen( PS_SOLID, 1, GetSysColor( COLOR_BTNSHADOW ) ) ; // RGB( 128, 128, 128 ) );
              hWhitePen = CreatePen( PS_SOLID, 1, GetSysColor( COLOR_BTNHIGHLIGHT ) ); // GetStockObject( WHITE_PEN );
              break;

         case 4: // DOTTED
              break;
         case 5: // Vertical gray lines
              hGrayPen  = CreatePen( PS_SOLID, 1, GetSysColor( COLOR_BTNSHADOW ) ) ; // RGB( 128, 128, 128 ) );
              hWhitePen = hGrayPen;
              break;
         case 6: // horizontal gray lines
              hGrayPen  = CreatePen( PS_SOLID, 1, GetSysColor( COLOR_BTNSHADOW ) ) ; // RGB( 128, 128, 128 ) );
              hWhitePen = hGrayPen;
              break;
         default :
              hGrayPen  = ( HPEN ) GetStockObject( BLACK_PEN );
              break ;
      }
   }

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

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

   GetClientRect( hWnd, &rct ) ;
   GetTextMetrics( hDC, &tm ) ;

   tm.tmHeight++;

   /* Calculate number of lines available to this Client Rect. */
   LineCount = ( ( rct.bottom - rct.top ) / tm.tmHeight ) - 1 ;

   /* Add the extra space that will be left over on the bottom of the screen
      to the header. */
   // HeaderHeight = ( ( rct.bottom - rct.top ) - ( LineCount * tm.tmHeight ) ) ;

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

   if( nRow == 0 )
      rct.top = 0 ;
   else
      rct.top = ( tm.tmHeight * nRow );

   if( rct.top + tm.tmHeight <= rct.bottom )
   {
      rct.bottom = rct.top + tm.tmHeight;

      /* Don't let left side go beyond rct.right of Client Rect. */
      if( nColumn - ( rct.right - rct.left) <= 0 )
      {
         rct.left   = nColumn ;

           /* if nWidth == -1, it indicates the last column so go to limit,
            Don't let right side go beyond rct.right of Client Rect. */
         if( ( nWidth != -1 ) && ((rct.left + nWidth - rct.right) <= 0) )
            rct.right  = rct.left + nWidth ;

         rct.right += 2;

         ExtTextOut( hDC, rct.left, rct.top + 1, ETO_OPAQUE | ETO_CLIPPED,
                     &rct, "", 0, 0  ) ;

         rct.left += 2 ;
         rct.right -= 4 ;

         if( nBitMap )
         {

         // use this next code to use ROPs, disable the 4 lines code below
         // also uncomment the dwRaster code in the begining of the function
	      // if ( nBitMap == 1 )
         //   dwRaster = 0;
         // DrawBitmap( hDC, hBitMap,  rct.top + 1, rct.left - 1, \
         //         rct.right - rct.left + 1,  rct.bottom - rct.top - 1, dwRaster );

              // DrawBitmap( hDC, hBitMap,  rct.top + 1, rct.left - 1, \
              //     rct.right - rct.left + 1,  rct.bottom - rct.top - 1, 0 );
              hBrush = CreateSolidBrush( clrBack );
              FillRect( hDC, &rct, hBrush );
              DeleteObject( hBrush );
              DrawMasked( hDC, hBitMap, rct.top, rct.left );

              // if ( nBitMap == 2 )
              //     InvertRect( hDC,  &rct) ;
         }
      else
      {
        if( nRow )
           rct.top++;

	      DrawText( hDC, cData, nLen, &rct, nAlign | DT_VCENTER |
                  DT_SINGLELINE | DT_NOPREFIX ) ;

        if( nRow )
           rct.top--;
      }

         rct.left -= 2 ;
         rct.right += 1 ;
         rct.bottom -= 1 ;

         if( wLineStyle )
         {
            if( wLineStyle != 3 ) // 3D
            {
               // rct.top--;
               rct.bottom++;
               if( rct.left > 0 )
                  rct.left--;
            }
            if( wLineStyle == 4 ) // DOTTED
               FrameDot( hDC, &rct );
            else
            {
               switch( wLineStyle )
               {
                  case 5 :
                       ExcludeClipRect( hDC, rct.left + 1, rct.top, rct.right -1, rct.bottom + 1 ) ;
                       break ;
                  case 6 :
                       ExcludeClipRect( hDC, rct.left, rct.top + 1, rct.right + 1, rct.bottom ) ;
                       break ;
               }

               WndDrawBox( hDC, &rct, hWhitePen, hGrayPen ) ;
            }
         }
      }
   }

   if( ! nRow )
   {
      // char buffer[ 100 ];

      // wsprintf( buffer, "top %02i: left %02i: bottom %02i: right %02i", rct.top, rct.left, rct.bottom, rct.right );
      // OutputDebugString( buffer );

      WndDrawBox( hDC, &rct, hWhitePen, ( HPEN ) GetStockObject( BLACK_PEN ) );
      hOldPen = ( HPEN ) SelectObject( hDC, hGrayPen );
      MoveTo( hDC, rct.left, rct.bottom - 1 );
      LineTo( hDC, rct.right, rct.bottom - 1 );
      MoveTo( hDC, rct.right - 1, rct.bottom - 1 );
      LineTo( hDC, rct.right - 1, rct.top );
      SelectObject( hDC, hOldPen );
   }

   if( wLineStyle )
   {
      switch( wLineStyle )
      {
         case 1: // BLACK
              break;    // it is a system resource, so do nothing

         case 2: // GRAY
              DeleteObject( hGrayPen );  // We just use this one
              break;

         case 3: // 3D
              DeleteObject( hGrayPen );
              DeleteObject( hWhitePen );
              break;

         case 4: // DOTTED
              break;                    // do nothing
         case 5: // VERTICAL GRAY
              DeleteObject( hGrayPen );
              break;
         case 6: // HORIZONTAL GRAY
              DeleteObject( hGrayPen );
              break;
      }
   }

   if( hFont )
      SelectObject( hDC, hOldFont ) ;

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

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

#ifdef __HARBOUR__
   HB_FUNC( TCBRWSCROLL )  //
#else
   CLIPPER TCBRWSCROL( PARAMS )  //
#endif
{
   HWND hWnd   = ( HWND ) _parnl( 1 );
   int wRows   = _parni( 2 );    // 04-22-00
   HFONT hFont = ( HFONT ) _parnl( 3 );
   HFONT hOldFont;
   HDC hDC     = GetDC( hWnd );
   RECT rct;
   TEXTMETRIC tm;

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

   GetClientRect( hWnd, &rct );
   GetTextMetrics( hDC, &tm );

   tm.tmHeight++;

   rct.top    += tm.tmHeight;
   rct.bottom -= ( ( rct.bottom - rct.top ) % tm.tmHeight );
   ScrollWindowEx( hWnd, 0, -( tm.tmHeight * wRows ), 0, &rct, 0, 0, 0 );

   if( hFont )
      SelectObject( hDC, hOldFont );

   ReleaseDC( hWnd, hDC );
}

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

static WORD near GetWindowRow( HWND hWnd, HDC hDC, WORD wGraphRow, \
                               HFONT hFont ) // -> wTextRow
{
   TEXTMETRIC tm;
   RECT rct;
   WORD wRow;
   BOOL bDCDestroy = FALSE;
   HFONT hOldFont;
	int LineCount, HeaderHeight ;

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

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

   GetTextMetrics( hDC, &tm );
   GetClientRect( hWnd, &rct );

   tm.tmHeight++;

   /* Calculate number of lines available to this Client Rect. */
   LineCount = ( ( rct.bottom - rct.top ) / tm.tmHeight ) - 1 ;

   /* Add the extra space that will be left over on the bottom of the screen
      to the header. */
   // HeaderHeight = ( ( rct.bottom - rct.top ) - ( LineCount * tm.tmHeight ) ) ;

   /*   wRow = ( wGraphRow - rct.top ) / tm.tmHeight;*/
   // if( wGraphRow - rct.top <= HeaderHeight )
   //   wRow = 0 ;
   // else
      wRow = ( ( wGraphRow - rct.top ) / tm.tmHeight );

   if( hFont )
      SelectObject( hDC, hOldFont );

   if( bDCDestroy )
      ReleaseDC( hWnd, hDC );

   return wRow;
}

HB_FUNC( NTCWROW ) // ( PARAMS )        // hWnd, hDC, nGraphRow, hFont -> nTextRow
{
   _retni( GetWindowRow( ( HWND ) _parnl( 1 ), ( HDC ) _parnl( 2 ),
                         _parni( 3 ), ( HFONT ) _parnl( 4 ) ) );
}

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

#ifdef __HARBOUR__
   HB_FUNC( ATCBRWPOSRECT ) // ( PARAMS ) // ( hWnd, nRow, nCol, nWidth, hFont )
#else
   CLIPPER ATCBRWPOSR( PARAMS ) // ect( hWnd, nRow, nCol, nWidth, hFont )
#endif
{
   HWND hWnd        = ( HWND ) _parnl( 1 );
   WORD wRow        = _parni( 2 );
   WORD wCol        = _parni( 3 );
   WORD wWidth      = _parni( 4 );
   HFONT hFont      = ( HFONT ) _parnl( 5 );
   HDC hDC          = GetDC( hWnd );
   HFONT hOldFont;
   WORD wMaxRight;
   TEXTMETRIC tm;
   RECT rct;
   int LineCount, HeaderHeight ;

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

   GetWindowRect( hWnd, &rct );
   wMaxRight = rct.right;

   GetTextMetrics( hDC, &tm );

   tm.tmHeight++;

   /* Calculate number of lines available to this Client Rect. */
   LineCount = ( ( ( rct.bottom - rct.top ) -
                 GetSystemMetrics( SM_CYHSCROLL ) ) / tm.tmHeight ) - 1 ;

   /* Add the extra space that will be left over on the bottom of the screen
      to the header. */
   // HeaderHeight = ( ( rct.bottom - rct.top ) -
   //                 GetSystemMetrics( SM_CYHSCROLL ) -
   //                 ( LineCount * tm.tmHeight ) ) ;

   // rct.top    += HeaderHeight + ( tm.tmHeight * ( wRow - 1 ) ) ;
   rct.top    += ( tm.tmHeight * wRow ) + 1;
   rct.bottom = rct.top + tm.tmHeight;
   rct.left   += wCol;
   rct.right  = rct.left + wWidth;

   if( hFont )
      SelectObject( hDC, hOldFont );

   ReleaseDC( hWnd, hDC );

   _reta( 4 );

   #ifdef __XPP__
      #define _storni( x, y, z ) STORNI( x, params, y, z )
   #endif

   _storni( rct.top,    -1, 1 );
   _storni( rct.left,   -1, 2 );
   _storni( rct.bottom, -1, 3 );
   _storni( ( wMaxRight <= rct.right ) ? wMaxRight - 18: rct.right, -1, 4 );
}
Saludos

Manuel Mercado
User avatar
karinha
Posts: 4882
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Post by karinha »

Gracias Maestro, voy intentar.

Best Regards, saludos.
João Santos - São Paulo - Brasil
Post Reply