FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour BITMAP NO TRANSPARENT
Posts: 3107
Joined: Fri Oct 07, 2005 06:28 PM
BITMAP NO TRANSPARENT
Posted: Wed Feb 24, 2010 04:34 PM
I HAVE A BITMAP

@ 10,10 BITMAP filename "test.bmp" SIZE 64,64 DESIGN

i MUST MOVE THIS BITMAP ON A WINDOW WITH DRAWGRID FUNCTION

THIS BITMAP IS NOT TRANSPARENT AND WHEN i MOVE IT COPY THE BACKGROUND ON NEW POSITION


HOW i CAN TO MOVE THIS BITMAP ON MODE TRANSPARENT ON THIS WINDOW ?


THE SIMPLY CODE

Code (fw): Select all Collapse
 #include "fivewin.ch"

FUNCTION main()
LOCAL oWnd ,oBmp

DEFINE window oWnd FROM 10,10 TO 80,80

@ 10,10 BITMAP oBmp  filename "C:\FWH\bitmaps\32x32\plus.bmp" DESIGN    SIZE 64,64

              oBmp:ltransparent:=.t.

ACTIVATE window oWnd ON PAINT DRAWGRID( oWnd:hWnd, oWnd:hdc, 1, 30, 30 )

RETURN NIL

#pragma BEGINDUMP

#include <Windows.h>
#include <HbApi.h>

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

HB_FUNC( DRAWGRID ) // hWnd, hDC, @cPS, wGridX, wGridY
{
   WORD wRow, wCol;
   HDC hDC = ( HDC ) hb_parnl( 2 );
   PAINTSTRUCT * ps = ( PAINTSTRUCT * ) hb_parc( 3 );
   WORD wGridX = hb_parni( 4 );
   WORD wGridY = hb_parni( 5 );
   RECT rc;
   WORD wWidth, wHeight;
   
   HPEN hOldPen;
   HPEN hGray   = CreatePen( PS_SOLID, 0, RGB( 210, 210, 210 ) );
   HPEN hGray2  = CreatePen( PS_SOLID, 0, RGB( 230, 230, 230 ) );
   
   hOldPen = ( HPEN ) SelectObject( hDC, hGray );

   GetWindowRect( ( HWND ) hb_parnl( 1 ), &rc );
   wWidth  = rc.right - rc.left + 1;
   wHeight = rc.bottom - rc.top + 1;

   for( wRow = 0; wRow <= wHeight; wRow += wGridX )
    {
        MoveTo( hDC, 0, wRow );
        LineTo( hDC, wWidth, wRow ) ; 
    }
      
   for( wCol = 0; wCol <= wWidth; wCol += wGridY )
    {
        MoveTo( hDC, wCol, 0 );
        LineTo( hDC, wCol, wHeight ) ; 
    }

   SelectObject( hDC, hGray2 );

   for( wRow = wGridX/2; wRow <= wHeight; wRow += wGridX )
    {
        MoveTo( hDC, 0, wRow );
        LineTo( hDC, wWidth, wRow ) ; 
    }
      
   for( wCol = wGridY/2; wCol <= wWidth; wCol += wGridY )
    {
        MoveTo( hDC, wCol, 0 );
        LineTo( hDC, wCol, wHeight ) ; 
    }
     
   SelectObject( hDC, hOldPen );
   DeleteObject( hGray );
   DeleteObject( hGray2);

         //SetPixel( hDC, wCol, wRow, 0 );
}

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

#pragma ENDDUM
Best Regards, Saludos



Falconi Silvio
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 PM
Re: BITMAP NO TRANSPARENT
Posted: Wed Feb 24, 2010 08:51 PM
Hello silvio

i will explain you...

1.- the current bitmap was alpha channel with white background, you can use this bitmap...
http://www.sitasoft.com/fivewin/bitmap/plus2.bmp

2.- the transparent in all controls come from the parent brush no from image background.
example:

http://www.sitasoft.com/fivewin/bitmap/grid.bmp

Code (fw): Select all Collapse
#include "fivewin.ch"

FUNCTION main()
LOCAL oWnd ,oBmp

LOCAL oBrush 

DEFINE BRUSH oBrush FILE "GRID.bmp"

DEFINE window oWnd FROM 10,10 TO 80,80 BRUSH oBrush

@ 10,10 BITMAP oBmp  filename "C:\FWH\bitmaps\32x32\plus2.bmp" SIZE 64, 64 ADJUST TRANSPARENT NOBORDER

ACTIVATE window oWnd 

RETURN NIL


3.- If you want move the bitmap around the window until the brush will be useless and will need paint the bitmap "with the hand" with transparencies techniques (seek in google about that) maybe bitblt function (http://msdn.microsoft.com/en-us/library/dd183370(VS.85).aspx) can help you, i don't know how do that
Posts: 3107
Joined: Fri Oct 07, 2005 06:28 PM
Re: BITMAP NO TRANSPARENT
Posted: Wed Feb 24, 2010 08:59 PM

SAME ERROR

WHEN YOU USE DESIGN COMMAND TO MOVE THE BITMAP

IT COPY THE OLD BACKGROUND INTO NEW POSITION

Best Regards, Saludos



Falconi Silvio
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 PM
Re: BITMAP NO TRANSPARENT
Posted: Wed Feb 24, 2010 09:43 PM
Silvio

Daniel Garcia-Gil wrote:3.- If you want move the bitmap around the window until the brush will be useless and will need paint the bitmap "with the hand" with transparencies techniques (seek in google about that) maybe bitblt function (http://msdn.microsoft.com/en-us/library/dd183370(VS.85).aspx) can help you, i don't know how do that
Posts: 3107
Joined: Fri Oct 07, 2005 06:28 PM
Re: BITMAP NO TRANSPARENT
Posted: Thu Feb 25, 2010 07:49 AM

this is strange....

With the fivewin power why not we cannot move a bitmap transparent into a window with drawgrid ?

I think we Not Know how make but i think and believe it can be done with the fivewin power language

Best Regards, Saludos



Falconi Silvio
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 PM
Re: BITMAP NO TRANSPARENT
Posted: Thu Feb 25, 2010 11:47 AM
Silvio

it isn't strange...

Silvio wrote:With the fivewin power why not we cannot move a bitmap transparent into a window with drawgrid ?

yes, and already you do that, but with the Windows OS standar features

FiveWin uses standard windows OS controls and other controls themselves, all controls created a "window".

The standard Windows OS feature, to create a window, only supports transparencies with brush, FiveWin added design mode for a more comprehensive management controls, but can not escape from the Windows OS features.

To do what you want, you can not use a normal control, you have to directly use the bitmap handle
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 PM
Re: BITMAP NO TRANSPARENT
Posted: Thu Feb 25, 2010 01:02 PM
Silvio

i found a possible solution... but you need the brush, same my last example

in CONTROL.PRG, method LButtonUp
LOCATE
Code (fw): Select all Collapse
if Empty( ::nMResize )
            ::Move( ::nTop + nRow - nMRow, ::nLeft + nCol - nMCol,,, .t. )


ADD AFTER
Code (fw): Select all Collapse
::Refresh()


http://www.sitasoft.com/fivewin/test/trans.zip
Code (fw): Select all Collapse
#include "fivewin.ch"

FUNCTION main()
   LOCAL oWnd ,oBmp
   LOCAL oBrush 
   
   DEFINE BRUSH oBrush FILE "grid.bmp"
   
   DEFINE WINDOW oWnd FROM 10,10 TO 400, 400 PIXEL BRUSH oBrush 
   
   @ 10,10 BITMAP oBmp  filename "plus2.bmp" SIZE 64, 64 ADJUST TRANSPARENT NOBORDER DESIGN
   
   ACTIVATE window oWnd 

RETURN NIL

Continue the discussion