Bug in TBar?

Re: Bug in TBar?

Postby ukservice » Fri Oct 07, 2011 2:04 pm

Antonio,

I search into Manual and Wiki for function IsGdiObject() and it does not exist.

My PC has 8 GB of RAM, so I think it is not a question of memory (unless FWH does not manage 8 GB as it happened with nExtMem()).

Point 3 sounds very interesting. I await your instructions.

Thanks a lot.
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: Bug in TBar?

Postby Daniel Garcia-Gil » Fri Oct 07, 2011 2:18 pm

User avatar
Daniel Garcia-Gil
 
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita

Re: Bug in TBar?

Postby ukservice » Fri Oct 07, 2011 3:30 pm

Daniel,

How are Bmps painted in Ribbon?. Does Ribbon use TBar?.

How can I track painted bmps?.

Thanks.
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: Bug in TBar?

Postby Antonio Linares » Fri Oct 07, 2011 5:27 pm

Please add this code to your main PRG:

Code: Select all  Expand view
#pragma BEGINDUMP

#include <windows.h>
#include <hbapi.h>

static void TransBmp( HBITMAP hBitmap, int iXsize, int iYsize,
               COLORREF rgbTransparent, HDC hDC,
               int iXOffset, int iYOffset, int iWidth, int iHeight )
{
  HDC mDC, nDC;
  HBITMAP hMask, hBmOld1, hBmOld2;
  LPBYTE lpBits;

  mDC = CreateCompatibleDC( hDC );
 
  if( mDC )
  {
    hBmOld1 = ( HBITMAP ) SelectObject( mDC, hBitmap );

    lpBits = ( LPBYTE ) hb_xgrab( iXsize * iYsize * 2 );
    if( lpBits )
    {
      hMask = CreateBitmap( iXsize, iYsize, 1, 1, lpBits );
      if( hMask )
      {
        nDC = CreateCompatibleDC( hDC );
        if( nDC )
        {
          hBmOld2 = ( HBITMAP ) SelectObject( nDC, hMask );
          SetBkColor( mDC, rgbTransparent );

          BitBlt( nDC, 0, 0, iXsize, iYsize, mDC, 0, 0, SRCCOPY );

          SetStretchBltMode( hDC, COLORONCOLOR );

          StretchBlt( hDC, iXOffset, iYOffset, iWidth, iHeight,
                      mDC, 0, 0, iXsize, iYsize,
                      SRCINVERT );

          StretchBlt( hDC, iXOffset, iYOffset, iWidth, iHeight,
                      nDC, 0, 0, iXsize, iYsize,
                      SRCAND );

          StretchBlt( hDC, iXOffset, iYOffset, iWidth, iHeight,
                      mDC, 0, 0, iXsize, iYsize,
                      SRCINVERT );

          SelectObject( nDC, hBmOld2 );
          DeleteDC( nDC );
        }
        else
           MessageBox( 0, "Can't create compatible DC!", "Error", 0 );

        DeleteObject( hMask );
      }
      else
        MessageBox( 0, "Can't create bitmap!", "Error", 0 );

      hb_xfree( lpBits );
    }
    else
            MessageBox( 0, "Can't allocate memory!", "Error", 0 );
   
SelectObject( mDC, hBmOld1 );
    DeleteDC( mDC );
  }
  else
     MessageBox( 0, "Can't create DC!", "Error", 0 );
}

HB_FUNC( TRANSBMP )
{
   TransBmp( ( HBITMAP ) hb_parnl( 1 ), hb_parnl( 2 ), hb_parnl( 3 ), hb_parnl( 4 ),
             ( HDC ) hb_parnl( 5 ), hb_parnl( 6 ), hb_parnl( 7 ), hb_parnl( 8 ),
             hb_parnl( 9 ) );   
}

#pragma ENDDUMP
 
regards, saludos

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

Re: Bug in TBar?

Postby ukservice » Fri Dec 09, 2011 2:57 pm

Antonio,

It happened today in Ribbon but no messagebox appear!!!.

Is above TransBmp included in FW 11.11?.

Can you check it?.

Thanks.
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: Bug in TBar?

Postby ukservice » Sun Dec 11, 2011 7:44 pm

up
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: Bug in TBar?

Postby ukservice » Mon Dec 12, 2011 3:10 pm

Daniel?.

Any idea or clue?.

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: Bug in TBar?

Postby Daniel Garcia-Gil » Mon Dec 12, 2011 3:42 pm

Hello

i have not any error or bug with this class, can you provide a sample we can reproduce the problem...

thanks
User avatar
Daniel Garcia-Gil
 
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita

Re: Bug in TBar?

Postby Enrico Maria Giordano » Mon Dec 12, 2011 3:53 pm

Unfortunately not. It is very very random. Myself I didn't saw the problem anymore.

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

Re: Bug in TBar?

Postby ukservice » Mon Dec 12, 2011 3:55 pm

Enrico, thanks for listening.

Daniel, is TransBmp´s funcion pasted above included in FW 11.11?.

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: Bug in TBar?

Postby Antonio Linares » Mon Dec 12, 2011 8:47 pm

John,

yes, it is but without the MessageBox() calls
regards, saludos

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

Re: Bug in TBar?

Postby ukservice » Tue Dec 13, 2011 8:07 am

Antonio,

I need please latest source with MessageBox in order to trace the bug.

Where should I put the code?.

Thanks.
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: Bug in TBar?

Postby Antonio Linares » Tue Dec 13, 2011 9:01 pm

John,

If you include that code in one of your own PRGs, your function will be used instead of FWH one
regards, saludos

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

Re: Bug in TBar?

Postby ukservice » Fri Dec 16, 2011 1:24 pm

Antonio,

Done.

I also added a number to each message to trace the error:

Code: Select all  Expand view

#pragma BEGINDUMP

#include <windows.h>
#include <hbapi.h>

static void TransBmp( HBITMAP hBitmap, int iXsize, int iYsize,
               COLORREF rgbTransparent, HDC hDC,
               int iXOffset, int iYOffset, int iWidth, int iHeight )
{
  HDC mDC, nDC;
  HBITMAP hMask, hBmOld1, hBmOld2;
  LPBYTE lpBits;

  mDC = CreateCompatibleDC( hDC );


  if( mDC )
  {
    hBmOld1 = ( HBITMAP ) SelectObject( mDC, hBitmap );

    lpBits = ( LPBYTE ) hb_xgrab( iXsize * iYsize * 2 );
    if( lpBits )
    {
      hMask = CreateBitmap( iXsize, iYsize, 1, 1, lpBits );
      if( hMask )
      {
        nDC = CreateCompatibleDC( hDC );
        if( nDC )
        {
          hBmOld2 = ( HBITMAP ) SelectObject( nDC, hMask );
          SetBkColor( mDC, rgbTransparent );

          BitBlt( nDC, 0, 0, iXsize, iYsize, mDC, 0, 0, SRCCOPY );

          SetStretchBltMode( hDC, COLORONCOLOR );

          StretchBlt( hDC, iXOffset, iYOffset, iWidth, iHeight,
                      mDC, 0, 0, iXsize, iYsize,
                      SRCINVERT );

          StretchBlt( hDC, iXOffset, iYOffset, iWidth, iHeight,
                      nDC, 0, 0, iXsize, iYsize,
                      SRCAND );

          StretchBlt( hDC, iXOffset, iYOffset, iWidth, iHeight,
                      mDC, 0, 0, iXsize, iYsize,
                      SRCINVERT );

          SelectObject( nDC, hBmOld2 );
          DeleteDC( nDC );
        }
        else
           MessageBox( 0, "(1) Can't create compatible DC!", "Error", 0 );

        DeleteObject( hMask );
      }
      else
        MessageBox( 0, "(2) Can't create bitmap!", "Error", 0 );

      hb_xfree( lpBits );
    }
    else
            MessageBox( 0, "(3) Can't allocate memory!", "Error", 0 );

SelectObject( mDC, hBmOld1 );
    DeleteDC( mDC );
  }
  else
     MessageBox( 0, "(4) Can't create DC!", "Error", 0 );
}

HB_FUNC( TRANSBMP )
{
   TransBmp( ( HBITMAP ) hb_parnl( 1 ), hb_parnl( 2 ), hb_parnl( 3 ), hb_parnl( 4 ),
             ( HDC ) hb_parnl( 5 ), hb_parnl( 6 ), hb_parnl( 7 ), hb_parnl( 8 ),
             hb_parnl( 9 ) );
}

#pragma ENDDUMP
 


Form this .c code, how could I invoke Fivewin´s error system to generate an error.log file with all the debug info to trace this bug?.
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: Bug in TBar?

Postby ukservice » Sat Dec 24, 2011 1:00 pm

Antonio,

I was able to trace the error.

Most of the buttons of the ribbon where painted, but in one case I got:

Error (2) Can't create bitmap!. Please, see above code to see error numbers.

Code: Select all  Expand view
Stack Calls
===========
   Called from:  => TRANSBMP( 0 )
   Called from: .\source\classes\TRBTN.PRG => TRBTN:PAINT( 1428 )
   Called from: .\source\classes\TRBTN.PRG => (b)TRBTN( 102 )
   Called from: .\source\classes\TRBTN.PRG => TRBTN:DISPLAY( 0 )
   Called from: .\source\classes\CONTROL.PRG => TCONTROL:HANDLEEVENT( 1665 )
   Called from: .\source\classes\TRBTN.PRG => TRBTN:HANDLEEVENT( 1516 )
   Called from: .\source\classes\WINDOW.PRG => _FWH( 3160 )
   Called from:  => WINRUN( 0 )
   Called from: .\source\classes\WINDOW.PRG => TWINDOW:ACTIVATE( 989 )
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

PreviousNext

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 48 guests