Page 1 of 1

Help for extextout

Posted: Thu Jun 05, 2014 1:28 pm
by Silvio.Falconi
I have a procedure use extexout function to show a text into a dialog
how I can converte the text on transparent with this extextout function ?

Re: Help for extextout

Posted: Thu Jun 05, 2014 7:50 pm
by Rick Lipkin
Silvo

I use Global SetDlgGradient() function which tells all your Dialogs to use the Transparent clause and then I use .rc to create a text field to be displayed on the form .. then a Redefine SAY with any PROMPT value I wish and you can embellish the font and use color if you like .. in this case I use a Bold Font and color the text with Blue.

Rick Lipkin

Code: Select all


cSay1 := "Available Balance" // or use your extexout function
REDEFINE SAY oSay1 PROMPT cSay1 ID 134 of oDlg UPDATE   
             oSay1:SetFont( oFontB )
             oSay1:SetColor(nRgb(7,7,224)) // blue
 

Code: Select all

// from .rc
CONTROL "Available PrePay", 134, "STATIC", SS_NOPREFIX | WS_GROUP, 151, 286, 55, 26
 

Code: Select all

//--------------
Func LightGreyGrad()

SetDlgGradient( { { .50, nRGB( 216, 216, 216 ), nRGB( 255, 255, 255 ) } } )

Return(nil)
 

Re: Help for extextout

Posted: Fri Jun 06, 2014 7:16 am
by Silvio.Falconi
Sorry,

I use this command :

hOldFnt := SelectObject( hDc, oFont:hFont )

ExtTextOut( hDc, nLinea, 22, {nLinea,22,nLinea+16,22+nwidth}, aText[nCont,1] )


I not remeber but exit a selectobject command to make trasparent ...


I'm trying to create a class to simulate for read a book ...

Image

Re: Help for extextout

Posted: Fri Jun 06, 2014 7:19 am
by ukoenig
Silvio,
after this line :

hOldFnt := SelectObject( hDc, oFont:hFont )

SetBkMode( hDC, 1 )
SetTextColor( hDC, nPenColor ) // Textcolor
...
...
...
DeleteObject( hOldFnt )


Best regards
Uwe :?:

Re: Help for extextout

Posted: Fri Jun 06, 2014 7:33 am
by Silvio.Falconi
thanks
if nPenColor is a gradient ?

Re: Help for extextout

Posted: Fri Jun 06, 2014 7:34 am
by Silvio.Falconi
I tried but it modify the text color not the back

Re: Help for extextout

Posted: Fri Jun 06, 2014 11:20 am
by ukoenig
Silvio,

added both TEXTOUT and EXTEXTOUT on a mainwindow for a test.
It works perpect, no problems.
It is tested on the mainwindow, I still have to look using a dialog.
I think there will be no difference.

The screenshots, testing using different backgrounds
it is a LEFT MOUSECLICK-solution, to define the positin on screen

1. image-background shows a JPG ( merged alphachannel ) and a alphablended BMP with transparent-areas

Image

2. Brush-background

Image

3. gradient-background

Image

4. color-background

Image

The lines 4 - 11 are using < TEXTOUT > and < EXTEXTOUT >, showing the usage ( don't forget < 0 > !!! )
ExtTextOut( hDC, aPoints[1][1] - 80, aPoints[1][2] + 300, { 50, 50, 100, 200}, "ExTextout", 0 )
TextOut( hDC, aPoints[1][1] - 30, aPoints[1][2] + 300, "Textout" )

Code: Select all

...
...
oWndMain:bLClicked  := { | x, y |aPoints[1][1] := x, aPoints[1][2] := y, ;
          IIF( cDrawStyle = "Transp.-Logo", DRAW_TLOGO(oWndMain), NIL ), // selected from combobox ;
          IIF( cDrawStyle = "Image-Logo", DRAW_ILOGO(oWndMain), NIL ), ;
          IIF( cDrawStyle = "Alpha-Logo", DRAW_ALOGO(oWndMain), NIL ) ) }

oWndMain:bRClicked  := { || oWndMain:Refresh() } // clears the window
...
...


// ----------- Transp.-Logo ----------------------

STATIC FUNCTION DRAW_TLOGO(oWndMain)
LOCAL oImg0, nLWidth, nLHeight
LOCAL hDC := oWndMain:GETDC()
LOCAL hOldFont := SelectObject( hDC, oFont3:hFont )

SetBkMode( hDC, 1 ) 
SetTextColor( hDC, nDTxtColor ) 
// don't forget to add < 0 > at the end !!!
ExtTextOut( hDC, aPoints[1][1] - 80, aPoints[1][2] + 300, { 50, 50, 100, 200}, "ExTextout", 0 ) 
TextOut( hDC, aPoints[1][1] - 30, aPoints[1][2] + 300, "Textout" )
SelectObject ( hDC, hOldFont )

IF FILE ( cImagepath + ALLTRIM(cTLogo) )
     DEFINE IMAGE oImg0 FILENAME cImagepath + ALLTRIM(cTLogo)
     nLWidth := oImg0:nWidth *  ( nLIResize / 100 )
     nLHeight := oImg0:nHeight * ( nLIResize / 100 )
     oImg0:End()
     COPYFILE( cImagepath + ALLTRIM(cTLogo), c_path1 + "TEMP1." + cExtension )
     oImg0 := FILoadImg( cImagepath + cTLogo )
     oDrawImg := ResizeImg( oImg0, nLWidth, nLHeight )
     ABPaint( hDC, aPoints[1][2], aPoints[1][1], oDrawImg, nTrLevel )
ELSE
     MsgAlert( "File : " + ALLTRIM(cTLogo) + CRLF + ;
          "does not exist" + CRLF + ; 
          "to show Image !", "ERROR" ) 
ENDIF
oWndMain:ReleaseDC()

RETURN( NIL )
 
A ready to use dialog-sample, the text-position is defined with a left mouseclick.
A right mouseclick clears the dialog :

Image

Code: Select all

#include "Fivewin.ch"

FUNCTION MAIN()
LOCAL oTxtDlg, oBtn1, oFont
LOCAL nDColorF := 16443068, nDColorB := 10899511
LOCAL nDGradpos := 0.9, LDDirect := .T.
LOCAL nDTxtColor := 8454143

DEFINE FONT oFont NAME "Arial" SIZE 0, -36 BOLD

DEFINE DIALOG oTxtDlg SIZE 500, 500 TITLE "testing TEXTOUT and EXTEXTOUT"

oTxtDlg:bLClicked  := { | x, y | DRAW_TOUT(oTxtDlg, x, y, oFont, nDTxtColor) }
oTxtDlg:bRClicked  := { || oTxtDlg:Refresh() }

@ 220, 180 BTNBMP oBtn1 OF oTxtDlg ; 
SIZE 50, 25 PIXEL 2007 ; // B / H
NOBORDER ;
PROMPT "&Exit" ;
FILENAME c_path1 + "Exit.Bmp" ;
ACTION oTxtDlg:End() ;
FONT oFont1  ;
LEFT
oBtn1:lTransparent := .t.   
oBtn1:cToolTip =  { "Exit" + CRLF + "Test","EXIT", 1, CLR_BLACK, 14089979 }
oBtn1:SetColor( 0, )

ACTIVATE DIALOG oTxtDlg CENTERED ;
ON INIT  SET_GRAD( oTxtDlg, oTxtDlg:nWidth, oTxtDlg:nHeight, ;
                                         nDColorF, nDColorB, nDGradpos, LDDirect ) 

oFont:End()

RETURN( NIL )

// ----------- TEXTOUT ----------------------

STATIC FUNCTION DRAW_TOUT(oTxtDlg, x, y, oFont, nDTxtColor)
LOCAL hDC := oTxtDlg:GETDC()
LOCAL hOldFont := SelectObject( hDC, oFont:hFont )

SetBkMode( hDC, 1 ) 
SetTextColor( hDC, nDTxtColor ) 
ExtTextOut( hDC, x, y, { 50, 50, 100, 200}, "ExTextout", 0 )
TextOut( hDC, x + 50, y, "Textout" )
SelectObject ( hDC, hOldFont )

oTxtDlg:ReleaseDC()

RETURN( NIL )

// --------  DIALOG - Background ---------------

FUNCTION SET_GRAD( oWnd, nWidth, nHeight, nDColorF, nDColorB, nDGradpos, LDDirect )
Local hDC, oBrush, aGrad

aGrad := { { nDGradpos, nDColorF, nDColorB }, { nDGradpos, nDColorB, nDColorF } }
hDC = CREATECOMPATIBLEDC( oWnd:GetDC() )
hBmp = CREATECOMPATIBLEBITMAP( oWnd:hDC, nWidth, nHeight )
hBmpOld = SELECTOBJECT( hDC, hBmp )
GRADIENTFILL( hDC, 0, 0, nHeight, nWidth, aGrad )
oBrush = TBrush():New( ,,,, hBmp )
oWnd:SetBrush( oBrush )
AEVAL( oWnd:aControls, { | oCtl | IF( oCtl:lTransparent, oCtl:SetBrush( oWnd:oBrush ), ) } )
SELECTOBJECT( hDC, hBmpOld )
DELETEDC( hDC )
oWnd:ReleaseDC()

oWnd:SetBrush( oBrush )
RELEASE BRUSH oBrush 

RETURN( NIL )
 
best regards
Uwe :lol:

Re: Help for extextout

Posted: Fri Jun 06, 2014 5:26 pm
by Antonio Linares
Dear Uwe,

The quality of the tech support that you provide to all of us is simply outstanding! :-)

What a team of great masters we have here ;-)

thank you so much

Re: Help for extextout

Posted: Thu Nov 19, 2020 3:31 pm
by karinha
Very gooooood!