bmptxt

User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Post by nageswaragunupudi »

Pl try this code which works
Later on please make any other changes

Code: Select all

#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
User avatar
Otto
Posts: 4470
Joined: Fri Oct 07, 2005 7:07 pm
Contact:

Post by Otto »

Perfect. Many thanks.
best regards,
Otto
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Post by nageswaragunupudi »

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
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Post by Enrico Maria Giordano »

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
User avatar
Otto
Posts: 4470
Joined: Fri Oct 07, 2005 7:07 pm
Contact:

Post by Otto »

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
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Post by nageswaragunupudi »

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