How can i use the (BITMAP TextOut( hDC, 5, 5, cMsg )) ?

Post Reply
yunbg1
Posts: 107
Joined: Sun Nov 13, 2005 12:40 am
Location: Winnipeg Canada

How can i use the (BITMAP TextOut( hDC, 5, 5, cMsg )) ?

Post by yunbg1 »

Hi All

Why the execution is not.

Code: Select all

 

#include "FiveWin.ch" 

#define CR chr(13) 

Function main() 

publ oWnd, oField := array(250), count := 1 , oFont 

DEFINE FONT oFont NAME GetSysFont() SIZE 0, -8 

DEFINE WINDOW oWnd 

   for i  := 1 to 50 
       for j := 1 to 5 

          @ (i*26), (j*75)  BITMAP oField[count] FILENAME "test.bmp" NOBORDER  SIZE 70, 24 OF oWnd ADJUST PIXEL 

           oField[count]:bPainted  := { |hDC| OnPaint( hDC, str(count, 3), oFont ) ) } 

           oField[count]:bLClicked := GenBlock(count) 

           count += 1 
      next 
   next 

ACTIVATE WINDOW oWnd 

oFont:End() 

return nil 

//------------------------------------------------ 
func GenBlock( n ) 
RETU { || test_button( n ) } 

//------------------------------------------------ 
FUNC OnPaint( hDC, cMsg, oFont ) 

local hOldFont 

hOldFont := SelectObject( hDC, oFont:hFont ) 
SetBkMode( hDC, TRANSPARENT ) 
TextOut( hDC, 5, 5, cMsg ) 
SelectObject( hDC, hOldFont ) 

RETU NILl 

//------------------------------------------------ 
FUNC test_button(n) 

msginfo(n) 

RETU NIL 

FWH User
FWPPC User
FWLinux User
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Again you have to do it the same way :-)

Code: Select all

#include "FiveWin.ch" 

#define CR chr(13) 

Function main() 

publ oWnd, oField := array(250), count := 1 , oFont 

DEFINE FONT oFont NAME GetSysFont() SIZE 0, -8 

DEFINE WINDOW oWnd 

   for i  := 1 to 50 
       for j := 1 to 5 

          @ (i*26), (j*75)  BITMAP oField[count] FILENAME "test.bmp" NOBORDER  SIZE 70, 24 OF oWnd ADJUST PIXEL 

           oField[count]:bPainted  := GenPaint( count, oFont )

           oField[count]:bLClicked := GenBlock(count) 

           count += 1 
      next 
   next 

ACTIVATE WINDOW oWnd 

oFont:End() 

return nil 

//------------------------------------------------ 

function Genpaint( n, oFont )

return { |hDC| OnPaint( hDC, str( n, 3), oFont ) } 
	
//------------------------------------------------ 

func GenBlock( n ) 

RETU { || test_button( n ) } 

//------------------------------------------------ 

#define TRANSPARENT 1

FUNC OnPaint( hDC, cMsg, oFont ) 

local hOldFont 

hOldFont := SelectObject( hDC, oFont:hFont ) 
SetBkMode( hDC, TRANSPARENT ) 
TextOut( hDC, 5, 5, cMsg ) 
SelectObject( hDC, hOldFont ) 

RETU NIL 

//------------------------------------------------ 
FUNC test_button(n) 

msginfo(n) 

RETU NIL 
Image
regards, saludos

Antonio Linares
www.fivetechsoft.com
yunbg1
Posts: 107
Joined: Sun Nov 13, 2005 12:40 am
Location: Winnipeg Canada

Post by yunbg1 »

Hi Antonio Linares

The agony is solved and truth it is grateful

Thank you.
FWH User
FWPPC User
FWLinux User
User avatar
ukoenig
Posts: 3981
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany
Contact:

Textout

Post by ukoenig »

Hello,

TextOut( hDC, 5, 5, cMsg )

Is it possible, to center the text in relation to the
Bitmap-hight and font-size ?

5, 5 is a fixed position.

In the Bitmap-class there is oBmp:nHeight
// It returns the Bitmap-Height in Pixel

When a Font is defined, as a sample TFont:New("Arial", , -20, .F.,.T.)
I use => oFont:nlnpHeight * -1 from the font-class
and get 20 of the font-height.
But this is not the font-pixel-height.

with => ( oBmp:nHeight - < Fontpixelheight > ) / 2
i get the text centered vertical.

I still need the length of a written text in pixel of a defined font,
to make a text centered horizontal, inside of a bitmap.
I don't know, how to calculate this.

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.
Post Reply