FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Help for extextout
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Help for extextout
Posted: Thu Jun 05, 2014 01:28 PM

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 ?

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: Help for extextout
Posted: Thu Jun 05, 2014 07:50 PM
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 (fw): Select all Collapse
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 (fw): Select all Collapse
// from .rc
CONTROL "Available PrePay", 134, "STATIC", SS_NOPREFIX | WS_GROUP, 151, 286, 55, 26


Code (fw): Select all Collapse
//--------------
Func LightGreyGrad()

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

Return(nil)
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: Help for extextout
Posted: Fri Jun 06, 2014 07:16 AM
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 ...

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: Help for extextout
Posted: Fri Jun 06, 2014 07:19 AM
Silvio,
after this line :

hOldFnt := SelectObject( hDc, oFont:hFont )

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


Best regards
Uwe :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: Help for extextout
Posted: Fri Jun 06, 2014 07:33 AM

thanks
if nPenColor is a gradient ?

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: Help for extextout
Posted: Fri Jun 06, 2014 07:34 AM

I tried but it modify the text color not the back

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: Help for extextout
Posted: Fri Jun 06, 2014 11:20 AM
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



2. Brush-background



3. gradient-background



4. color-background



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 (fw): Select all Collapse
...
...
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 :



Code (fw): Select all Collapse
#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 :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Help for extextout
Posted: Fri Jun 06, 2014 05:26 PM

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

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: Help for extextout
Posted: Thu Nov 19, 2020 03:31 PM

Very gooooood!

João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341

Continue the discussion