Help for extextout

Help for extextout

Postby Silvio.Falconi » Thu Jun 05, 2014 1: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 November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 7070
Joined: Thu Oct 18, 2012 7:17 pm

Re: Help for extextout

Postby Rick Lipkin » Thu Jun 05, 2014 7: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: Select all  Expand view  RUN


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  Expand view  RUN

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


Code: Select all  Expand view  RUN

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

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

Return(nil)
 
User avatar
Rick Lipkin
 
Posts: 2666
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Help for extextout

Postby Silvio.Falconi » Fri Jun 06, 2014 7: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 ...

Image
Last edited by Silvio.Falconi on Fri Jun 06, 2014 7:31 am, edited 1 time in total.
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 7070
Joined: Thu Oct 18, 2012 7:17 pm

Re: Help for extextout

Postby ukoenig » Fri Jun 06, 2014 7: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.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: Help for extextout

Postby Silvio.Falconi » Fri Jun 06, 2014 7:33 am

thanks
if nPenColor is a gradient ?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 7070
Joined: Thu Oct 18, 2012 7:17 pm

Re: Help for extextout

Postby Silvio.Falconi » Fri Jun 06, 2014 7: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 November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 7070
Joined: Thu Oct 18, 2012 7:17 pm

Re: Help for extextout

Postby ukoenig » 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

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  Expand view  RUN

...
...
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  Expand view  RUN

#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:
Last edited by ukoenig on Fri Nov 20, 2020 2:12 pm, edited 8 times in total.
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.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: Help for extextout

Postby Antonio Linares » Fri Jun 06, 2014 5: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42120
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Help for extextout

Postby karinha » Thu Nov 19, 2020 3:31 pm

Very gooooood!
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7832
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 28 guests