Page 1 of 1

printing words in bold in HMG print system

Posted: Sun Aug 02, 2020 12:49 pm
by Paramvir
Hi,
When printing a line, I use this code to print a line in bold:

Code: Select all

@ nPrintRow, nPrintCol PRINT xLine ; 
TO nPrintRow, nEndOfLine ;
FONT cFontName SIZE hFontSize BOLD 
I am not sure what method I should use to print a few words in bold within a line. Any help will be appreciated.
Thank you all.

Re: printing words in bold in HMG print system

Posted: Sun Aug 02, 2020 7:57 pm
by Rathinagiri
If you want to print part of the text to be bold, we have to split the text and print separately.

Re: printing words in bold in HMG print system

Posted: Sun Aug 02, 2020 7:58 pm
by Rathinagiri
Another way of doing this:

We can create HTML file and print.

Re: printing words in bold in HMG print system

Posted: Tue Aug 04, 2020 3:15 pm
by Paramvir
Rathinagiri wrote: Sun Aug 02, 2020 7:58 pm Another way of doing this:

We can create HTML file and print.
Thank you Rathi ji for the suggestion. In good old DOS days, it seemed easy by just inserting control characters before and after the desired words and you were ready to go. Thank you once again.

Re: printing words in bold in HMG print system

Posted: Tue Aug 04, 2020 3:28 pm
by serge_girard
inserting control characters before and after the desired words
Would be very handy to have this, a bit like CSS in our LABEL controls, like: <font style=color:red;><b> Desired words in red and bold</b></font>
Maybe the gurus know if it is possible?

Claudio?

Re: printing words in bold in HMG print system

Posted: Tue Aug 04, 2020 6:01 pm
by gfilatov
serge_girard wrote: Tue Aug 04, 2020 3:28 pm
inserting control characters before and after the desired words
Would be very handy to have this, a bit like CSS in our LABEL controls, like: <font style=color:red;><b> Desired words in red and bold</b></font>
Hi Serge,

There is the 'Colored Label' sample in the MiniguiEx distribution (see below).
demo.png
demo.png (37.43 KiB) Viewed 2839 times
Sample code:

Code: Select all

/*
 * MINIGUI - Harbour Win32 GUI library Demo
 *
 */

#include "minigui.ch"
#include "hbclass.ch"

////////////////////////////////////////////////////////////////////////////////
FUNCTION Main()

   LOCAL cTxt, aTxt, oLbl
   LOCAL h := 0, w := 0, s := 10
   LOCAL BColor := { 220, 220, 220 }
   LOCAL a, c, y, x
   LOCAL cFile := "test.txt"

   SET FONT TO "Arial", 12

   IF ! File( cFile )
      Create_txt( cFile )
   ENDIF

   cTxt := hb_MemoRead( cFile )
   c    := iif( CRLF $ cTxt, CRLF, Chr( 10 ) )
   aTxt := hb_ATokens( cTxt, c )

   DEFINE WINDOW _T ;
      AT 0, 0 WIDTH 100 HEIGHT 100 ;
      TITLE 'Colored Label Demo' ;
      MAIN ;
      BACKCOLOR BColor

   oLbl := cLbl():New( BColor )

   oLbl:Add( 'Harbour', BLUE )
   oLbl:Add( 'Project', GREEN, .T., .F., .T. )
   oLbl:Add( 'Free', BLUE )
   oLbl:Add( 'Software', GREEN, .T., .T., .T., 'Tooltip' )
   oLbl:Add( 'General', BLUE )
   oLbl:Add( 'Public', YELLOW, .T., .F., .T., 'Click me', .T., ;
      {|o| MsgInfo( 'Value: ' + _GetValue( _HMG_ThisControlName, _HMG_ThisFormName ), 'Class: ' + o:ClassName ) } )
   oLbl:Add( 'License', BLUE )
   oLbl:Add( 'exception', RED  )

   y := x := s

   FOR EACH cTxt IN aTxt
      IF ! Empty( cTxt )
         oLbl:Def( cTxt )
         a := oLbl:Out( y, x )
         y += a[ 1 ] + s
         h += a[ 1 ] + s
         w := Max( w, a[ 2 ] )
      ENDIF
   NEXT

   h += s * 2
   w += s * 2

   This.Width  := w + GetBorderWidth () * 2
   This.Height := h + GetBorderHeight() * 2 + GetTitleHeight()

   END WINDOW

   CENTER   WINDOW _T
   ACTIVATE WINDOW _T

RETURN NIL
The all magic is hidden in the custom class cLbl :idea:

May be it's useful :?:

Re: printing words in bold in HMG print system

Posted: Tue Aug 04, 2020 7:14 pm
by srvet_claudio
Hi,
maybe with RichEdit
see: C:\hmg.3.4.4\SAMPLES\Controls\RichEditBox

Re: printing words in bold in HMG print system

Posted: Wed Aug 05, 2020 10:00 am
by mustafa
Hello friends:

See if there can be any use?

https://www.alanit.com/category/programacion/

https://github.com/JoseluisSanchez/RichText

RichText-master.zip

In code "rtfdemo.prg" you must add #include "hmg.ch"

Code: Select all


    #include "hmg.ch"      //  <==  New  
    #include "hbclass.ch"
    #include "richtext.ch"

    PROCEDURE Main()
    RTFDemo()
   Return

    

Compile rtfdemo.hbp Result == >> RTFDEMO.RTF

Regards
Mustafa