How to use RichText font attributes

Post Reply
User avatar
reinaldocrespo
Posts: 918
Joined: Thu Nov 17, 2005 5:49 pm
Location: Fort Lauderdale, FL

How to use RichText font attributes

Post by reinaldocrespo »

Hello FiveWinners!

I've been asked by Silvio via email how to do superscript using richtext. I've been using this class for so long now I don't really remember what I changed if any from the original class. So here are my sources where you can clearly see how to perform many font attributes including superscript. I'm posting here in the off-chance that someone else is interested or eventually wants to expand my work:

Code: Select all

//Reinaldo Crespo
//reinaldo.crespo@gmail.com

#INCLUDE "fivewin.ch" 
#include "Inkey.ch"
#include "RichEdit.ch"

#define SSCE_OPTION 64
#define CFM_LINK                 32
#define CFM_ALLCAPS              128
#define CFM_HIDDEN               256
#define CFM_SUBSCRIPT            196608
#define CFM_SUPERSCRIPT          196608

#define CFE_LINK                 32
#define CFE_ALLCAPS              128
#define CFE_HIDDEN               256
#define CFE_SUBSCRIPT            65536
#define CFE_SUPERSCRIPT          131072


//#define CFE_SUBSCRIPT     0x00010000      // Superscript and subscript are 
//#define CFE_SUPERSCRIPT       0x00020000      //  mutually exclusive           
#define CFM_SMALLCAPS       0x0040          // (*)  
#define CFE_SMALLCAPS       CFM_SMALLCAPS

#define DC_CALL_STD     0X0020
#define RTF_VER         "PathLabs10"

STATIC hDLL 

*-------------------------------------------------------------------------------------------------------------------------------
CLASS MyRchEdt FROM TRichEdit

    DATA lBold      AS LOGICAL INIT .F. 
    DATA lItalic    AS LOGICAL INIT .F. 
    DATA lUnderline AS LOGICAL INIT .F. 
    DATA lNum       AS LOGICAL INIT .F.
    DATA lBul       AS LOGICAL INIT .F. 
    DATA lRE30      AS LOGICAL INIT REDllVersion() >= 30
    DATA lSuper     AS LOGICAL INIT .F. 
    DATA lSub       AS LOGICAL INIT .F. 
    DATA lSmallCaps AS LOGICAL INIT .F.
    DATA lUpper     AS LOGICAL INIT .F.
    
    DATA lChanged   AS LOGICAL INIT .F.

    Data odbf
    Data nPrintedPages AS NUMERIC INIT 0

    METHOD Init() CONSTRUCTOR
    METHOD KeyDown( nKey, nFlags )
    METHOD KeyChar( nKey, nFlags )

    METHOD HandleEvent( nMsg, nWParam, nLParam )

    METHOD LButtonDown( nRow, nCol, nFlags )
    METHOD PopMenu( nRow, nCol, nFlags )
    METHOD CanRedo() INLINE ::SendMsg( EM_CANREDO, 0, 0 ) != 0 .and. ! ::lReadOnly
    
   METHOD SetSuper( lOnOff )     INLINE ::SetAttribute2( ,.T.,,,,, lOnOff )
   METHOD SetSub( lOnOff )       INLINE ::SetAttribute2( ,,.T.,,,, lOnOff )
   METHOD SetUpperCaps( lOnOff ) INLINE ::SetAttribute2( .T.,,,,,,  lOnOff )
   METHOD SetSmallCaps( lOnOff ) INLINE ::SetAttribute2( ,,,,,.T., lOnOff )
   METHOD SetHangingIndent()
   //METHOD SelectAll()  INLINE ::SetSelection( 0, -1 )
   METHOD SelectNone() INLINE ::SetSel( -1, 0 )

   METHOD SetAttribute2( lSuper, lSub, lSmallCaps, lOnOff )

   METHOD IsRTF( cFile )
   METHOD InsertFile() 
   METHOD InsertPic()

END CLASS

*-------------------------------------------------------------------------------------------------------------------------------
METHOD Init CLASS MyRchEdt

   ::lhighlight := .F.
   ::nDlgCode = DLGC_WANTALLKEYS
    ::bRClicked := { |nRow, nCol, nFlags| ::PopMenu( nRow, nCol, nFlags ) }
   hDLL := oApp():hSSCEDLL
    
RETURN SELF

*-------------------------------------------------------------------------------------------------------------------------------
METHOD PopMenu( nRow, nCol, nFlags ) CLASS MyRchEdt
local oClp, oMenu

    DEFINE CLIPBOARD oClp OF Self FORMAT TEXT

    MENU oMenu POPUP
        MENUITEM "&Undo" ACTION ::UnDo() RESOURCE "UnDo16" WHEN ::CanUndo()
        MENUITEM "&Redo" ACTION ::ReDo() RESOURCE "ReDo16" WHEN ::CanRedo()

        SEPARATOR

        MENUITEM "Select &All" ACTION ::SelectAll() RESOURCE "SelAll"
        MENUITEM "Cu&t" ACTION ::Cut() RESOURCE "Cut16" WHEN ::CanCut()
        MENUITEM "&Copy" ACTION ::Copy() RESOURCE "Copy16" WHEN ::CanCopy()
        MENUITEM "&Paste" ACTION ::Paste() RESOURCE "Paste16" WHEN ::CanPaste()
        MENUITEM "&Delete" ACTION ::Del() RESOURCE "Delete16" WHEN ::CanDel()

        SEPARATOR

        MENUITEM "&Font..." ACTION ::SetCharFormat() RESOURCE "Font" WHEN !::lReadOnly
        MENUITEM "A&ling" WHEN !::lReadOnly
        
        MENU
            MENUITEM "&Left"   ACTION ::SetAlign( PFA_LEFT )   RESOURCE "Justify_Left16" WHEN !::lReadOnly
            MENUITEM "&Center" ACTION ::SetAlign( PFA_CENTER ) RESOURCE "Justify_Center16" WHEN !::lReadOnly
            MENUITEM "&Right"  ACTION ::SetAlign( PFA_RIGHT )  RESOURCE "Justify_Right16" WHEN !::lReadOnly
        ENDMENU

        SEPARATOR

        MENUITEM "P&rint" ACTION ::Print() RESOURCE "Printer16"

        SEPARATOR

   ENDMENU

   ACTIVATE POPUP oMenu AT nRow, nCol OF Self

return 0

*-------------------------------------------------------------------------------------------------------------------------------
METHOD KeyDown( nKey, nFlags ) CLASS MyRchEdt

//  logfile( "trace.log", { "Keydown", nKey } )
    ::PostMsg( FM_CHANGE ) //FM_HIGHLIGHT )
    
Return Super:KeyDown( nKey, nFlags )
    
*-------------------------------------------------------------------------------------------------------------------------------
METHOD KeyChar( nKey, nFlags ) CLASS MyRchEdt
local bCode

    if ::bkeyChar <> Nil .and. !::lreadOnly
        Eval( ::bkeyChar, nKey, nFlags )
    endif   

    if nKey == VK_TAB .or. ::lreadOnly
        return Nil
    endif

    if ( bCode := hb_SetKeyGet( K_CTRL_P ) ) != Nil     ;eval( bCode )  ;endif
    if ( bCode := hb_SetKeyGet( K_CTRL_F ) ) != Nil     ;eval( bCode )  ;endif
    if ( bCode := hb_SetKeyGet( K_CTRL_B ) ) != Nil     ;eval( bCode )  ;endif
    
    ::PostMsg( FM_CHANGE )
   ::lChanged := .T. 
    
    if ::lHighlight
        ::PostMsg( FM_HIGHLIGHT )
    endif

return super:KeyChar( nKey, nflags )

*-------------------------------------------------------------------------------------------------------------------------------
METHOD HandleEvent( nMsg, nWParam, nLParam ) CLASS MyRchEdt
local oapp := oApp()

    if nMsg == WM_KEYDOWN .and. nWParam == VK_TAB
        Return 0        //avoid processing the tab key by windows
    endif
    
    if nMsg == FM_CHANGE .and. oApp:hSSCEDLL != Nil
        SSCE_CheckCtrlBackgroundNotify( ::hWnd, SSCE_OPTION, RGB(254, 1, 1) )
    endif

    if nMsg == WM_KEYDOWN .and. ;
        (   nWParam == 38 .or. ;//K_UP arrow
            nWParam == 40 .or. ;//DOWN arrow
            nWParam == 37 .or. ;//LEFT arrow
            nWParam == 39 .or. ;//RIGHT arrow
            nWParam == 35 .or. ;//END
            nWParam == 36 ) //HOME
            
        ::PostMsg( FM_CHANGE )
        IF oApp:hSSCEDLL != Nil
            SSCE_CheckCtrlBackgroundNotify( ::hWnd, SSCE_OPTION, RGB(254, 1, 1) )
        ENDIF
    Endif

/*  if nMsg == 187 .and. nWParam == 7
        ::PostMsg( FM_CHANGE )
        SSCE_CheckCtrlBackgroundNotify( ::hWnd, SSCE_OPTION, RGB(254, 1, 1) )
    endif */
//      logfile( "trace.log", { "HandleEvent", nMsg, nWParam, nLParam } )

Return Super:HandleEvent( nMsg, nWParam, nLParam )

*-------------------------------------------------------------------------------------------------------------------------------
METHOD LButtonDown( nRow, nCol, nFlags ) CLASS MyRchEdt

    ::PostMsg( FM_CHANGE )
    Super:LButtonDown( nRow, nCol, nFlags )

RETURN NIL 

//----------------------------------------------------------------------------//
METHOD SetAttribute2( lUpper, lSuper, lSub, lHidden, lLink, lSmallCaps, lOnOff ) CLASS MyRchEdt

   local nMask, nEffects

   DEFAULT lSuper     := .f.,;
           lSub       := .f.,;
           lSmallCaps := .f.,;
           lUpper     := .f.,;
           lHidden    := .f.,;
           lLink      := .f.,;
           lOnOff     := .t.

   if ( lUpper .or. lHidden ) .and. ! ::lRE30
      RETURN NIL
   endif

   nMask := nOR( If( lUpper,  CFM_ALLCAPS,    0 ),;
                 If( lSuper, CFM_SUPERSCRIPT, 0 ),;
                 If( lSub, CFM_SUBSCRIPT,     0 ),;
                 If( lHidden, CFM_HIDDEN,     0 ),;
                 If( lLink, CFM_LINK,         0 ),;
                 If( lSmallCaps, CFM_SMALLCAPS, 0 ) )

   nEffects := nOR( If( lUpper,  CFE_ALLCAPS,    0 ),;
                    If( lSuper, CFE_SUPERSCRIPT, 0 ),;
                    If( lSub, CFE_SUBSCRIPT,     0 ),;
                    If( lHidden, CFE_HIDDEN,     0 ),;
                    If( lLink, CFE_LINK,         0 ),;
                    If( lSmallCaps, CFE_SMALLCAPS, 0 ) )

   RESetAttribute2( ::hWnd, nMask, nEffects, lOnOff )

   ::Change()

return nil

*-------------------------------------------------------------------------------------------------------------------------------
METHOD SetHangingIndent() CLASS MyRchEdt
local nLen := REGEtIndent( ::hWnd )

   if nLen[ 1 ] > 0
      RESetIndent( ::hWnd, 0, 0, 0 )
   else
      RESetHangingIndent( ::hWnd  )
   endif
//   pf.dwMask = PFM_OFFSET;

Return nil

*-------------------------------------------------------------------------------------------------------------------------------
METHOD InsertPic() CLASS MyRchEdt
   LOCAL cFile := cGetFile( "Windows bitmap (*.bmp) |*.bmp|" + ;
                            "Windows bitmap (*.dib) |*.dib|" + ;
                            "ICON format (*.ico) |*.ico", ;
                            RTF_VER, nGetFileFilter() )

   if !Empty( cFile )
//      ::InsertPicture( cFile )
   endif

RETURN NIL

*-------------------------------------------------------------------------------------------------------------------------------
METHOD InsertFile() CLASS MyRchEdt
   LOCAL cFile := cGetFile( "Rich Text Format (*.rtf) |*.rtf|" + ;
                            "Only Text Format (*.txt) |*.txt|" + ;
                            "All files (*.*) |*.*", RTF_VER, nGetFileFilter() )

   LOCAL nFormat

   IF !EMPTY( cFile )   
      nFormat := nOr( If( ::IsRTF( cFile ), SF_RTF, SF_TEXT ), SFF_SELECTION )

      RELoadFile( ::hWnd, cFile, nFormat )

      ::SendMsg( EM_SCROLLCARET, 0, 0 )
   ENDIF 
   
RETURN NIL

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

METHOD IsRTF( cFile ) CLASS MyRchEdt

   LOCAL nHandle := FOpen( cFile )
   LOCAL cBuffer := Space( 5 )
   LOCAL lOk     := .F.
   LOCAL nBytes

   if !( nHandle == -1 )
      if ( nBytes := FRead( nHandle, @cBuffer, 5 ) ) == 5
         lOk := ( cBuffer == "{\rtf" )
      endif

      FClose( nHandle )
   endif

RETURN lOk


*-------------------------------------------------------------------------------------------------------------------------------
//this func is also declared on tPathTrns but this .prg is included on 
//PlAdmin project while tPathTrns is not.  Don't know any other way to 
//solve this problem right now.
STATIC FUNCTION SSCE_CheckCtrlBackgroundNotify( hWnd, nOptions, nRGB )
RETURN DllCall( hDLL, DC_CALL_STD, "SSCE_CheckCtrlBackgroundNotify", hWnd, nOptions, nRGB )
 
And here is some c source you might need:

Code: Select all

*-------------------------------------------------------------------------------------------------------------------------------
#pragma BEGINDUMP

#include <windows.h>
#include <richedit.h>
#include <richole.h>
#include <oledlg.h>
#include <hbapi.h>
#include <hbvm.h>

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

static int nDLLVer = -1;

HB_FUNC( REDLLVERSION )
{
   char    szPath[ MAX_PATH ];
   HMODULE hMod;
   DWORD   Dummy;
   DWORD   dwSize;
   HGLOBAL hMem;
   LPVOID  pMem;
   VS_FIXEDFILEINFO * vsInfo;
   UINT    vsInfoSize;

   if( nDLLVer == -1 )
   {
      hMod = LoadLibrary( "RICHED20.DLL" );

      GetModuleFileName( hMod, szPath, sizeof( szPath ) );

      FreeLibrary( hMod );

      dwSize = GetFileVersionInfoSize( szPath, &Dummy );

      hMem = GlobalAlloc( GMEM_MOVEABLE, dwSize );

      if( hMem )
      {
         pMem = GlobalLock( hMem );

         GetFileVersionInfo( szPath, 0, dwSize, pMem );
         VerQueryValue( pMem, "\\", ( LPVOID * ) &vsInfo, &vsInfoSize );

         GlobalUnlock( hMem );
         GlobalFree( hMem );

         nDLLVer = LOWORD( vsInfo->dwFileVersionMS );
      }
   }
   hb_retni( nDLLVer );
}

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

HB_FUNC( REFINDTEXT )
{
   FINDTEXTEX ft;

   HWND  hWnd    = ( HWND ) hb_parnl( 1 );
   DWORD dwFlags = ( hb_parl( 3 ) ? FR_DOWN : 0 ) | ( hb_parl( 4 ) ? FR_MATCHCASE : 0 ) |
                   ( hb_parl( 5 ) ? FR_WHOLEWORD : 0 );

   SendMessage( hWnd, EM_EXGETSEL, 0, ( LPARAM ) &ft.chrg );

   ft.chrg.cpMin = hb_parl( 3 ) ? ft.chrg.cpMax : ft.chrg.cpMin;
   ft.chrg.cpMax = -1;
   ft.lpstrText  = ( LPSTR ) hb_parc( 2 );

   hb_retnl( SendMessage( hWnd, EM_FINDTEXTEX, dwFlags, ( LPARAM ) &ft ) );
}

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

HB_FUNC( REGETALIGNMENT )
{
   PARAFORMAT pf;

   memset( &pf, 0, sizeof( pf ) );

   pf.cbSize = sizeof( pf );

   SendMessage( ( HWND ) hb_parnl( 1 ), EM_GETPARAFORMAT, 0, ( LPARAM ) &pf );

   hb_retni( pf.wAlignment );
}

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

HB_FUNC( RESETALIGNMENT )
{
   PARAFORMAT pf;

   memset( &pf, 0, sizeof( pf ) );

   pf.cbSize = sizeof( pf );
   pf.dwMask = PFM_ALIGNMENT;
   pf.wAlignment = hb_parnl( 2 );

   hb_retl( SendMessage( ( HWND ) hb_parnl( 1 ), EM_SETPARAFORMAT, 0,
                         ( LPARAM ) &pf ) );
}

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

HB_FUNC( REGETBULLET )
{
   PARAFORMAT pf;

   memset( &pf, 0, sizeof( pf ) );

   pf.cbSize = sizeof( pf );

   SendMessage( ( HWND ) hb_parnl( 1 ), EM_GETPARAFORMAT, 0, ( LPARAM ) &pf );

   hb_retl( ( pf.dwMask & PFM_NUMBERING ) ? ( ( pf.wNumbering & PFN_BULLET ) ? 1 : 0 ) : 0 );
}

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

HB_FUNC( RESETBULLET )
{
   PARAFORMAT pf;

   memset( &pf, 0, sizeof( pf ) );

   pf.cbSize = sizeof( pf );
   pf.dwMask = PFM_NUMBERING | PFM_OFFSET;
   pf.wNumbering = hb_parl( 2 ) ? PFN_BULLET : 0;
   pf.dxOffset   = hb_parl( 2 ) ? 360 : 0;

   hb_retl( SendMessage( ( HWND ) hb_parnl( 1 ), EM_SETPARAFORMAT, 0,
                         ( LPARAM ) &pf ) );
}

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

HB_FUNC( RESETHANGINGINDENT )
{
   PARAFORMAT pf;

   memset( &pf, 0, sizeof( pf ) );

   pf.cbSize = sizeof( pf );
   pf.dwMask = PFM_OFFSET;
   pf.dxOffset   = 360;   //hb_parl( 2 ) ? 360 : 0;

   hb_retl( SendMessage( ( HWND ) hb_parnl( 1 ), EM_SETPARAFORMAT, 0,
                         ( LPARAM ) &pf ) );
}

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

HB_FUNC( REGETCHARFORMAT )
{
   CHARFORMAT cf;

   memset( &cf, 0, sizeof( cf ) );

   cf.cbSize = sizeof( cf );

   SendMessage( ( HWND ) hb_parnl( 1 ), EM_GETCHARFORMAT, TRUE, ( LPARAM ) &cf );

   hb_reta( 14 );
   hb_storni( cf.yHeight / 20, -1, 1 );
   hb_storni( 0, -1, 2 );
   hb_storni( 0, -1, 3 );
   hb_storni( 0, -1, 4 );
   hb_storni( cf.dwEffects & CFE_BOLD      ? FW_BOLD : FW_NORMAL, -1, 5 );
   hb_storl(  cf.dwEffects & CFE_ITALIC    ? TRUE    : FALSE,     -1, 6 );
   hb_storl(  cf.dwEffects & CFE_UNDERLINE ? TRUE    : FALSE,     -1, 7 );
   hb_storl(  cf.dwEffects & CFE_STRIKEOUT ? TRUE    : FALSE,     -1, 8 );
   hb_storni( cf.bCharSet, -1, 9 );
   hb_storni( 0, -1, 10 );
   hb_storni( 0, -1, 11 );
   hb_storni( 0, -1, 12 );
   hb_storni( cf.bPitchAndFamily, -1, 13 );
   hb_storc(  cf.szFaceName,      -1, 14 );

   if( hb_pcount() == 2 )
      hb_stornl( cf.crTextColor, 2 );
}

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

HB_FUNC( REGETCHARFORMAT2 )
{
   CHARFORMAT2 cf;

   memset( &cf, 0, sizeof( cf ) );

   cf.cbSize = sizeof( cf );
   
   cf.dwMask = CFM_SUBSCRIPT | CFM_SUPERSCRIPT | CFM_SMALLCAPS | CFM_BOLD | 
               CFM_ITALIC | CFM_UNDERLINE | CFM_SIZE |CFM_FACE | CFM_CHARSET ;
               
   cf.dwEffects = CFE_SUBSCRIPT | CFE_SUPERSCRIPT |CFE_SMALLCAPS |CFE_BOLD |
                  CFE_ITALIC | CFE_UNDERLINE ;
                                 
   SendMessage( ( HWND ) hb_parnl( 1 ), EM_GETCHARFORMAT, SCF_SELECTION, ( LPARAM ) &cf );

   hb_reta(6);

   hb_storl( cf.dwEffects & CFE_SUBSCRIPT ? TRUE : FALSE, -1, 1);
   hb_storl( cf.dwEffects & CFE_SUPERSCRIPT ? TRUE : FALSE, -1, 2);
   hb_storl( cf.dwEffects & CFE_SMALLCAPS ? TRUE : FALSE, -1, 3);
   hb_storl( cf.dwEffects & CFE_BOLD ? TRUE : FALSE, -1, 4);
   hb_storl( cf.dwEffects & CFE_ITALIC ? TRUE : FALSE, -1, 5);
   hb_storl( cf.dwEffects & CFE_UNDERLINE ? TRUE : FALSE, -1, 6);
}

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

HB_FUNC( RESETCHARFORMAT )
{
   CHARFORMAT cf;

   memset( &cf, 0, sizeof( cf ) );

   cf.cbSize = sizeof( cf );
   cf.dwMask = CFM_COLOR | CFM_FACE | CFM_SIZE | CFM_BOLD | CFM_ITALIC |
               CFM_UNDERLINE | CFM_STRIKEOUT;

   strcpy( cf.szFaceName, hb_parc( 2 ) );
   cf.yHeight = ( LONG ) hb_parnl( 3 );
   cf.crTextColor = hb_parnl( 4 );
   cf.bCharSet    = hb_parnl( 5 );
   cf.bPitchAndFamily = hb_parnl( 6 );

   if( hb_parl( 7 ) )
      cf.dwEffects |= CFE_BOLD;

   if( hb_parl( 8 ) )
      cf.dwEffects |= CFE_ITALIC;

   if( hb_parl( 9 ) )
      cf.dwEffects |= CFE_UNDERLINE;

   if( hb_parl( 10 ) )
      cf.dwEffects |= CFE_STRIKEOUT;

   hb_retl( SendMessage( ( HWND ) hb_parnl( 1 ), EM_SETCHARFORMAT,
                         SCF_WORD | SCF_SELECTION, ( LPARAM ) &cf ) );
}
//----------------------------------------------------------------------------//

HB_FUNC( RESETCHARFORMAT2 )
{
   CHARFORMAT cf;

   memset( &cf, 0, sizeof( cf ) );

   cf.cbSize = sizeof( cf );
   cf.dwMask = CFM_SUBSCRIPT | CFM_SUPERSCRIPT | CFM_SMALLCAPS ;

   if( hb_parl( 1 ) )
      cf.dwEffects |= CFE_SUBSCRIPT ;
      
   if( hb_parl( 2 ) )
      cf.dwEffects |= CFM_SUPERSCRIPT ;
      
   if( hb_parl( 3 ) )
      cf.dwEffects |= CFM_SMALLCAPS ;
      
   hb_retl( SendMessage( ( HWND ) hb_parnl( 1 ), EM_SETCHARFORMAT,
                         SCF_WORD | SCF_SELECTION, ( LPARAM ) &cf ) );
}

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

HB_FUNC( RESETSUPERSCRIPT )
{
   CHARFORMAT2 cf;

   memset( &cf, 0, sizeof( cf ) );

   cf.cbSize = sizeof( cf );
   cf.dwMask = CFM_SUPERSCRIPT;

   if( hb_parl( 2 ) )
      cf.dwEffects |= CFM_SUPERSCRIPT ;

   hb_retl( SendMessage( ( HWND ) hb_parnl( 1 ), EM_SETCHARFORMAT, 
                          SCF_WORD | SCF_SELECTION, ( LPARAM ) &cf ) );
}
//----------------------------------------------------------------------------//

HB_FUNC( REGETSUPERSCRIPT )
{
   CHARFORMAT2 cf;

   memset( &cf, 0, sizeof( cf ) );

   cf.cbSize = sizeof( cf );
   cf.dwMask = CFM_SUPERSCRIPT ;
   cf.dwEffects = CFE_SUPERSCRIPT;
                                 
   SendMessage( ( HWND ) hb_parnl( 1 ), EM_GETCHARFORMAT, SCF_SELECTION, ( LPARAM ) &cf );

   hb_retl( cf.dwEffects & CFE_SUPERSCRIPT );
}

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

HB_FUNC( REGETHIGHLIGHT )
{
   CHARFORMAT2 cf;

   memset( &cf, 0, sizeof( cf ) );

   cf.cbSize = sizeof( cf );

   SendMessage( ( HWND ) hb_parnl( 1 ), EM_GETCHARFORMAT, TRUE, ( LPARAM ) &cf );

   hb_retnl( cf.crBackColor );
}

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

HB_FUNC( RESETHIGHLIGHT )
{
   CHARFORMAT2 cf;

   memset( &cf, 0, sizeof( cf ) );

   cf.cbSize = sizeof( cf );
   cf.dwMask = CFM_BACKCOLOR;
   cf.crBackColor = hb_parnl( 2 );

   hb_retl( SendMessage( ( HWND ) hb_parnl( 1 ), EM_SETCHARFORMAT,
                         SCF_WORD | SCF_SELECTION, ( LPARAM ) &cf ) );
}


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

HB_FUNC( REGETINDENT )
{
   PARAFORMAT pf;

   memset( &pf, 0, sizeof( pf ) );

   pf.cbSize = sizeof( pf );

   SendMessage( ( HWND ) hb_parnl( 1 ), EM_GETPARAFORMAT, 0, ( LPARAM ) &pf );

   hb_reta( 3 );
   hb_stornl( pf.dxStartIndent + pf.dxOffset, -1, 1 );
   hb_stornl( pf.dxRightIndent, -1, 2 );
   hb_stornl( -pf.dxOffset, -1, 3 );
}

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

HB_FUNC( RESETINDENT )
{
   PARAFORMAT pf;

   memset( &pf, 0, sizeof( pf ) );

   pf.cbSize = sizeof( pf );
   pf.dwMask = PFM_STARTINDENT | PFM_RIGHTINDENT | PFM_OFFSET;
   pf.dxStartIndent = hb_parnl( 2 );
   pf.dxRightIndent = hb_parnl( 3 );
   pf.dxOffset      = hb_parnl( 4 );

   hb_retl( SendMessage( ( HWND ) hb_parnl( 1 ), EM_SETPARAFORMAT, 0,
                         ( LPARAM ) &pf ) );
}

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

HB_FUNC( REGETLINE )
{
   TCHAR szBuf[ 256 ];

   * ( ( WORD * ) szBuf ) = 256;

   hb_retclen( szBuf, SendMessage( ( HWND ) hb_parnl( 1 ), EM_GETLINE, hb_parnl( 2 ),
                                   ( LONG ) szBuf ) - 1 );
}

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

HB_FUNC( REGETNMHDRLINK )
{
   ENLINK enLink = * ( ( ENLINK * ) hb_parnl( 1 ) );

   hb_reta( 4 );
   hb_storni( enLink.msg, -1, 1 );
   hb_storni( enLink.lParam, -1, 2 );
   hb_storni( enLink.chrg.cpMin, -1, 3 );
   hb_storni( enLink.chrg.cpMax, -1, 4 );
}

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

HB_FUNC( REGETNUMBERING )
{
   PARAFORMAT2 pf;

   memset( &pf, 0, sizeof( pf ) );

   pf.cbSize = sizeof( pf );

   SendMessage( ( HWND ) hb_parnl( 1 ), EM_GETPARAFORMAT, 0, ( LPARAM ) &pf );

   hb_retl( ( pf.dwMask & PFM_NUMBERING ) ? ( ( pf.wNumbering & 2 ) ? 1 :0 ) : 0 );
}

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

HB_FUNC( RESETNUMBERING )
{
   PARAFORMAT2 pf;
   BOOL bOnOff = hb_parl( 2 );

   memset( &pf, 0, sizeof( pf ) );

   pf.cbSize = sizeof( pf );
   pf.dwMask = PFM_NUMBERING | PFM_OFFSET |
               ( bOnOff ? ( PFM_NUMBERINGSTART | PFM_NUMBERINGSTYLE | PFM_NUMBERINGTAB ) : 0 );
   pf.wNumbering      = bOnOff ? 2 : 0;
   pf.wNumberingStart = bOnOff ? 1 : 0;
   pf.wNumberingStyle = bOnOff ? 1 : 0;
   pf.wNumberingTab   = bOnOff ? 360 : 0;
   pf.dxOffset        = bOnOff ? 360 : 0;

   hb_retl( SendMessage( ( HWND ) hb_parnl( 1 ), EM_SETPARAFORMAT, 0,
                         ( LPARAM ) &pf ) );
}

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

#pragma argsused

static void * pBuffer = 0;
static ULONG ulSize = 0;
static ULONG ulMax = 0;

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

static DWORD CALLBACK REStreamIn( DWORD dwCookie, LPBYTE pbBuff, LONG cb,
                                  LONG FAR * pcb )
{
   if( ulSize + cb >= ulMax )
      cb = ulMax - ulSize - 1;

   memcpy( ( char * ) pbBuff, ( char * ) pBuffer + ulSize, cb );
   * pcb = cb;
   ulSize += cb;

   return 0;
}

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

#pragma argsused

static DWORD CALLBACK REStreamOut( DWORD dwCookie, LPBYTE pbBuff, LONG cb,
                                   LONG FAR * pcb )
{
   if( pBuffer == 0 )
      pBuffer = hb_xgrab( cb );
   else
      pBuffer = hb_xrealloc( pBuffer, ulSize + cb );

   memcpy( ( char * ) pBuffer + ulSize, ( char * ) pbBuff, cb );
   * pcb = cb;
   ulSize += cb;

   return 0;
}

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

HB_FUNC( REGETRTF )
{
   EDITSTREAM es;

   es.dwCookie    = 0;
   es.dwError     = 0;
   es.pfnCallback = REStreamOut;

   SendMessage( ( HWND ) hb_parnl( 1 ), EM_STREAMOUT,
                ( hb_parl( 2 ) ? SFF_SELECTION : 0 ) | SF_RTF, ( LPARAM ) &es );

   hb_retclen( ( char * ) pBuffer, ulSize );
   hb_xfree( pBuffer );

   pBuffer = 0;
   ulSize  = 0;
   ulMax   = 0;
}

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

HB_FUNC( RELOADRTF )
{
   EDITSTREAM es;

   es.dwCookie    = 0;
   es.dwError     = 0;
   es.pfnCallback = REStreamIn;

   pBuffer = ( void * ) hb_parc( 2 );
   ulSize  = 0;
   ulMax   = hb_parclen( 2 );

   SendMessage( ( HWND ) hb_parnl( 1 ), EM_STREAMIN, hb_parni( 3 ), ( LPARAM ) &es );

   pBuffer = 0;
   ulSize  = 0;
   ulMax   = 0;
}

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

HB_FUNC( REGETSELECTION )
{
   CHARRANGE cr;

   SendMessage( ( HWND ) hb_parnl( 1 ), EM_EXGETSEL, 0, ( LPARAM ) &cr );

   if( hb_pcount() > 1 )
      hb_stornl( cr.cpMin, 2 );

   if( hb_pcount() == 3 )
      hb_stornl( cr.cpMax, 3 );
}

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

HB_FUNC( RESETSELECTION )
{
   CHARRANGE cr;

   cr.cpMin = hb_parnl( 2 );
   cr.cpMax = hb_parnl( 3 );

   SendMessage( ( HWND ) hb_parnl( 1 ), EM_EXSETSEL, 0, ( LPARAM ) &cr );

   hb_retni( SendMessage( ( HWND ) hb_parnl( 1 ), EM_SCROLLCARET, 0, 0L ) );
}

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

HB_FUNC( REGETTABSTOP )
{
   PARAFORMAT pf ;

   memset( &pf, 0, sizeof( pf ) );

   pf.cbSize = sizeof( pf );

   SendMessage( ( HWND ) hb_parnl( 1 ), EM_GETPARAFORMAT, 0, ( LPARAM ) &pf );

   hb_retnl( pf.rgxTabs[ 0 ] );
}

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

HB_FUNC( RESETTABSTOP )
{
   PARAFORMAT pf;
   int i;

   memset( &pf, 0, sizeof( pf ) );

   pf.cbSize = sizeof( pf );
   pf.dwMask = PFM_TABSTOPS;
   pf.cTabCount = MAX_TAB_STOPS;

   for( i = 0; i < MAX_TAB_STOPS; i++ )
       pf.rgxTabs[ i ] = ( i + 1 ) * hb_parnl( 2 );

   hb_retl( SendMessage( ( HWND ) hb_parnl( 1 ), EM_SETPARAFORMAT, 0, ( LPARAM ) &pf ) );
}

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

HB_FUNC( REGETTEXTCOLOR )
{
   CHARFORMAT cf;

   memset( &cf, 0, sizeof( cf ) );

   cf.cbSize = sizeof( cf );

   SendMessage( ( HWND ) hb_parnl( 1 ), EM_GETCHARFORMAT, TRUE, ( LPARAM ) &cf );

   hb_retnl( cf.crTextColor );
}

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

HB_FUNC( RESETTEXTCOLOR )
{
   CHARFORMAT cf;

   memset( &cf, 0, sizeof( cf ) );

   cf.cbSize = sizeof( cf );
   cf.dwMask = CFM_COLOR;
   cf.crTextColor = hb_parnl( 2 );

   hb_retl( SendMessage( ( HWND ) hb_parnl( 1 ), EM_SETCHARFORMAT,
                         SCF_WORD | SCF_SELECTION, ( LPARAM ) &cf ) );
}

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

HB_FUNC( REGETTEXTRANGE )
{
   TEXTRANGE tr;

   tr.chrg.cpMin = hb_parnl( 2 );
   tr.chrg.cpMax = hb_parnl( 3 );
   tr.lpstrText  = ( LPSTR ) hb_parc( 4 );

   SendMessage( ( HWND ) hb_parnl( 1 ), EM_GETTEXTRANGE, 0, ( LPARAM ) &tr );

   hb_storc( tr.lpstrText, 4 );
}

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

HB_FUNC( RELEN )
{
   GETTEXTLENGTHEX gt;

   gt.flags = GTL_PRECISE;
   gt.codepage = CP_ACP;

   hb_retnl( SendMessage( ( HWND ) hb_parnl( 1 ), EM_GETTEXTLENGTHEX, ( WPARAM ) &gt, 0 ) );
}

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

HB_FUNC( REREPLACE )
{
   SendMessage( ( HWND ) hb_parnl( 1 ), EM_REPLACESEL, TRUE,
                ( LPARAM ) ( LPSTR ) hb_parc( 2 ) );
}

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

HB_FUNC( RESETATTRIBUTE )
{
   CHARFORMAT cf;

   memset( &cf, 0, sizeof( cf ) );

   cf.cbSize = sizeof( cf );
   cf.dwMask = hb_parnl( 2 );

   if( hb_parl( 4 ) )
      cf.dwEffects |= hb_parnl( 3 );
   else
      cf.dwEffects &= ~hb_parnl( 3 );

   hb_retl( SendMessage( ( HWND ) hb_parnl( 1 ), EM_SETCHARFORMAT,
                         SCF_WORD | SCF_SELECTION, ( LPARAM ) &cf ) );
}

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

HB_FUNC( RESETATTRIBUTE2 )
{
   CHARFORMAT2 cf;

   memset( &cf, 0, sizeof( cf ) );

   cf.cbSize = sizeof( cf );
   cf.dwMask = hb_parnl( 2 );

   if( hb_parl( 4 ) )
      cf.dwEffects |= hb_parnl( 3 );
   else
      cf.dwEffects &= ~hb_parnl( 3 );

   hb_retl( SendMessage( ( HWND ) hb_parnl( 1 ), EM_SETCHARFORMAT,
                         SCF_WORD | SCF_SELECTION, ( LPARAM ) &cf ) );
}

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

HB_FUNC( RESETAUTOURLDETECT )
{
   HWND hWnd = ( HWND ) hb_parnl( 1 );
   BOOL bUrl = hb_parl( 2 );
   UINT uMask;

   SendMessage( hWnd, EM_AUTOURLDETECT, bUrl, 0 );

   uMask = SendMessage( hWnd, EM_GETEVENTMASK, 0, 0 );

   if( bUrl )
      uMask |= ENM_LINK;
   else
      uMask &= ~ENM_LINK;

   SendMessage( hWnd, EM_SETEVENTMASK, 0, uMask );
}

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

HB_FUNC( RESETFONTNAME )
{
   CHARFORMAT cf;

   memset( &cf, 0, sizeof( cf ) );

   cf.cbSize = sizeof( cf );
   cf.dwMask = CFM_FACE;
   strcpy( cf.szFaceName, hb_parc( 2 ) );

   hb_retl( SendMessage( ( HWND ) hb_parnl( 1 ), EM_SETCHARFORMAT,
                         SCF_WORD | SCF_SELECTION, ( LPARAM ) &cf ) );
}

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

HB_FUNC( RESETFONTSIZE )
{
   CHARFORMAT cf;

   memset( &cf, 0, sizeof( cf ) );

   cf.cbSize  = sizeof( cf );
   cf.dwMask  = CFM_SIZE;
   cf.yHeight = hb_parnl( 2 );

   hb_retl( SendMessage( ( HWND ) hb_parnl( 1 ), EM_SETCHARFORMAT,
                         SCF_WORD | SCF_SELECTION, ( LPARAM ) &cf ) );
}

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

HB_FUNC( RESETPOS )
{
   CHARRANGE cr;

   cr.cpMin = hb_parnl( 2 );
   cr.cpMax = hb_parnl( 2 );

   SendMessage( ( HWND ) hb_parnl( 1 ), EM_EXSETSEL, 0, ( LPARAM ) &cr );
}

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

HB_FUNC( REPRINT )
{
   GETTEXTLENGTHEX gt;
   FORMATRANGE fr;
   DOCINFO info;

   HWND hWnd = ( HWND ) hb_parnl( 1 );
   HDC  hDC  = ( HDC ) hb_parnl( 3 );
   BOOL bPageNums  = hb_parl( 4 );
   BOOL bSelection = hb_parl( 5 );
   BOOL bCollate   = hb_parl( 6 );
   WORD nFromPage  = hb_parni( 7, 1 );
   WORD nToPage    = hb_parni( 7, 2 );
   WORD nCopies    = hb_parni( 8 );
   WORD nTop       = hb_parni( 9, 1 );
   WORD nLeft      = hb_parni( 9, 2 );
   WORD nRight     = hb_parni( 9, 3 );
   WORD nBottom    = hb_parni( 9, 4 );
   WORD nPag, nCollate, i;
   LONG lSize, lPrint;
   RECT rcTemp;

   SetMapMode( hDC, MM_TEXT );

   ZeroMemory( &fr, sizeof( fr ) );
   fr.hdc = hDC;
   fr.hdcTarget = hDC;

   fr.rcPage.top    = 0;
   fr.rcPage.left   = 0;
   fr.rcPage.right  = MulDiv( GetDeviceCaps( hDC, HORZRES ), 1440,
                              GetDeviceCaps( hDC, LOGPIXELSX ) );
   fr.rcPage.bottom = MulDiv( GetDeviceCaps( hDC, VERTRES ), 1440,
                              GetDeviceCaps( hDC, LOGPIXELSY ) );

   fr.rc.top    = fr.rcPage.top + nTop;
   fr.rc.left   = fr.rcPage.left + nLeft;
   fr.rc.right  = fr.rcPage.right - nRight;
   fr.rc.bottom = fr.rcPage.bottom - nBottom;

   ZeroMemory( &info, sizeof( info ) );
   info.cbSize      = sizeof( DOCINFO );
   info.lpszDocName = hb_parc( 2 );
   info.lpszOutput  = NULL;

   gt.flags = GTL_PRECISE;
   gt.codepage = CP_ACP;

   lSize = SendMessage( hWnd, EM_GETTEXTLENGTHEX, ( WPARAM ) &gt, 0 );

   rcTemp = fr.rc;

   if( bCollate )
      nCollate = nCopies;
   else
      nCollate = 1;

   for( i = 0; i < nCollate; i++ )
   {
      nPag = 1;

      fr.chrg.cpMin = 0;
      fr.chrg.cpMax = -1;

      if( bSelection )
      {
         SendMessage( hWnd, EM_EXGETSEL, 0, ( LPARAM ) &fr.chrg );
         lSize = fr.chrg.cpMax;
      }

      StartDoc( hDC, &info );

      do
      {
         lPrint = SendMessage( hWnd, EM_FORMATRANGE, FALSE, ( LPARAM ) &fr );

         if( !( bPageNums && nPag < nFromPage ) )
         {
            StartPage( hDC );

            SendMessage( hWnd, EM_DISPLAYBAND, 0, ( LPARAM ) &fr.rc );

            EndPage( hDC );
         }

         if( lPrint < lSize )
         {
            fr.chrg.cpMin = lPrint;
            fr.chrg.cpMax = lSize;
         }

         fr.rc = rcTemp;

         nPag++;

         if( bPageNums && nPag > nToPage )
            break;
      }
      while( lPrint < lSize );
   }
   SendMessage( hWnd, EM_FORMATRANGE, FALSE, ( LPARAM ) NULL );

   EndDoc( hDC );
}

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

static DWORD CALLBACK StreamIn( DWORD dwCookie, LPBYTE pbBuff, LONG cb,
                                LONG FAR * pcb )
{
   DWORD dwRead;

   if( ReadFile( ( HANDLE ) dwCookie, pbBuff, cb, &dwRead, NULL ) )
      * pcb = dwRead;

   return 0;
}

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

static DWORD CALLBACK StreamOut( DWORD dwCookie, LPBYTE pbBuff, LONG cb,
                                 LONG FAR * pcb )
{
   DWORD dwWrite;

   if( WriteFile( ( HANDLE ) dwCookie, pbBuff, cb, &dwWrite, NULL ) )
      * pcb = dwWrite;

   return 0;
}

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

HB_FUNC( RELOADFILE )
{
   EDITSTREAM es;

   es.dwCookie    = ( DWORD ) CreateFile( ( LPCTSTR ) hb_parc( 2 ),
                                          GENERIC_READ | GENERIC_WRITE,
                                          FILE_SHARE_READ | FILE_SHARE_WRITE,
                                          NULL,
                                          OPEN_EXISTING,
                                          FILE_ATTRIBUTE_NORMAL,
                                          NULL );
   es.dwError     = 0;
   es.pfnCallback = StreamIn;

   SendMessage( ( HWND ) hb_parnl( 1 ), EM_STREAMIN, hb_parni( 3 ), ( LPARAM ) &es );

   CloseHandle( ( HANDLE ) es.dwCookie );
}

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

HB_FUNC( RESAVEFILE )
{
   EDITSTREAM es;

   es.dwCookie    = ( DWORD ) CreateFile( ( LPCTSTR ) hb_parc( 2 ),
                                          GENERIC_READ | GENERIC_WRITE,
                                          0,
                                          NULL,
                                          CREATE_ALWAYS,
                                          FILE_ATTRIBUTE_ARCHIVE,
                                          NULL );
   es.dwError     = 0;
   es.pfnCallback = StreamOut;

   SendMessage( ( HWND ) hb_parnl( 1 ), EM_STREAMOUT, hb_parni( 3 ), ( LPARAM ) &es );

   CloseHandle( ( HANDLE ) es.dwCookie );
}

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

HB_FUNC( REFILEPROPERTY )
{
   SHELLEXECUTEINFO sei;

   ZeroMemory( &sei, sizeof( sei ) );
   sei.cbSize = sizeof( sei );
   sei.hwnd   = ( HWND ) hb_parnl( 1 );
   sei.lpFile = ( LPSTR ) hb_parc( 2 );
   sei.lpVerb = "properties";
   sei.fMask  = SEE_MASK_INVOKEIDLIST;

   ShellExecuteEx( &sei );
}


//--------------------------------------------------------------------------
//adding method InsertPicture() to class TRichEdit
/*HB_FUNC( TRICHEDIT_INSERTPICTURE )
{
   PHB_ITEM     Self     = hb_stackSelfItem();
   REDOC *      predoc   = ( REDOC * ) XA_ObjGetNL( Self, "pREDOC" );
   LPDATAOBJECT pdataobj = NULL;
   LPOLEOBJECT  poleobj  = NULL;
   LPSTORAGE    pstg     = NULL;
   LPOLECLIENTSITE polesite = NULL;
   STGMEDIUM    stgm;
   LPFORMATETC  pft;
   FORMATETC    ft;
   LPWSTR       szFile;
   REOBJECT     reo;
   CLSID        clsid;
   SIZEL        sizel;
   BOOL         bBitmap = ISNUM( 1 );

   XA_ObjSend( Self, "GetOleInterface" );

   if( predoc->preole->lpVtbl->GetClientSite( predoc->preole, ( LPOLECLIENTSITE FAR * ) &polesite ) == S_OK )
   {
      if( REOC_GetNewStorage( predoc->preoc, &pstg ) == S_OK )
      {
         if( bBitmap )
         {
            if( REDATA_QueryInterface( predoc->predata, &IID_IDataObject, ( LPVOID FAR * ) &pdataobj ) == S_OK )
            {
               stgm.tymed = TYMED_GDI;
               stgm.u.hBitmap = ( HBITMAP ) hb_parnl( 1 );
               stgm.pUnkForRelease = NULL;

               ft.cfFormat = CF_BITMAP;
               ft.ptd      = NULL;
               ft.dwAspect = DVASPECT_CONTENT;
               ft.lindex   = -1;
               ft.tymed    = TYMED_GDI;

               if( REDATA_SetData( predoc->predata, &ft, &stgm, TRUE ) == S_OK )
                  OleCreateStaticFromData( pdataobj, &IID_IOleObject, OLERENDER_FORMAT,
                                           &ft, polesite, pstg,
                                           ( LPVOID FAR * ) &poleobj );
            }
         }
         else
         {
            pft = &ft;
            pft->cfFormat = 0;
            pft->ptd      = NULL;
            pft->dwAspect = DVASPECT_CONTENT;
            pft->lindex   = -1;
            pft->tymed    = TYMED_NULL;

            szFile = AnsiToWide( hb_parc( 1 ) );

            OleCreateFromFile( &CLSID_NULL, szFile, &IID_IOleObject, OLERENDER_DRAW,
                               pft, polesite, pstg, ( LPVOID FAR * ) &poleobj );

            hb_xfree( szFile );
         }

         if( OleSetContainedObject( ( LPUNKNOWN ) poleobj, TRUE ) == S_OK )
         {
            if( poleobj->lpVtbl->GetUserClassID( poleobj, &clsid ) == S_OK )
            {
               sizel.cx = ISNUM( 2 ) ? hb_parnl( 2 ) : 0;
               sizel.cy = ISNUM( 3 ) ? hb_parnl( 3 ) : 0;

               ZeroMemory( &reo, sizeof( REOBJECT ) );
               reo.cbStruct = sizeof( REOBJECT );
               reo.clsid    = clsid;
               reo.cp       = REO_CP_SELECTION;
               reo.dvaspect = DVASPECT_CONTENT;
               reo.dwFlags  = REO_RESIZABLE | REO_BELOWBASELINE;
               reo.dwUser   = 0;
               reo.poleobj  = poleobj;
               reo.polesite = polesite;
               reo.pstg     = pstg;
               reo.sizel    = sizel;

               predoc->preole->lpVtbl->InsertObject( predoc->preole, &reo );
            }
         }
      }
   }

   if( poleobj )
      poleobj->lpVtbl->Release( poleobj );

   if( pstg )
      pstg->lpVtbl->Release( pstg );

   if( polesite )
      polesite->lpVtbl->Release( polesite );

   poleobj  = NULL;
   pstg     = NULL;
   polesite = NULL;

   if( bBitmap )
   {
      if( pdataobj )
         pdataobj->lpVtbl->Release( pdataobj );

      pdataobj = NULL;
   }

   hb_ret();
}

/**/
//----------------------------------------------------------------------------//
/*
static SYSTEMTIME st;
static LCID id;
static PHB_ITEM pFormats;

static BOOL CALLBACK DateFormatEnumProc( LPTSTR lpszFormatString )
{
   PHB_ITEM pDate = hb_itemNew( NULL );
   char szDate[ 256 ];

   GetDateFormat( id, 0, &st, lpszFormatString, szDate, 256 );

   #if defined( __XHARBOUR__ )
      if( hb_arrayScan( pFormats, hb_itemPutC( pDate, szDate ), NULL, NULL, TRUE ) == 0 )
   #else
      if( hb_arrayScan( pFormats, hb_itemPutC( pDate, szDate ), NULL, NULL ) == 0 )
   #endif
      hb_arrayAdd( pFormats, pDate );

   hb_itemRelease( pDate );

   return TRUE;
}

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

static BOOL CALLBACK TimeFormatEnumProc( LPTSTR lpszFormatString )
{
   PHB_ITEM pTime = hb_itemNew( NULL );
   char szTime[ 256 ];

   GetTimeFormat( id, 0, &st, lpszFormatString, szTime, 256 );

   #if defined( __XHARBOUR__ )
      if( hb_arrayScan( pFormats, hb_itemPutC( pTime, szTime ), NULL, NULL, TRUE ) == 0 )
   #else
      if( hb_arrayScan( pFormats, hb_itemPutC( pTime, szTime ), NULL, NULL ) == 0 )
   #endif
      hb_arrayAdd( pFormats, pTime );

   hb_itemRelease( pTime );

   return TRUE;
}

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

HB_FUNC( REGETDATETIME )
{
   GetLocalTime( &st );
   id = GetUserDefaultLCID();

   pFormats = hb_itemArrayNew( 0 );

   EnumDateFormats( ( DATEFMT_ENUMPROC ) DateFormatEnumProc, id, DATE_SHORTDATE );
   EnumDateFormats( ( DATEFMT_ENUMPROC ) DateFormatEnumProc, id, DATE_LONGDATE );
   EnumTimeFormats( ( DATEFMT_ENUMPROC ) TimeFormatEnumProc, id, 0 );

   hb_itemReturn( pFormats );
   hb_itemRelease( pFormats );
}
*/
//----------------------------------------------------------------------------//
#pragma ENDDUMP

/*
#pragma BEGINDUMP



#include <windows.h>
#include <richedit.h>
#include <hbapi.h>

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

HB_FUNC( REGETHIGHLIGHT )
{
   CHARFORMAT2 cf;

   memset( ( char * ) &cf, 0, sizeof( cf ) );

   cf.cbSize = sizeof( cf );

   SendMessage( ( HWND ) hb_parnl( 1 ), EM_GETCHARFORMAT, TRUE, ( LPARAM ) &cf );

   hb_retnl( cf.crBackColor );
}

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

HB_FUNC( RESETHIGHLIGHT )
{
   CHARFORMAT2 cf;

   memset( ( char * ) &cf, 0, sizeof( cf ) );

   cf.cbSize = sizeof( cf );
   cf.dwMask = CFM_BACKCOLOR;
   cf.crBackColor = hb_parnl( 2 );

   hb_retl( SendMessage( ( HWND ) hb_parnl( 1 ), EM_SETCHARFORMAT,
                         SCF_WORD | SCF_SELECTION, ( LPARAM ) &cf ) );
}
//------------------------------------------------------------------------------------------------------------------------------
HB_FUNC( REGETINDENT )
{
   PARAFORMAT pf;

   memset( ( char * ) &pf, 0, sizeof( pf ) );

   pf.cbSize = sizeof( pf );

   SendMessage( ( HWND ) hb_parnl( 1 ), EM_GETPARAFORMAT, 0, ( LPARAM ) &pf );

   hb_reta( 3 );
   hb_stornl( pf.dxStartIndent + pf.dxOffset, -1, 1 );
   hb_stornl( pf.dxRightIndent, -1, 2 );
   hb_stornl( -pf.dxOffset, -1, 3 );
}

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

HB_FUNC( REGETLINE )
{
   TCHAR szBuf[ 256 ];

   * ( ( WORD * ) szBuf ) = 256;

   hb_retclen( szBuf, SendMessage( ( HWND ) hb_parnl( 1 ), EM_GETLINE, hb_parnl( 2 ),
                                   ( LONG ) szBuf ) - 1 );
}


//------------------------------------------------------------------------------------------------------------------------------
HB_FUNC( REGETSELECTION )
{
   CHARRANGE cr;

   SendMessage( ( HWND ) hb_parnl( 1 ), EM_EXGETSEL, 0, ( LPARAM ) &cr );

   if( hb_pcount() > 1 )
      hb_stornl( cr.cpMin, 2 );

   if( hb_pcount() == 3 )
      hb_stornl( cr.cpMax, 3 );
}

//------------------------------------------------------------------------------------------------------------------------------
HB_FUNC( RESETSELECTION )
{
   CHARRANGE cr;

   cr.cpMin = hb_parnl( 2 );
   cr.cpMax = hb_parnl( 3 );

   SendMessage( ( HWND ) hb_parnl( 1 ), EM_EXSETSEL, 0, ( LPARAM ) &cr );

   hb_retni( SendMessage( ( HWND ) hb_parnl( 1 ), EM_SCROLLCARET, 0, 0L ) );
}

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

HB_FUNC( REFINDTEXT )
{
   FINDTEXTEX ft;

   HWND  hWnd    = ( HWND ) hb_parnl( 1 );
   DWORD dwFlags = ( hb_parl( 3 ) ? FR_DOWN : 0 ) | ( hb_parl( 4 ) ? FR_MATCHCASE : 0 ) |
                   ( hb_parl( 5 ) ? FR_WHOLEWORD : 0 );

   SendMessage( hWnd, EM_EXGETSEL, 0, ( LPARAM ) &ft.chrg );

   ft.chrg.cpMin = hb_parl( 3 ) ? ft.chrg.cpMax : ft.chrg.cpMin;
   ft.chrg.cpMax = -1;
   ft.lpstrText  = ( LPSTR ) hb_parc( 2 );

   hb_retnl( SendMessage( hWnd, EM_FINDTEXTEX, dwFlags, ( LPARAM ) &ft ) );
}


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

#pragma ENDDUMP
 */
 
Reinaldo.
User avatar
Silvio.Falconi
Posts: 4956
Joined: Thu Oct 18, 2012 7:17 pm

Re: How to use RichText font attributes

Post by Silvio.Falconi »

thanks
these sources I reviewed many functions that I had lost and they were in the old class of 2002 when I was the old pad
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
Post Reply