TEXTOUT() function cannot use some predefined fonts?

TEXTOUT() function cannot use some predefined fonts?

Postby codemaker » Mon Oct 07, 2013 3:29 pm

I have a situation where the dialog is covered by the BMP and from then on I am writting on this BMP practically when I want some text on it.
The activation code looks like this:
Code: Select all  Expand view

ACTIVATE DIALOG oDlgMain CENTERED ;
    ON PAINT ( DrawBitmap( oDlgmain:hDC, oBmp2, 0, 0, 0,0,SRCAND ),;    // Draws a bitmap on dialog
                         SetBkMode( oDlgMain:hDC, 1 ),;                   // writting mode TRANSPARENT
                        SetTextColor( oDlgMain:hDC, CLR_RED),;       // Color of written tect
                        TEXTOUT(oDlgMain:hDC,20,40,"YEAR 20"+WebYear,50) )   // The text
 


Before that I define the dialog like this:
Code: Select all  Expand view

DEFINE FONT oMainFont NAME "ARIAL" SIZE 0,30 BOLD   //24 BOLD
DEFINE DIALOG oDlgMain FROM 0,0 TO 608,808 PIXEL STYLE WS_POPUP FONT oMainFont 
 


What happens is that the function TEXTOUT() uses some font other than I want - oMainFont.
Is there a way I can force this function to use the desired font? I thought when I defined dialog with a font "oMainFont" everything on this dialog will be written in that font. All controls on this dialog uses the desired font, but the TEXTOUT() doesn't.
Is there I way to force the "oMainFont" to be used by TEXTOUT() function?
User avatar
codemaker
 
Posts: 208
Joined: Wed Dec 03, 2008 4:48 pm
Location: Belgrade, Serbia

Re: TEXTOUT() function cannot use some predefined fonts?

Postby MaxP » Mon Oct 07, 2013 4:07 pm

You can try this

Code: Select all  Expand view

CTIVATE DIALOG oDlgMain CENTERED ;
    ON PAINT ( DrawBitmap( oDlgmain:hDC, oBmp2, 0, 0, 0,0,SRCAND ),;    // Draws a bitmap on dialog
                         SetBkMode( oDlgMain:hDC, 1 ),;                   // writting mode TRANSPARENT
                        SetTextColor( oDlgMain:hDC, CLR_RED),;       // Color of written tect                        
                        SelectObject( oDlgMain:hDC, oMainFont :hFont )
                        TEXTOUT(oDlgMain:hDC,20,40,"YEAR 20"+WebYear,50) )   // The text
 


Best Regards
User avatar
MaxP
 
Posts: 84
Joined: Thu Jul 12, 2007 2:02 pm

Re: TEXTOUT() function cannot use some predefined fonts?

Postby MaxP » Mon Oct 07, 2013 4:13 pm

I stand corrected

Code: Select all  Expand view

ACTIVATE DIALOG oDlgMain CENTERED ;
    ON PAINT ( DrawBitmap( oDlgmain:hDC, oBmp2, 0, 0, 0,0,SRCAND ),;    // Draws a bitmap on dialog
                         SetBkMode( oDlgMain:hDC, 1 ),;                   // writting mode TRANSPARENT
                        SetTextColor( oDlgMain:hDC, CLR_RED),;       // Color of written tect                        
                        SelectObject( oDlgMain:hDC, oMainFont:hFont ), ;   // Set current font
                        TEXTOUT(oDlgMain:hDC,20,40,"YEAR 20"+WebYear,50) )   // The text
 


Best Regards
User avatar
MaxP
 
Posts: 84
Joined: Thu Jul 12, 2007 2:02 pm

Re: TEXTOUT() function cannot use some predefined fonts?

Postby codemaker » Mon Oct 07, 2013 4:23 pm

Thank you MaxP
It works perfect!
User avatar
codemaker
 
Posts: 208
Joined: Wed Dec 03, 2008 4:48 pm
Location: Belgrade, Serbia

Re: TEXTOUT() function cannot use some predefined fonts?

Postby codemaker » Mon Oct 07, 2013 4:37 pm

Ok, now I have another quuestion:

If I use TEXTOUT() to write some text and is transparent, how can I erase this text and write another text on the same position?
If I just write another text over the g, it will write over the previous one and I will end up with garbage on the screen?

Is there a way to erase the first text and write another at the same position? Something like XOR in some languages which erases the text if I repeat the same text again.
User avatar
codemaker
 
Posts: 208
Joined: Wed Dec 03, 2008 4:48 pm
Location: Belgrade, Serbia

Re: TEXTOUT() function cannot use some predefined fonts?

Postby Antonio Linares » Mon Oct 07, 2013 5:25 pm

Boris,

before calling TextOut() you may call SetBkMode( oDlgMain:hDC, 1 ) // 1 stands for TRANSPARENT

http://msdn.microsoft.com/en-us/library/windows/desktop/dd162965(v=vs.85).aspx

Also, it is a very good practice to save and restore the GDI objects that we select, i.e.:

hOldFOnt := SelectObject( oDlgMain:hDC, oMainFont:hFont )
...
SelectObject( oDlgMain:hDC, hOldFont )
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41318
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: TEXTOUT() function cannot use some predefined fonts?

Postby codemaker » Thu Oct 10, 2013 10:16 pm

Thanks Antonio.
But I am afraid I do not understand how can I do the following:

1. Have a bitmap on dialog. - This I can do
2. Write some TRANSPARENT text on some position - This I can do also
- What I cannot do:
3. Write another TRANSPARENT text on the same position (over the previous) but not having TWO texts visible! The old text should be erased somehow.

For example I am building some setup program. User selects the disk where the setup will copy the files.
When user selects one disk, the text will show the amount of space
When user selects another disk, the text should show another number, the amount of free space of this new disk
I need to erase the previous amount before I write new disk space amount.
User avatar
codemaker
 
Posts: 208
Joined: Wed Dec 03, 2008 4:48 pm
Location: Belgrade, Serbia

Re: TEXTOUT() function cannot use some predefined fonts?

Postby ukoenig » Fri Oct 11, 2013 12:05 pm

I think, a better solution would be, using TTitle.
There You have many design-/style-options like :
3D-text, optional border, textcolor or brush, text-shadow,
a optional extra info-image animated with action, textstyle-change at runtime ...
I can complete the sample, if You like it.

changing values and different text-styles at runtime :

Image

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: TEXTOUT() function cannot use some predefined fonts?

Postby codemaker » Fri Oct 11, 2013 7:48 pm

Yes Uwe, I would appreciate some sample very much...
I never used TTitle, to be honest, I was not even aware it exists.

Thanks in advance for some small sample, I don't want to take too much of your time.

Boris
User avatar
codemaker
 
Posts: 208
Joined: Wed Dec 03, 2008 4:48 pm
Location: Belgrade, Serbia

Re: TEXTOUT() function cannot use some predefined fonts?

Postby ukoenig » Fri Oct 11, 2013 8:24 pm

Boris,
does Your used FWH-release include TTitle ?
If Yes, In the meantime You can have a look at : \samples\Testtitl.prg
Maybe You like the first TRANSPARENT BASE sample with border and 3D-text.
My extended version :

Image

Class TTitle added :

April 2010
==========

* New: Class TTitleText to use in class TTITLE, create an object with the properties of the text added to TTITLE
* New: Class TTitleImg to use in class TTITLE, create an object with properties of the image added to TTITLE

displaying the text, class TTitle uses :

TextOut( ::hDC,;
nRow + nRowSha, ;
nCol + nColSha, ;
::aText[ n, TI_TEXT ], ;
Len( ::aText[ n, TI_TEXT ] ) )

Best Regards
Uwe :lol:
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: TEXTOUT() function cannot use some predefined fonts?

Postby Antonio Linares » Sat Oct 12, 2013 8:13 am

Boris,

If you have a bitmap and paint a text of top of it, in order to erase the text and paint another one, simply refresh the bitmap:

oBmp:Refresh()
paint the new text on it
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41318
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: TEXTOUT() function cannot use some predefined fonts?

Postby codemaker » Sat Oct 12, 2013 9:16 pm

Brilliant ideas are always simple :)
But ... (always a but) my problem is that I have also some other elements drawn on this bitmap (get, combobox and other texts, so I need to redraw everything after I redraw a bitmap.... :(
It might cause some flickering.
Will give it a try anyway

@Uwe
Thanks Uwe, I will try tText class
Last edited by codemaker on Sat Oct 12, 2013 9:18 pm, edited 1 time in total.
User avatar
codemaker
 
Posts: 208
Joined: Wed Dec 03, 2008 4:48 pm
Location: Belgrade, Serbia

Re: TEXTOUT() function cannot use some predefined fonts?

Postby codemaker » Sat Oct 12, 2013 10:29 pm

Tried.
Works as expected. I can dynamically change the oTitle text when needed, just changing the content of "cString" variable and apply it to oTitle:

cString := "Some new string"
oTitle:aText[1][3] := cString
oTitle:Refresh()

Thanks to all
User avatar
codemaker
 
Posts: 208
Joined: Wed Dec 03, 2008 4:48 pm
Location: Belgrade, Serbia

Re: TEXTOUT() function cannot use some predefined fonts?

Postby ukoenig » Mon Oct 14, 2013 11:48 am

Boris,

with the titlepainter, it will be very easy,
to create any style with any combination of window and dialog You like.
Define dialog-size and title-position and size.
Create a standalone EXE-file of Your design.
With the different PAINTERS, You can define / create the Backgrounds and other settings :
( still some work to do )

Image

Change styles at runtime :

Image

Some results :

Image

Best Regards
Uwe :lol:
Last edited by ukoenig on Mon Oct 14, 2013 5:32 pm, edited 1 time 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: TEXTOUT() function cannot use some predefined fonts?

Postby codemaker » Mon Oct 14, 2013 12:07 pm

Uwe,

where can I find this TitlePainter?
User avatar
codemaker
 
Posts: 208
Joined: Wed Dec 03, 2008 4:48 pm
Location: Belgrade, Serbia

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Otto and 14 guests