DATA lBorder
DATA lRound
DATA nClrBorder
DATA cWaterImage
DATA hWaterImage
DATA nWaterTrans // 0 VISIBLE 300 TRASPARENT
change the new method
METHOD New( cTitle, oWnd, nIndex, cBmpPanel, nBodyHeight,lborder,;
nClrBorder,cWaterImage,nWatertrans ) CLASS TTaskPanel
...
DEFAULT nBodyHeight := 50
DEFAULT lBorder := .f.
DEFAULT nClrBorder := CLR_WHITE //RGB( 206, 99, 49 )
then loadbitmaps()
::lBorder := lBorder
::nClrBorder := nClrBorder
::cWaterImage := cWaterImage
::nWatertrans := nWatertrans
On Paint method
before this line local aInfo := ::DispBegin(), oItem, n
insert
local aRect := GetClientRect(::hWnd)
then before these lines
if ! Empty( ::aControls )
AEval( ::aControls, { | oControl | oControl:Refresh() } )
endif
insert
if ::lBorder
If ::lRound
RoundBox( ::hDC, aRect[ 2 ] , aRect[ 1 ] , aRect[ 4 ]-0.50 , aRect[ 3 ] , 5, 5, ::nClrBorder )
ELSE
RoundBox( ::hDC, aRect[ 2 ] , aRect[ 1 ] , aRect[ 4 ]-1 , aRect[ 3 ] , 0, 0, ::nClrBorder )
endif
endif
before ::DispEnd( aInfo )
insert
::WaterImage()
then add two new methods on ttaskpanel
METHOD WaterImage()
METHOD LoadImage( cImage )
- Code: Select all Expand view RUN
- METHOD WaterImage() CLASS TTaskPanel
local hBmp
if !Empty(::cWaterImage ) .and. !::lCollapsed
hBmp := ::LoadImage( ::cWaterImage )
if ::hWaterImage != 0
nWidth = nBmpWidth( hBmp )
nHeight = nBmpHeight( hBmp )
nTop := ::nHeight - nHeight-1
nLeft := ::nWidth - nWidth-10
nBottom := nTop + nHeight
nRight := nLeft + nWidth
nAlphaLevel := 20
DrawAlphaTransparentBitmap( ::hDC, hBmp, {nTop,nLeft,nBottom,nRight}, ::nWaterTrans, RGB(255,0,255) )
DeleteObject( hBmp )
ENDIF
ENDIF
RETURN NIL
METHOD LoadImage( cImage ) CLASS TTaskPanel
local hBmp := 0
hBmp := LoadBitmap( GetResources(), cImage )
if hBmp == 0
hBmp := ReadBitmap( 0, cImage )
endif
return hBmp
THAN ADD THIS FUNCTION
- Code: Select all Expand view RUN
//-----------------------------------------------------------------//
#pragma BEGINDUMP
#include "Windows.h"
#include "hbapi.h"
void DrawAlphaTransparentBitmap(HDC hDC, HBITMAP hBmp, RECT rc, BYTE iAlpha, COLORREF clrTrans)
{
typedef BOOL (CALLBACK *LPALPHABLEND)(HDC,int, int, int, int,HDC, int, int, int, int, BLENDFUNCTION);
LPALPHABLEND lpAlphaBlend; //static LPALPHABLEND lpAlphaBlend = (LPALPHABLEND) GetProcAddress( GetModuleHandle("msimg32.dll"), "AlphaBlend");
int cx, cy, x, y;
BOOL bRes;
LPDWORD pSrcBits, pDest, pSrc;
DWORD dwKey, dwShowColor;
BITMAPINFO bmi = { 0 };
HBITMAP hOldBitmap, bmpDest;
HDC dcCompat;
BLENDFUNCTION bf;
HINSTANCE hLib = LoadLibrary( "msimg32.dll" );
lpAlphaBlend = ( LPALPHABLEND ) GetProcAddress( hLib, "AlphaBlend" );
if( lpAlphaBlend == NULL )
{
FreeLibrary( hLib );
return;
}
cx = rc.right - rc.left;
cy = rc.bottom - rc.top;
bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bRes = GetDIBits(hDC, hBmp, 0, cy, NULL, &bmi, DIB_RGB_COLORS);
if( !bRes )
{
FreeLibrary( hLib );
return;
}
pSrcBits = (LPDWORD) LocalAlloc(LPTR, bmi.bmiHeader.biWidth * bmi.bmiHeader.biHeight * sizeof(DWORD));
bmi.bmiHeader.biBitCount = 32; // Ask for ARGB codec
bmi.bmiHeader.biCompression = BI_RGB;
bRes = GetDIBits(hDC, hBmp, 0, cy, pSrcBits, &bmi, DIB_RGB_COLORS);
if( !bRes || bmi.bmiHeader.biBitCount != 32 ) {
LocalFree(pSrcBits);
FreeLibrary( hLib );
return;
}
pDest = NULL;
bmpDest = CreateDIBSection(hDC, &bmi, DIB_RGB_COLORS, (LPVOID*) &pDest, NULL, 0);
if( bmpDest == NULL ) {
LocalFree(pSrcBits);
FreeLibrary( hLib );
return;
}
dwKey = RGB(GetBValue(clrTrans), GetGValue(clrTrans), GetRValue(clrTrans));
pSrc = pSrcBits;
dwShowColor = 0xFF000000;
for( y = 0; y < abs(bmi.bmiHeader.biHeight); y++ ) {
for( x = 0; x < bmi.bmiHeader.biWidth; x++ ) {
if( *pSrc != dwKey ) *pDest++ = *pSrc | dwShowColor;
else *pDest++ = 0x00000000;
pSrc++;
}
}
dcCompat = CreateCompatibleDC(hDC);
hOldBitmap = (HBITMAP) SelectObject(dcCompat, bmpDest);
SetStretchBltMode(hDC, COLORONCOLOR);
bf.BlendOp = AC_SRC_OVER;
bf.BlendFlags = 0;
bf.AlphaFormat = AC_SRC_ALPHA;
bf.SourceConstantAlpha = iAlpha;
//bRes =
lpAlphaBlend(hDC, rc.left, rc.top, cx, cy, dcCompat, 0, 0, cx, cy, bf);
SelectObject(dcCompat, hOldBitmap);
LocalFree(pSrcBits);
FreeLibrary( hLib );
}
HB_FUNC( DRAWALPHATRANSPARENTBITMAP )
{
RECT rc;
rc.top = hb_parni( 3, 1 );
rc.left = hb_parni( 3, 2 );
rc.bottom = hb_parni( 3, 3 );
rc.right = hb_parni( 3, 4 );
DrawAlphaTransparentBitmap((HDC) hb_parnl( 1 ),
(HBITMAP) hb_parnl( 2 ),
rc,
(BYTE) hb_parni( 4 ),
(COLORREF) hb_parnl( 5 ));
hb_ret();
}
#pragma ENDDUMP
THEN YOU CAN ADD ALSO ANEW COMMAND INTO YOUR CH FILES
#xcommand ADD PANEL [ <oPanel> ] ;
[ <of: OF> <oExBar> ];
[ HEIGHT <nHeight> ] ;
[ <lBorder: BORDER> ] ;
[ BORDERCOLOR <nClrBorder> ];
[ WATERIMAGE <cWaterImage> ] ;
[ NTRANSPARENT <nWaterTrans> ] ;
[ <color: COLOR, COLORS> <nClrText> ,<nClrPane> ] ;
[ <lOpenClose:OPENCLOSE > ] ; //NOT RUN YET!
[ BMPBTN <cBmpUp>[, <cBmpDown>]] ;
=>;
[ <oPanel> := ] <oExBar>:AddPanel( <nHeight>,;
[<.lBorder.>],<nClrBorder>,<cWaterImage>,[ <nWaterTrans> ],;
<nClrText>, <nClrPane>,[ <.lOpenClose.> ],[ <cBmpUp> ],[ <cBmpDown> ] )