Hello JC,
Like Antonio told you : You have to use ONPAINT, to solve your problem.
Here is just a quick sample, how i use text-writing on BMP's from Resource on any places.
The BMP-resource is filled with a brush or color, then a text is painted.
I use it for my Title-paintings.
Maybe you can find some informations on it.
The resource < Blanc > is a small BMP inside the resource, used as container. ID 100 is your BMP with the original size.
POSLEFT defines the needed left-position of the text.
The top-position of the text is calculated from the font- and BMP-height,
to center the text vertical.
- Code: Select all Expand view
REDEFINE BITMAP oBmp1 ID 100 ADJUST RESOURCE "Blanc" OF oDlg1
oBmp1:bPainted := { |hDC|OnPaint( oDlg1,hDC,oBMP1, "Your Text", oFont, POSLEFT ) }
//----------------------------------------------------------------//
FUNCTION ONPAINT(oDlg1,hDC,oBmp,cText, oBFont,nPOSLEFT )
LOCAL hOldFont, oNewbrush, hBitmap, aRect, nTOP, nLEFT
hOldFont := SelectObject( hDC, oBFont:hFont )
// find the text-length
nTXTLG := GettextWidth( hDC, cText )
nBMPLONG := oBmp:Super:nWidth()
nBMPHIGHT := oBmp:Super:nHeight()
nFONTHIGHT := oBfont:nInpHeight * -1
// The text-pos is calculated
nLEFT := 5
IF nPOSLEFT = 0
// Center-position in BMP if POSLEFT = 0
nLEFT := (nBMPLONG - nTXTLG) / 2
ELSE
// defined left-position
nLEFT := nPOSLEFT
ENDIF
nNEWHIGHT := nFONTHIGHT
// Text-top-position is calculated.
nTOP := (nBMPHIGHT - nNEWHIGHT) / 2
aRect := GETCLIENTRECT( oBmp:hWnd )
oBmp:oBrush := oNewbrush
SetTextColor( hDC,nColor)
SetBkMode( oBmp:hDC, 0 )
// Fills your BMP with a brush
FillRect( hDC, aRect, oBmp:oBrush:hBrush )
IF nPOSLEFT > 0
TextOut( hDC, nTOP, nLEFT, cText )
ELSE
TextOut( hDC, nTOP, nLEFT, cText )
ENDIF
SelectObject( hDC, hOldFont )
RETURN NIL
Regards
Uwe