FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour bmptxt
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
bmptxt
Posted: Mon Jan 21, 2008 05:55 PM
Pl try this code which works
Later on please make any other changes
#include "FiveWin.ch"

#define TRANSPARENT 1

static oWnd

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

function Main()

   local oBmp
   local oFntGross

    DEFINE FONT oFntGross NAME "VERDANA" SIZE 0,-20 BOLD

   DEFINE WINDOW oWnd TITLE "Text on a bitmap"

   @ 1, 1 BITMAP oBmp FILENAME "..\bitmaps\fw.bmp" OF oWnd

   oBmp:bPainted  := { |hDC| OnPaint( hDC, "BOLD TEXT", oFntGross ) }

   ACTIVATE WINDOW oWnd

return nil

//----------------------------------------------------------------//
static function OnPaint( hDC, cMsg, oFont )

   local hOldFont

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

return nil
Regards



G. N. Rao.

Hyderabad, India
Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
bmptxt
Posted: Mon Jan 21, 2008 06:00 PM

Perfect. Many thanks.
best regards,
Otto

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
bmptxt
Posted: Mon Jan 21, 2008 06:08 PM

Good.
Now about your code. ChooseFont returns array but not a font object.
That was the reason for your error.

Regards



G. N. Rao.

Hyderabad, India
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
bmptxt
Posted: Mon Jan 21, 2008 06:41 PM
Otto wrote:Enrico,
I tried your suggestion but this does not work.


Sorry, I'm working too much...

Anyway, I've seen you already solved the problem.

EMG
Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
bmptxt
Posted: Mon Jan 21, 2008 07:05 PM

Using NageswaraRao's code and parts of yours from
" Saving and restoring a font. By Enrico Maria Giordano"
I put together a sample:

www.fwcodesnips.com

Thank you for your help,
Otto

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
bmptxt
Posted: Mon Jan 21, 2008 07:27 PM

Mr Otto

Nice. If you keep including interesting code from these forums on your site, it becomes easy for us to search when we want.

By the way you need to add some error checking in your code. The program fails when BuildFont function returns NIL.

Regards



G. N. Rao.

Hyderabad, India

Continue the discussion