FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour Error: drawvbox.c 33: Suspicious pointer conversion
Posts: 1078
Joined: Thu Sep 27, 2007 03:47 PM
Error: drawvbox.c 33: Suspicious pointer conversion
Posted: Thu Aug 19, 2010 08:26 PM
Cual puede ser del error


Warning W8075 k:\proy_harb\libprg\drawvbox.c 33: Suspicious pointer conversion

Codigo

Code (fw): Select all Collapse
/ Developed by Vagner Wirts
//
// Pequeñas modificaciones por Vikthor y Daniel Andrade [AD2K]
//
// ULTIMA MODIFICACION: 05/mar/2003

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


void BoxDegrade(HDC hDC, RECT * rOrig, LPSTR cTexto, COLORREF cCorT, COLORREF cCor1, COLORREF cCor2, int nAlinha ,BOOL lRaised,BOOL lTransp) ;

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

// By Vikthor
// Llamado a Clipper
#ifndef __HARBOUR__
   CLIPPER DrawVBox( PARAMS ) // hWnd, hDC, cTexto,cCorT , cCor1, cCor2, nAlinha,
                              // lRaised, hFont, lTransp
                              //   nClrTo, lDegrad, hBrush )
#else
// Ahora para Harbour
   HARBOUR HB_FUN_DRAWVBOX( PARAMS )    //  ¡¡ A fuerzas deben ser mayusculas  !!


#endif

{
    HWND hWnd      = ( HWND ) _parni( 1 );
    HDC hDC        = ( HDC )  _parni( 2 );
    LPSTR cTexto   =          _parc(  3 );
    COLORREF cCorT =          _parnl( 4 );
    COLORREF cCor1 =          _parnl( 5 );
    COLORREF cCor2 =          _parnl( 6 );
  char nAlinha   =          _parni( 7 );  // char nAlinha   =          _parni( 7 );
    BOOL lRaised   =          _parl(  8 );
  HFONT hFont    = (HFONT)  _parni( 9 );  // By Vikthor
    BOOL lTransp   =          _parl( 10 );
    HFONT hFontOld;
    RECT rct;

    /*------------- Tipos de Molduras --------------*/
    /* nAlinha == 1 - Escrita na Esquerda (default) */
    /*         == 2 - Escrita no Centro             */
    /*         == 3 - Escrita na Direita            */
    /*----------------------------------------------*/
    nAlinha = (nAlinha < 1 || nAlinha > 3 ? 1 : nAlinha) ;

    GetClientRect( hWnd, &rct );
  rct.bottom ++;                    // [AD2K]

    if(hFont) hFontOld = SelectObject(hDC,hFont) ;

    BoxDegrade( hDC, &rct, cTexto, cCorT ,cCor1, cCor2, nAlinha, lRaised, lTransp );

    if(hFont) SelectObject(hDC,hFontOld) ;

}

void BoxDegrade(HDC hDC, RECT * rOrig, LPSTR cTexto , COLORREF cCorT, COLORREF cCor1, COLORREF cCor2, int nAlinha ,BOOL lRaised,BOOL lTransp )
{
    int nColoR1,nColoG1,nColoB1,nColoR2,nColoG2,nColoB2;
    RECT rct,rcti,rctOri,rctTem;
    HBRUSH hBrush;
    signed int nSomaR,nSomaG,nSomaB,nSoma;
    int nStep , nFor;
    WORD nPosTex ,nAltura,nLargura,nLenTex;
    DWORD dwExtent;
    SIZE sz;                            // By Vikthor
    TEXTMETRIC tm;                      // By Vikthor

    nLenTex    = _parclen(3);
    rct.top    = rOrig->top ;
    rct.left   = rOrig->left ;
    rct.bottom = rOrig->bottom ;
    rct.right  = rOrig->right ;

    rctOri = rcti = rct;

    /*---- Sempre subtrai metade do tamanho do texto ----*/
  //dwExtent = GetTextExtent(hDC, (LPCSTR) cTexto,lstrlen(cTexto));

  /*
   * By Vikthor
   */
  #ifndef __FLAT__
    dwExtent = GetTextExtent( hDC, (LPCSTR) cTexto, strlen(cTexto) );
  #else
    GetTextExtentPoint32( hDC, (LPCSTR) cTexto , strlen(cTexto) , &sz );
    dwExtent = sz.cx;
  #endif

  /*
   * Para Obtener correctamente la Altura del Texto
   */
  GetTextMetrics( hDC, &tm );         // By Vikthor
  nAltura  = tm.tmHeight ;            // By Vikthor

//  nAltura  = LOWORD(dwExtent);      // No funciona correctamente
  nLargura = LOWORD(dwExtent);

    if(!strlen(cTexto) >= 1)   // By Vikthor
        {
        rct.top  += 6;
        rcti.top  = rct.top;
    rct.bottom += 6;              // [AD2K]
    rcti.bottom = rct.bottom;     // [AD2K]
        }

    if(!lTransp)
        {
        nColoR1 = GetRValue(cCor1);
        nColoG1 = GetGValue(cCor1);
        nColoB1 = GetBValue(cCor1);

        nColoR2 = GetRValue(cCor2);
        nColoG2 = GetGValue(cCor2);
        nColoB2 = GetBValue(cCor2);

        nSomaR = abs( nColoR2 - nColoR1 ) ;
        nSomaG = abs( nColoG2 - nColoG1 ) ;
        nSomaB = abs( nColoB2 - nColoB1 ) ;

        nStep = ((rct.bottom/2) - rct.top + 1) ;  // [AD2K]

        nSoma = nStep/100 ;
    nSoma = max(nSoma,1) ;   // Vikthor
                             // En Mayusculas da error , asi que se declara en minusculas

        nSomaR = ( nSomaR <= 0 ? 0 : ( nSomaR / (nStep*2) ) ) ; // [AD2K]
        nSomaG = ( nSomaG <= 0 ? 0 : ( nSomaG / (nStep*2) ) ) ; // [AD2K]
        nSomaB = ( nSomaB <= 0 ? 0 : ( nSomaB / (nStep*2) ) ) ; // [AD2K]

    nSomaR = max(nSomaR,1);         // Vikthor
    nSomaG = max(nSomaG,1);         // Vikthor
    nSomaB = max(nSomaB,1);         // Vikthor

        rct.bottom = rct.top;

        for( nFor = 0; nFor <= (nStep*2) ; nFor++ )
            {
        rct.bottom += nSoma;
            if(strlen(cTexto) >= 1 && nFor <= (nAltura/2))
                {
                if(nAlinha==1)  //left
                    rct.right = rct.left+nLargura;
                if(nAlinha==2)  //Center
                    {
                    rct.left  = ((rcti.right-rcti.left)-nLargura)/2 ;
                    rct.right = rct.left+nLargura ;
                    }
                if(nAlinha==3)  //right
                    rct.left  = rct.right-nLargura;
                }
            else
            {
                rct.left  = rcti.left;
                rct.right = rcti.right;
            }
            hBrush = CreateSolidBrush(RGB(nColoR1, nColoG1, nColoB1));

      FillRect( hDC, &rct, hBrush );

            DeleteObject(hBrush);

            rct.top  += nSoma;

            nColoR1 = (nColoR2 > nColoR1 ? nColoR1 + nSomaR : nColoR1 - nSomaR ) ;
            nColoG1 = (nColoG2 > nColoG1 ? nColoG1 + nSomaG : nColoG1 - nSomaG ) ;
            nColoB1 = (nColoB2 > nColoB1 ? nColoB1 + nSomaB : nColoB1 - nSomaB ) ;

            nColoR1 = (nColoR1 < 0 ? 0 : nColoR1 > 255 ? 255 : nColoR1);
            nColoG1 = (nColoG1 < 0 ? 0 : nColoG1 > 255 ? 255 : nColoG1);
            nColoB1 = (nColoB1 < 0 ? 0 : nColoB1 > 255 ? 255 : nColoB1);

            }
        }

    if(strlen(cTexto) >= 1)
        {
        nPosTex = (nAlinha == 1 ? DT_LEFT : nAlinha == 2 ? DT_CENTER : DT_RIGHT ) ;

        SetBkMode(hDC,TRANSPARENT);
        /*---- Escrita ----*/
        SetTextColor( hDC, cCorT);
        rcti.top += 1;
        rcti.bottom = rcti.top+nAltura;
        DrawText( hDC, cTexto, nLenTex, &rcti, nPosTex+DT_VCENTER);
        }

    /*----------------------- Monta a Moldura ----------------------*/
    /* Montei com Brush ao inves de LineTo para nao perder recursos */
    /*--------------------------------------------------------------*/

    rctOri.top += (strlen(cTexto) >= 1 ? nAltura/2 : 6) ;
    rctOri.top ++;

    /*---- 1¦ Moldura ----*/
    hBrush = CreateSolidBrush(GetSysColor((!lRaised ? 20 : 16)));

    /*- Linha Superior -*/
    if(strlen(cTexto) >= 1)
        {
        if(nAlinha==1)  //Left
            {
            /*---- Linha Lateral Direita do Texto ----*/
            rctTem.top    = (rctOri.top - (nAltura/2))-1 ;
            rctTem.left   = rctOri.left                  ;
            rctTem.bottom = rctOri.top                   ;
            rctTem.right  = rctOri.left               +1 ;
            FillRect( hDC, &rctTem, hBrush )             ;

            /*---- Linha Superior do Texto ----*/
            rctTem.bottom = rctTem.top           +1 ;
            rctTem.right  = rctOri.left+nLargura +1 ;
            FillRect( hDC, &rctTem, hBrush )        ;

            /*---- Linha Lateral Esquerda do Texto ----*/
            rctTem.left   = rctTem.right  -1 ;
            rctTem.bottom = rctOri.top       ;
            FillRect( hDC, &rctTem, hBrush ) ;

            /*---- Linha Inferior do Texto ----*/
            rctTem.top    = rctTem.bottom -1 ;
            rctTem.right  = rctOri.right  +1 ;
            FillRect( hDC, &rctTem, hBrush ) ;
            }

        if(nAlinha==2)  //Center
            {
            /*---- Linha Inferior do Texto Esquerda ----*/
            rctTem.top    = rctOri.top-1                              ;
            rctTem.left   = rctOri.left                               ;
            rctTem.bottom = rctOri.top                                ;
            rctTem.right  = (((rctOri.right-rctOri.left)-nLargura)/2) ;
            FillRect( hDC, &rctTem, hBrush )                          ;

            /*---- Linha Lateral Direita do Texto ----*/
            rctTem.top    = (rctOri.top - (nAltura/2)) -1 ;
            rctTem.left   = rctTem.right                  ;
            rctTem.right  ++                              ;
            FillRect( hDC, &rctTem, hBrush )              ;

            /*---- Linha Superior do Texto ----*/
            rctTem.bottom = (rctOri.top - (nAltura/2))   ;
            rctTem.right  += nLargura                 -1 ;
            FillRect( hDC, &rctTem, hBrush )             ;

            /*---- Linha Lateral Esquerda do Texto ----*/
            rctTem.left   = rctTem.right     ;
            rctTem.bottom = rctOri.top       ;
            rctTem.right  ++                 ;
            FillRect( hDC, &rctTem, hBrush ) ;

            /*---- Linha Inferior do Texto Esquerda ----*/
            rctTem.top    = rctTem.bottom -1 ;
            rctTem.bottom = rctOri.top       ;
            rctTem.right  = rctOri.right  +1 ;
            FillRect( hDC, &rctTem, hBrush ) ;
            }

        if(nAlinha==3)  //Right
            {
            /*---- Inferior Direita do Texto ----*/
            rctTem.top    = rctOri.top         -1 ;
            rctTem.left   = rctOri.left           ;
            rctTem.bottom = rctOri.top            ;
            rctTem.right  = rctOri.right-nLargura ;
            FillRect( hDC, &rctTem, hBrush )      ;

            /*---- Lateral Direita do Texto ----*/
            rctTem.top    -= (nAltura/2)     ;
            rctTem.left   = rctTem.right  -1 ;
            FillRect( hDC, &rctTem, hBrush ) ;

            /*---- Linha Superior do Texto ----*/
            rctTem.bottom = rctTem.top    +1 ;
            rctTem.right  = rctOri.right  +1 ;
            FillRect( hDC, &rctTem, hBrush ) ;

            /*---- Linha Lateral Esquerda do Texto ----*/
            rctTem.left   = rctTem.right     ;
            rctTem.bottom = rctOri.top       ;
            rctTem.right  ++                 ;
            FillRect( hDC, &rctTem, hBrush ) ;
            }
        }
    else
    {
        rctTem.top    = rctOri.top    -1 ;
        rctTem.left   = rctOri.left   +1 ;
        rctTem.bottom = rctOri.top       ;
        rctTem.right  = rctOri.right  +1 ;
        FillRect( hDC, &rctTem, hBrush ) ;
    }

    /*- Linha Lateral Esquerda -*/
    rctTem.top    = rctOri.top    -1 ;
    rctTem.left   = rctOri.right  +1 ;
    rctTem.bottom = rctOri.bottom +2 ;
    rctTem.right  = rctOri.right  +2 ;
    FillRect( hDC, &rctTem, hBrush ) ;

    /*- Linha Inferior -*/
    rctTem.top    = rctTem.bottom    ;
    rctTem.left   = rctOri.left   +1 ;
    rctTem.bottom ++                 ;
    FillRect( hDC, &rctTem, hBrush ) ;

    /*- Linha Lateral Direita -*/
    rctTem.top    = rctOri.top    -1 ;
    rctTem.left   = rctTem.left   -1 ;  // --                 ; // [AD2K] 16
    rctTem.right  = rctTem.left   +1 ;
    FillRect( hDC, &rctTem, hBrush ) ;

    DeleteObject(hBrush);

    /*---- 2¦ Moldura ----*/
    hBrush = CreateSolidBrush(GetSysColor((!lRaised ? 16 : 20)));

    if(strlen(cTexto) >= 1)
        {
        if(nAlinha==1)  //Left
            {
            /*---- Linha Lateral Direita do Texto ----*/
            rctTem.top    = (rctOri.top - (nAltura/2))-2 ;
            rctTem.left   = rctOri.left               -1 ;
            rctTem.bottom = rctOri.top                -1 ;
            rctTem.right  = rctOri.left                  ;
            FillRect( hDC, &rctTem, hBrush )             ;

            /*---- Linha Superior do Texto ----*/
            rctTem.bottom = rctTem.top           +1 ;
            rctTem.right  = rctOri.left+nLargura -1 ;
            FillRect( hDC, &rctTem, hBrush )        ;

            /*---- Linha Lateral Esquerda do Texto ----*/
            rctTem.left   = rctTem.right     ;
            rctTem.right  ++                 ;
            rctTem.bottom = rctOri.top    -1 ;
            FillRect( hDC, &rctTem, hBrush ) ;

            /*---- Linha Inferior do Texto ----*/
            rctTem.top    = rctTem.bottom -1 ;
            rctTem.right  = rctOri.right  +1 ;
            FillRect( hDC, &rctTem, hBrush ) ;
            }

        if(nAlinha==2)  //Center
            {
            /*---- Linha Inferior do Texto Esquerda ----*/
            rctTem.top    = rctOri.top                               -2 ;
            rctTem.left   = rctOri.left                              -1 ;
            rctTem.bottom = rctOri.top                               -1 ;
            rctTem.right  = (((rctOri.right-rctOri.left)-nLargura)/2)-1 ;
            FillRect( hDC, &rctTem, hBrush )                            ;

            /*---- Linha Lateral Direita do Texto ----*/
            rctTem.top    = (rctOri.top - (nAltura/2))-2 ;
            rctTem.left   = rctTem.right                 ;
            rctTem.right  ++                             ;
            FillRect( hDC, &rctTem, hBrush )             ;

            /*---- Linha Superior do Texto ----*/
            rctTem.bottom = (rctOri.top - (nAltura/2))-1 ;
            rctTem.right  += nLargura                 -1 ;
            FillRect( hDC, &rctTem, hBrush )             ;

            /*---- Linha Lateral Esquerda do Texto ----*/
            rctTem.left   = rctTem.right     ;
            rctTem.bottom = rctOri.top    -1 ;
            rctTem.right  ++                 ;
            FillRect( hDC, &rctTem, hBrush ) ;

            /*---- Linha Inferior do Texto Esquerda ----*/
            rctTem.top    = rctTem.bottom -1 ;
            rctTem.bottom = rctOri.top-1     ;
            rctTem.right  = rctOri.right  +1 ;
            FillRect( hDC, &rctTem, hBrush ) ;
            }

        if(nAlinha==3)  //Right
            {
            /*---- Inferior Direita do Texto ----*/
            rctTem.top    = rctOri.top           -2 ;
            rctTem.left   = rctOri.left          -1 ;
            rctTem.bottom = rctOri.top           -1 ;
            rctTem.right  = rctOri.right-nLargura-1 ;
            FillRect( hDC, &rctTem, hBrush )        ;

            /*---- Lateral Direita do Texto ----*/
            rctTem.top    -= (nAltura/2)     ;
            rctTem.left   = rctTem.right-1   ;
            FillRect( hDC, &rctTem, hBrush ) ;

            /*---- Linha Superior do Texto ----*/
            rctTem.bottom = rctTem.top    +1 ;
            rctTem.right  = rctOri.right     ;
            FillRect( hDC, &rctTem, hBrush ) ;

            /*---- Linha Lateral Esquerda do Texto ----*/
            rctTem.left   = rctTem.right     ;
            rctTem.bottom = rctOri.top    -1 ;
            rctTem.right  ++                 ;
            FillRect( hDC, &rctTem, hBrush ) ;
            }
        }
    else
    {
        rctTem.top    = rctOri.top    -2 ;
        rctTem.left   = rctOri.left   -1 ;
        rctTem.bottom = rctOri.top    -1 ;
        rctTem.right  = rctOri.right     ;
        FillRect( hDC, &rctTem, hBrush ) ;
    }

    /*- Linha Lateral Esquerda -*/
    rctTem.top    = rctOri.top    -2 ;
    rctTem.left   = rctOri.right     ;
    rctTem.bottom = rctOri.bottom +1 ;
    rctTem.right  = rctOri.right  +1 ;
    FillRect( hDC, &rctTem, hBrush ) ;

    /*- Linha Inferior -*/
    rctTem.top    = rctTem.bottom    ;
    rctTem.left   = rctOri.left      ;
    rctTem.bottom ++                 ;
    FillRect( hDC, &rctTem, hBrush ) ;

    /*- Linha Lateral Direita -*/
    rctTem.top    = rctOri.top    -1 ;
    rctTem.left   = rctTem.left   -1 ; // --                 ;  // [AD2K] 16
    rctTem.right  = rctTem.left   +1 ;
    FillRect( hDC, &rctTem, hBrush ) ;

    DeleteObject(hBrush);
}
Ruben Dario Gonzalez
Cali-Colombia
rubendariogd@hotmail.com - rubendariogd@gmail.com
Posts: 71
Joined: Fri Jan 11, 2008 06:55 AM
Re: Error: drawvbox.c 33: Suspicious pointer conversion
Posted: Thu Aug 19, 2010 08:45 PM
Ruben,

Cambia esta linea
Code (fw): Select all Collapse
LPSTR cTexto   =          _parc(  3 );


por
Code (fw): Select all Collapse
LPSTR cTexto   = (LPSTR)   _parc(  3 );


Saludos,
Andres reyes
{{{ ---- xharbour + Borland C --- }}}

Continue the discussion