Page 1 of 1

Method SetText() Transparent

Posted: Sun Sep 21, 2008 10:13 pm
by Dorneles
http://img179.imageshack.us/my.php?image=tela1oc3.png

Changed the METHOD SetText( cText ) not to exceeding the limit as shown in Image 1, only that he lost his transparency, lack what?

Code: Select all

METHOD SetText( cText ) CLASS TSSay

   local hDC , nWidth

   DEFAULT ::lTransparent := .f.

   ::cCaption := If( ::cPicture != nil,;
         		     Transform( cText, ::cPicture ),;
                    cValToChar( cText ) )
                     
   if ! lAnd( GetWindowLong( ::hWnd, GWL_STYLE ), nOr( SS_LEFT, SS_RIGHT, SS_CENTER ) ) 
      nWidth = GetTextWidth( 0, ::cCaption, If( ::oFont != nil, ::oFont:hFont,) )  
      IF nWidth > ::nWidth 
         nWidth = GetTextWidth( 0, ::cCaption, If( ::oFont != nil, ::oFont:hFont,) ) -(GetTextWidth( 0, ::cCaption, If( ::oFont != nil, ::oFont:hFont,) ) - ::nWidth) 
      ENDIF
      if nWidth > ::nWidth 
         ::nWidth = nWidth 
      endif    
   endif   
   
   SetWindowText( ::hWnd, ::cCaption )

return nil

Posted: Wed Sep 24, 2008 1:29 am
by Dorneles
The image 2 this with the gray background, I make it transparent.

Posted: Wed Sep 24, 2008 12:05 pm
by Silvio
Dear Dorneles,

STATIC FUNCTION DrawText2( hDC, hFont, nBkMode, cText, nTop, nLeft, nWidth, nHeight )
LOCAL hFontOld:= SelectObject( hDC, hFont )
LOCAL nBkOld := SetBkMode( hDC, nBkMode )
DrawText( hDC, cText, { nTop, nLeft, nTop+nWidth, nLeft+nHeight } )
SelectObject( hDC, hFontOld )
SetBkMode( hDC, nBkOld )
RETURN( NIL )


it write trasparent on bitmap