printing words in bold in HMG print system

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
Paramvir
Posts: 44
Joined: Sun Mar 27, 2016 9:46 am
Location: India
Has thanked: 15 times
Been thanked: 4 times
Contact:

printing words in bold in HMG print system

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

User avatar
Rathinagiri
Posts: 5317
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Has thanked: 196 times
Been thanked: 210 times
Contact:

Post by Rathinagiri »

If you want to print part of the text to be bold, we have to split the text and print separately.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.

User avatar
Rathinagiri
Posts: 5317
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Has thanked: 196 times
Been thanked: 210 times
Contact:

Post by Rathinagiri »

Another way of doing this:

We can create HTML file and print.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.

Paramvir
Posts: 44
Joined: Sun Mar 27, 2016 9:46 am
Location: India
Has thanked: 15 times
Been thanked: 4 times
Contact:

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

User avatar
serge_girard
Posts: 2562
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Has thanked: 852 times
Been thanked: 160 times
Contact:

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

User avatar
gfilatov
Posts: 760
Joined: Fri Aug 01, 2008 5:42 am
Location: Ukraine
Has thanked: 30 times
Been thanked: 400 times
Contact:

Post 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 1119 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 :?:
Kind Regards,
Grigory Filatov

"Everything should be made as simple as possible, but no simpler." Albert Einstein

User avatar
srvet_claudio
Posts: 2105
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Has thanked: 47 times
Been thanked: 216 times
Contact:

Post by srvet_claudio »

Hi,
maybe with RichEdit
see: C:\hmg.3.4.4\SAMPLES\Controls\RichEditBox
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com

User avatar
mustafa
Posts: 1002
Joined: Fri Mar 20, 2009 11:38 am
DBs Used: DBF
Location: Alicante - Spain
Been thanked: 201 times
Contact:

Post 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

Post Reply