Antonio, thank you very much
To have Bottom and Right as well,
like the other BMP's, i could design a frame.
Then there are still other things possible.
Just a underline
Code: Select all
FUNCTION ONPAINT(oDlg1,hDC,oBmp,nVColor, nBColor,nColor,cText, ;
oBFont,nPOSLEFT, nEND, nORIENT,cBRUSH, nPEN )
LOCAL hOldFont, oNewbrush, hBitmap, aRect, oBmp1, nTOP, nLEFT
LOCAL oBmp2, nCENTER
hOldFont := SelectObject( hDC, oBFont:hFont )
nTXTLG := GettextWidth( hDC, cText )
nBMPLONG := oBmp:Super:nWidth()
nBMPHIGHT := oBmp:Super:nHeight()
nFONTHIGHT := e_oBfont1:nInpHeight * -1
IF nPOSLEFT = 0
nLEFT := (nBMPLONG - nTXTLG) / 2
ELSE
nLEFT := nPOSLEFT
ENDIF
nNEWHIGHT := nFONTHIGHT
nTOP := (nBMPHIGHT - nNEWHIGHT) / 2
aRect := GETCLIENTRECT( oBmp:hWnd )
nGRADIENT := Gradient( hDC, aRect, nVColor, nBColor, .T. ) // .T. Horizontal
oBmp:oBrush := TBrush():New( , nGRADIENT )
SetTextColor( hDC,nColor)
SetBkMode( oBmp:hDC, 0 )
FillRect( hDC, aRect, oBmp:oBrush:hBrush )
TextOut( hDC, nTOP, nLEFT, cText )
SelectObject( hDC, hOldFont )
// A simple border
// --------------------
IF nPEN > 0
DRAWBOX( aRect, hDC, nColor, nBMPLONG, nBMPHIGHT, B_PEN )
ENDIF
// Alphablended underline-bmp
// -------------------------------------
DEFINE BITMAP oBmp2 FILENAME "Underline.bmp"
// We have to get the DC from the dialog.
// Then we have to paint the underline-bmp in relation to
// the < dialog-info-BMP-position >
// The position of the BMP-resource comes from
// TControl oBmp:nTop and oBmp:nLeft
// now we can calculate the needed position for the
// underline-BMP
The needed dimensions from TControl :
The Top- and Left-position of a resource inside of a dialog
Code: Select all
nBlendTop := oBmp:nTop + nBMPHIGHT + 10
nBlendLeft := oBmp:nLeft - 10
// 10 = Distance between bottom of BMP and Top of Underline-BMP
// and left position of Underline-BMP
// we still have to adjust the length and hight of the underline
// for that we need a Right and Bottom for < ABPaint >
ABPaint( oDlg1:GetDC(), Left, Top, Right, Bottom, oBmp2:hBitmap, 255 )
// 0-255 transparency level
// The new Bottom and Right are needed for adjustment to Dialog-Info
//-------------------------------------------------------------------------------
RETURN NIL
Best Regards
Uwe