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

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

Postby yunbg1 » Tue Apr 01, 2008 4:30 am

Hi All

Why the execution is not.

Code: Select all  Expand view  RUN


#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
yunbg1
 
Posts: 107
Joined: Sun Nov 13, 2005 12:40 am
Location: Winnipeg Canada

Postby Antonio Linares » Tue Apr 01, 2008 8:29 am

Again you have to do it the same way :-)
Code: Select all  Expand view  RUN
#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
User avatar
Antonio Linares
Site Admin
 
Posts: 42122
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby yunbg1 » Tue Apr 01, 2008 10:00 am

Hi Antonio Linares

The agony is solved and truth it is grateful

Thank you.
FWH User
FWPPC User
FWLinux User
yunbg1
 
Posts: 107
Joined: Sun Nov 13, 2005 12:40 am
Location: Winnipeg Canada

Textout

Postby ukoenig » Wed Apr 02, 2008 10:41 am

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


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: dutch, Otto and 60 guests