RichType Print

Re: RichType Print

Postby cnavarro » Thu May 11, 2017 6:04 pm

Yes, code is correct
When you retrieve from memo, not retrieve image, format and text ?
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
User avatar
cnavarro
 
Posts: 6541
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: RichType Print

Postby Rick Lipkin » Thu May 11, 2017 6:15 pm

Cristabol

Here is what I retrieve after saving cLetter to the Access memo .. and then retrieving it with ( paraphrasing the code )

Code: Select all  Expand view

cLetter      := oRsLetter:Fields("BODY"):Value

 _ViewMemo( cMode, Substr(cName,1,30), oRsLetter, oButt3, @cRtPrompt, @cLetter, oFontB

//-----------------------------
Static FUNC _ViewMemo( cMODE, cTitle, oRsLetter, oButt3, cRtPrompt, cLetter, oFontb )
Local cRtf

cRtf := cLetter

IF cMODE = "E" .or. cMode = "A"

    REDEFINE RICHEDIT5 oRtf VAR cRtf ID 130 of oUSERS //UPDATE

ELSE     // view

     REDEFINE RICHEDIT5 oRtf VAR cRtf ID 130 of oUSERS //READONLY //COLOR CLR_BLACK, 15987697 READONLY
      oRtf:SetReadOnly( .T. )

ENDIF

oRtf:SetText( cRtf )
oRtf:bGotFocus = { || oRtf:SetSel( 0, 0 ) }
 


Image
User avatar
Rick Lipkin
 
Posts: 2663
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: RichType Print

Postby cnavarro » Thu May 11, 2017 7:07 pm

Rick
When you load rtf text, use oRich:LoadRTF( cLetter ), instead of SetText, and try
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
User avatar
cnavarro
 
Posts: 6541
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: RichType Print

Postby Rick Lipkin » Thu May 11, 2017 7:28 pm

Cristabol

Let me put together a self contained example using Ms Access .. I will send it to your private e-mail.

Rick Lipkin
User avatar
Rick Lipkin
 
Posts: 2663
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: RichType Print

Postby Enrico Maria Giordano » Thu May 11, 2017 8:47 pm

Rick Lipkin wrote:Cristabol


Rick,

his correct name is Cristobal, not Cristabol! :-)

Anyway... can you build a compilable and runnable sample showing the problem so we can test it here?

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: RichType Print

Postby Rick Lipkin » Thu May 11, 2017 11:40 pm

Enrico

Here is the self contained example I sent Cristobal .. for some reason, the program did not create the ms access file for Cristobal .. let me know if you have any problems:
Code: Select all  Expand view

// RichText

#Include "FiveWin.ch"
#include "RichEdi5.ch"

//-------------------------------
Func Main()

Local cFile,aDir,dExe
Local nStart,cDefa,nYear
Local xProvider,xSource,cRdd
Local xConnect,oCn,cSql
Local catNewDB,oRsLetter,oErr
Local Saying

//-- get timestamp on .exe //

cFILE := GetModuleFileName( GetInstance() )
aDIR  := DIRECTORY( cFILE )
dEXE  := aDIR[1] [3]

// where .exe started from is default directory //

nSTART := RAT( "\", cFILE )
cDEFA  := SUBSTR(cFILE,1,nSTART-1)

aDIR := NIL
SET DEFA to ( cDEFA )

SET DELETED on
SET CENTURY on
SET 3DLOOK on

nYEAR := ( year( DATE() )-30 )
SET EPOCH to ( nYEAR )

REQUEST DBFCDX
rddsetdefault ( "
DBFCDX" )

xPROVIDER := "
Microsoft.Jet.OLEDB.4.0"
xSOURCE   := cDEFA+"
\Rick.mdb"
cRDD      := xPROVIDER+"
-- "+xSOURCE

 // global connection string
xCONNECT := 'Provider='+xPROVIDER+';Data Source='+xSOURCE

aDIR := DIRECTORY( cDEFA+"
\MASTHEAD\*.*", "D" )
IF EMPTY( aDIR )

   IF lMkDir( cDEFA+"
\Masthead" )
   ELSE
      SAYING := "
SORRY ... Could not make the directory "+CHR(10)
      SAYING += cDEFA+"
\Masthead needed to run this Application "+CHR(10)
      SAYING += "
Aborting"+CHR(10)
      MsgInfo( SAYING )
      RETURN(.F.)
   ENDIF

ENDIF

aDir := NIL

If .not. File( cDefa+"
\Rick.mdb" )

   Ferase( cDefa+"
\Rick.mdb" )

   // create the adox object
   Try
      catNewDB := CreateObject("
ADOX.Catalog")
   Catch
      MsgInfo( "
Could not Create ADOX object")
      Return(.f.)
   End try

   // create the table Rick.mdb
   Try
     catNewDB:Create('Provider='+xProvider+';Data Source='+xSource+';Jet OLEDB:Engine Type=5' )
   Catch
     MsgInfo( "
Could not create the table "+xSource )
     Return(.f.)
   End Try

   catNewDB:ActiveConnection:Close()
   catNewDB := nil

   Try
     oCn  := CREATEOBJECT( "
ADODB.Connection" )
   Catch
     MsgInfo( "
Could not create the ADO object for connection")
   End Try

   TRY
     oCn:Open( xCONNECT )
   CATCH oErr
     MsgInfo( "
Could not open a Connection to Database "+xSource )
     RETURN(.F.)
   END TRY

   cSQL := "
CREATE TABLE [Letter]"
   cSQL += "
( "
   cSql += "
[LetterEid]         Integer   NOT NULL, "
   cSql += "
[Title]             char(100) NULL, "
   cSql += "
[Body]              Text      NULL, "
   cSql += "
[EntryBy]           char(25)  NULL, "
   cSql += "
[EntryDate]         DateTime  NULL, "
   cSql += "
[PicFileName]       char(50)  NULL, "
   cSQL += "
CONSTRAINT PK_LETTER PRIMARY KEY ( [LetterEid] )"
   cSQL += "
)"

   Try
      oCn:Execute( cSQL )
   Catch
      MsgInfo( "
Table LETTER Failed" )
      Return(.f.)
   End try

   oRsLetter := TOleAuto():New( "
ADODB.Recordset" )
   oRsLetter:CursorType     := 1        // opendkeyset
   oRsLetter:CursorLocation := 3        // local cache
   oRsLetter:LockType       := 3        // lockoportunistic

   cSQL := "
SELECT * FROM Letter"

   TRY
     oRsLetter:Open(cSQL,xConnect )
   CATCH oErr
      MsgInfo( "
Error in Opening LETTER table" )
      oCn:Close()
      RETURN(.F.)
   END TRY

   oRsLetter:AddNew()

   oRsLetter:Fields("
LetterEid"):Value := 49491863
   oRsLetter:Fields("
Title"):Value       := "We Have Moved             "
   oRsLetter:Fields("
Body"):Value        := ""
   oRsLetter:Fields("
EntryBy"):Value     := "Donald Trump"
   oRsLetter:Fields("
EntryDate"):Value   := Date()
   oRsLetter:Fields("
PicFileName"):Value := "49491863.PNG"

   oRsLetter:Update()
   oRsLetter:CLose()

   oCn:Close()
   oCn := nil

Endif

_LightGreyGrad()

 // global connection string
xCONNECT := 'Provider='+xPROVIDER+';Data Source='+xSOURCE

oCn := nil
oCn := CREATEOBJECT( "
ADODB.Connection" )

TRY
   oCn:Open( xConnect )
CATCH oErr
   Saying := "
Could not open a Global Connection to Database "+xSource
   MsgInfo( Saying )
   RETURN(.F.)
END TRY

oRsLetter := TOleAuto():New( "
ADODB.Recordset" )
oRsLetter:CursorType     := 1        // opendkeyset
oRsLetter:CursorLocation := 3        // local cache
oRsLetter:LockType       := 3        // lockoportunistic

cSQL := "
SELECT * FROM Letter"

TRY
  oRsLetter:Open(cSQL,xConnect )
CATCH oErr
   MsgInfo( "
Error in Opening LETTER table" )
   RETURN(.F.)
END TRY

If oRsLetter:Eof
   Saying := "
Sorry .. there are No Records to View"
   Msginfo( Saying )
   oRsLetter:CLose()
   Return(.t.)
Endif

_LettView( "
E", oRsLetter )

oRsLetter:CLose()

Return(nil)


//----------------------
Static FUNC _LettView( cMODE,oRsLetter )

LOCAL SAYING, oDlg, lOK, oBmp
LOCAL lOK1,oButt1,oButt2,oButt3
Local cName,cLetter,dEntryDate,cEntryBy
Local oName,oLetter,oEntryDate,oEntryBy
Local cTitle

Local cSql,oErr

Local oSay1,oSay2,oSay3
Local oFontB,cRtPrompt


IF oRsLetter:EOF .and. ( cMODE = "
E" .or. cMode = "V" )
   SAYING := "
SORRY ... Before you can EDIT or VIEW a record you have to ADD "
   SAYING += "
one First"
   MsgInfo( SAYING )

   RETURN(.F.)
ENDIF

_DarkGreyGrad()

oFontB    := TFont():New("
Ms Sans Serif",,-6,.F.,.T. ,,,,.F. )

IF cMODE = "
A"

   cName        := space(100)
   cLetter      := "
"
   dEntryDate   := Date()
   cEntryBy     := "
HillaryC"

ELSE

   cName        := If(empty(oRsLetter:Fields("
Title"):Value),space(100),;
                            oRsLetter:Fields("
Title"):Value)
   cLetter      := oRsLetter:Fields("
BODY"):Value
   dEntryDate   := If(empty(oRsLetter:Fields("
EntryDate"):Value), ctod(""),;
                          _TtoDate(oRsLetter:Fields("
EntryDate"):Value))
   cEntryBy     := If(empty(oRsLetter:Fields("
EntryBy"):Value),space(25),;
                    substr(alltrim(oRsLetter:Fields("
EntryBy"):Value)+space(25),1,25))

ENDIF

cTITLE := "
Mail Merge Letter Information"
DO CASE
CASE cMODE = "
A"
     cTITLE := "
Mail Merge Letter Information   ADD"
CASE cMODE = "
E"
     cTITLE := "
Mail Merge Letter Information  EDIT"
CASE cMODE = "
V"
     cTITLE := "
Mail Merge Letter Information  VIEW"
ENDCASE

lOK   := .F.

*DEFINE BITMAP oBmp RESOURCE "
LETTVIEW"
DEFINE DIALOG oDlg RESOURCE "
LETTVIEW" ;
       TITLE cTITLE



    REDEFINE SAY oSay1 ID 119 OF oDlg UPDATE  // letter name
             oSay1:SetFont( oFontB )
    REDEFINE SAY oSay2 ID 122 OF oDlg UPDATE   // associated letter
             oSay2:SetFont( oFontB )
             oSay2:SetColor(nRgb(7,7,224))    // blue
    REDEFINE SAY oSay3 ID 126 OF oDlg UPDATE  // last update
             oSay3:SetFont( oFontB )

IF cMODE = "
A" .or. cMODE = "E"

   REDEFINE GET oName              VAR cName             ID 120 of oDlg UPDATE

ELSE     // view

   REDEFINE GET oName              VAR cName             ID 120 of oDlg COLOR CLR_BLACK, 15987697 READONLY

ENDIF

REDEFINE GET oEntryBy   VAR cEntryBy   ID 127 of oDlg COLOR CLR_BLACK, 15987697 READONLY
REDEFINE GET oEntryDate VAR dEntryDate ID 128 of oDlg COLOR CLR_BLACK, 15987697 READONLY

cRtPrompt := "
Create Letter"
nLen  := Len( cLetter )

Do Case
Case nLen = 0
     cRtPrompt := "
Create Letter"
Case nLen > 0
     cRtPrompt := "
View Letter"
End Case

REDEFINE BTNBMP oButt3 PROMPT cRtPrompt ID 123 of oDlg LEFT 2007 ;  // letter
         RESOURCE "
LETTER32";
         ACTION ( _ViewMemo( cMode, Substr(cName,1,30), oRsLetter, oButt3, @cRtPrompt, @cLetter, oFontB ));
        GRADIENT _DarkGreyButtonGrad()


REDEFINE BTNBMP oButt1 ID 150 of oDlg   ;     // ok
         RESOURCE "
OK", "DOK", "DOK" ;
         PROMPT "
&Ok" LEFT 2007;
         ACTION ( IF(cMODE = "
V",lOK := .T. , lOK := _busrules( cMODE, cName,oName ) ), ;
                  IF(cMODE = "
V",lOK := .T. , If(lOK = .T., _doit( cMODE,cName,cLetter,oRsLetter ),)),;
                                               If(lOK = .T., oDlg:END(), ) )

REDEFINE BTNBMP oButt2 ID 160 of oDlg   ;    // cancel
         RESOURCE "
CANCEL", "DCANCEL", "DCANCEL" ;
         PROMPT "
&Cancel" LEFT 2007;
         ACTION ( lOk := .f., oDlg:END())


ACTIVATE DIALOG oDlg ;
         VALID (!GETKEYSTATE( 27 ))// ;  // do not allow esc key here
      *   ON INIT( NIL ) ; // _Hidum( oSay2,oButt3,cInvoiceType));
      *   ON PAINT (PalBmpDraw( hDC, 0, 0, oBmp:hBitmap ))

_LightGreyGrad()


lOK1 := lOK
Release oFontB
*oBmp:End()

RETURN( lOK1 )

//---------------------------------
Static FUNC _DoIt( cMODE,cName,cLetter,oRsLetter )

LOCAL nEID,nEid1,nUpdated

IF cMODE = "
V"
   RETURN(.T.)
ENDIF

IF cMODE = "
A"
   nEid := _GenEid()
   If nEid = -1
      Saying := "
Error in Creating Unique Row Id"
      MsgInfo( Saying )
      Return(.f.)
   Endif

   oRsLetter:AddNew()
   oRsLetter:Fields("
LetterEid"):Value    := nEid

ENDIF

cName := _UpperLower(cName)

oRsLetter:Fields("
Title"):Value       := cName
*oRsLetter:Fields("
Body"):Value        := cLetter

oRsLetter:Fields("
EntryBy"):Value     := "Admin"
oRsLetter:Fields("
EntryDate"):Value   := Date()

oRsLetter:Update()

IF cMODE = "
A"
   oRsLetter:Sort( "
Title" )
   oRsLetter:MoveFirst()
   oRsLetter:Find( "
LetterEid = "+lTrim(Str(nEid)) )
ENDIF


RETURN(NIL)

//-------------------
Static Func _GenEid()

LOCAL nRAND
LOCAL oRs, cSQL, oERR

oRs:= TOleAuto():New( "
ADODB.Recordset" )
oRs:CursorType     := 1        // opendkeyset
oRs:CursorLocation := 3        // local cache
oRs:LockType       := 3        // lockoportunistic

cSQL := "
SELECT [LetterEid] from [Letter]"

TRY
   oRs:Open( cSQL,xCONNECT )
CATCH oErr
   MsgInfo( "
Error in Opening LETTER table to Create Unique EID" )
   RETURN(-1)
END TRY

DO WHILE .T.

   nRAND := nRANDOM(100000000)

   // 1 is reserved and 0 is a null key //

   IF nRAND = 1 .or. nRAND = 0 .or. nRAND = NIL
      LOOP
   ENDIF

   IF oRs:eof
   ELSE
      oRs:MoveFirst()
      oRs:Find("
LetterEid = "+ltrim(str(nRand)) )
   ENDIF

   IF oRs:eof
      EXIT
   ELSE
      LOOP
   ENDIF

   EXIT

ENDDO

oRs:Close()
oRs := nil

RETURN( nRAND )

//-------------------------
*Static Func _Hidum( oSay2,oButt3,cInvoiceType)
*
*If UPPER( cInvoiceType ) = "
RETURNS"
*Else
*   oSay2:Hide()
*   oButt3:Hide()
*Endif
*
*Return(.t.)

//---------------------------------
Static FUNC _BusRules( cMODE,cName,oName  )

LOCAL SAYING

If cName = "
 "
   SAYING := "
SORRY .. LETTER Name is a Required Field"
   MsgInfo( SAYING )
   oName:SetFocus()
   RETURN(.F.)
ENDIF

RETURN(.T.)

//-----------------------------
Static FUNC _ViewMemo( cMODE, cTitle, oRsLetter, oButt3, cRtPrompt, cLetter, oFontb )

Local SAYING, oUSERS
Local oRTF, cRTF, oBtn1,oBtn2,oBtn3
Local lOk,nLen,cOldMemo
Local oSay1,oSay2,xGrad



Lok      := .f.
cOldMemo := cLetter
xGrad    := { { .50, nRGB( 216, 216, 216 ), nRGB( 255, 255, 255 ) } }


If empty( cTitle )
   cTitle := "
Text Viewer"
Endif

Do Case
Case cMode = "
E"
     cTITLE := cTitle +"
    EDIT"
Case cMode = "
A"
     cTITLE := cTitle +"
     ADD"
Case cMode = "
V"
     cTITLE := cTitle +"
    VIEW"
EndCase

cRtf := cLetter

_LightGreyGrad()
*SetDlgGradient()  // reset to blank

DEFINE DIALOG oUSERS RESOURCE "
LETTER" ;
       TITLE cTITLE              ;

       REDEFINE SAY oSay1 ID 125 OF oUsers UPDATE     // double click
       oSay1:SetFont( oFontB )


       REDEFINE SAY oSay2 ID 126 OF oUsers UPDATE     // double click
       oSay2:SetFont( oFontB )
       oSay2:SetColor( nRgb(7,7,224)) // blue


       IF cMODE = "
E" .or. cMode = "A"

          REDEFINE RICHEDIT5 oRtf VAR cRtf ID 130 of oUSERS //UPDATE

       ELSE     // view

          REDEFINE RICHEDIT5 oRtf VAR cRtf ID 130 of oUSERS //READONLY //COLOR CLR_BLACK, 15987697 READONLY
          oRtf:SetReadOnly( .T. )

       ENDIF

     *  oRTf:LoadRTF( cRtf )
       oRtf:SetText( cRtf )
       oRtf:bGotFocus = { || oRtf:SetSel( 0, 0 ) }


       REDEFINE BTNBMP oBtn1 ID 111 of oUSERS   ;     // ok
         RESOURCE "
OK", "DOK", "DOK" ;
         PROMPT "
&Ok" LEFT 2007;
         ACTION ( lOk := .t.,;
                  If( lOk = .t., (cLetter := oRtf:GetText(),oRsLetter:Fields("
Body"):Value := cLetter,;
                                  oRsLetter:Update()),  ),;
                  If( lOk = .t., oUSERS:END(),)  )

         * If( lOk = .t., (cLetter := oRtf:SaveAsRTF(),oRsLetter:Fields("
Body"):Value := cLetter,;
         *                         oRsLetter:Update()),  ),;
         *         If( lOk = .t., oUSERS:END(),)  )


       REDEFINE BTNBMP oBtn2 ID 112 of oUSERS   ;    // cancel
         RESOURCE "
CANCEL", "DCANCEL", "DCANCEL" ;
         PROMPT "
&Cancel" LEFT 2007;
         ACTION (lOk := .f., oUSERS:END())


       REDEFINE BTNBMP oBtn3 ID 113 of oUSERS   ;    // test print
         RESOURCE "
PRINT25" ;
         PROMPT "
Test"+CRLF+"Print" LEFT 2007;
         ACTION ( oRtf:Preview( cRtf ) )

         oUsers:bResized = { | nSizeType, nWidth, nHeight | _ResizeControls( nSizeType, nWidth, nHeight, oUsers )}

ACTIVATE DIALOG oUSERS  ;
     ON INIT ( oUsers:Move(100,250) );
     ON PAINT ( GradientFill( hDC, 0, 0, oUsers:nHeight, oUsers:nWidth, xGrad, .T. ));     // note GradientFill
     VALID (!GETKEYSTATE( 27 )) ;  // do not allow esc key here

If cMode = "
V"
   cLetter := cOldMemo
Endif

If lOk = .t.
   nLen  := Len( cLetter )

   Do Case
   Case nLen = 0
        cRtPrompt := "
Create Letter"
   Case nLen > 0
        cRtPrompt := "
View Letter"
   End Case

   oButt3:cCAPTION := cRtPrompt
   * oBtn3:SetColor( "
R+/W*" )
   oButt3:ReFresh()
ENdif

_LightGreyGrad()

RETURN( NIL )

//-------------------------
Static Func _ResizeControls( nSizeType, nWidth, nHeight, oUsers )

*xbrowse(oUsers:aControls)
                                                            // 185
if nSizeType = 0 //SIZE_MAXIMIZED         //nWidth - 60    nHeight -30
   oUsers:aControls[ 3  ]:SetSize(   , nHeight -30  ) //txbrowse
endif

Return(nil)

//------------------
Static Func _LightGreyGrad()

SetDlgGradient( { { .50, nRGB( 216, 216, 216 ), nRGB( 255, 255, 255 ) } } )
Return(nil)

//--------------------
Static Func _DarkGreyGrad()

SetDlgGradient( { { 0.87, 16777215, 11513775 },{ 0.87,11513775, 16777215 }})
Return(nil)

//-------------------------------
Static Func _TtoDate( tDate )

If empty( tDate)
   Return( ctod("
00/00/00"))
Endif

If ValType( tDate ) = "
D"
   Return(tDate )
Endif

Return( stod( substr( ttos( tDate ), 1, 8 ) ))

//-------------------
Static Func _DarkGreyButtonGrad()

// 2010 grey button skin

Local bGrad

bGrad := { | lInvert | If( ! lInvert, ;
         { { 1, nRGB( 255, 255, 255 ), nRGB( 64, 64, 64 ) } }, ;
         { { 1/3, nRGB( 255, 253, 222 ), nRGB( 255, 231, 151 ) }, ;
         { 2/3, nRGB( 255, 215,  84 ), nRGB( 255, 233, 162 ) } } ) }

Return( bGrad )

//------------------
Func _UpperLower( cText )

Local nLen,i,cField

nLen  := len( cText )

For i = 1 to Len(cText)

   If i = 1
      cField := upper(substr(cText,i,1))
      Loop
   Endif

   // check for multiple words
   // use space as the delimeter

   If substr(cText,i,1) = space(1) // found a space in between words
      i++
      cField := cField+"
"+upper(substr(cText,i,1))
      loop
   Else
      cField := cField+lower(substr(cText,i,1))
   Endif

Next

cText := cField

Return(cText)

// End Main.prg



Letter.Rc
Code: Select all  Expand view

// Generated by ResEdit 1.6.6
// Copyright (C) 2006-2015
// http://www.resedit.net

#include <windows.h>
#include <commctrl.h>
//#include "resource.h"
//#define WC_STATIC L"Static"
//#define MONTHCAL_CLASS "SysMonthCal32"
//#define DATETIMEPICK_CLASS "SysDateTimePick32"




//
// Dialog resources
//
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
LETTER DIALOG 13, 35, 455, 303
STYLE DS_MODALFRAME | DS_SETFONT | WS_CAPTION | WS_POPUP | WS_THICKFRAME | WS_SYSMENU
FONT 6, "MS Sans Serif"
{
    CONTROL         "", 130, "RichEdit50W", 0x50A11004, 53, 8, 394, 285, 0x00000000
    CONTROL         "Ok", 111, "TBtnBmp", 0x50010020, 5, 236, 41, 25, 0x00000000
    CONTROL         "Cancel", 112, "TBtnBmp", 0x50010020, 5, 266, 41, 25, 0x00000000
    CONTROL         "Test Print", 113, "TBtnBmp", 0x50010020, 5, 119, 41, 40, 0x00000000
    LTEXT           "Text", 125, 4, 15, 41, 12, SS_LEFT | SS_NOPREFIX, WS_EX_LEFT
    LTEXT           "Right Click to bring up additional Menu Options", 126, 4, 44, 41, 55, SS_LEFT | SS_NOPREFIX, WS_EX_LEFT
}
 


LettView.Rc
Code: Select all  Expand view

// Generated by ResEdit 1.6.6
// Copyright (C) 2006-2015
// http://www.resedit.net

#include <windows.h>
#include <commctrl.h>
//#include "resource.h"
//#define WC_STATIC L"Static"
//#define MONTHCAL_CLASS "SysMonthCal32"
//#define DATETIMEPICK_CLASS "SysDateTimePick32"

//
// Dialog resources
//
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
LETTVIEW DIALOG 110, 125, 306, 173
STYLE DS_SETFONT | WS_CAPTION | WS_POPUP
FONT 6, "MS Sans Serif"
{
    EDITTEXT        120, 3, 50, 230, 12, ES_AUTOHSCROLL, WS_EX_LEFT
    CONTROL         "&Ok", 150, "TBtnBmp", 0x50010020, 202, 115, 41, 25, 0x00000000
    CONTROL         "&Cancel", 160, "TBtnBmp", 0x50010020, 247, 115, 41, 25, 0x00000000
    EDITTEXT        127, 6, 113, 65, 12, WS_DISABLED | NOT WS_TABSTOP, WS_EX_LEFT
    EDITTEXT        128, 6, 128, 65, 12, WS_DISABLED | NOT WS_TABSTOP, WS_EX_LEFT
    LTEXT           "Letter Name", 119, 6, 35, 61, 12, SS_LEFT | SS_NOPREFIX, WS_EX_LEFT
    LTEXT           "Last Update", 126, 6, 99, 58, 12, SS_LEFT | SS_NOPREFIX, WS_EX_LEFT
    LTEXT           "Associated Mail Merge Letter", 122, 136, 71, 57, 32, SS_LEFT | SS_NOPREFIX, WS_EX_LEFT
    CONTROL         "Letter", 123, "TBtnBmp", 0x50010020, 202, 71, 85, 34, 0x00000000
}
 


Thanks
Rick Lipkin
User avatar
Rick Lipkin
 
Posts: 2663
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: RichType Print

Postby Rick Lipkin » Fri May 12, 2017 12:07 am

To All

Cristobol found the solution ... here are the changes that needed to be made ... Thanks Cristobol !!
Code: Select all  Expand view

       //oRTf:LoadRTF( cRtf )
       //oRtf:SetText( cRtf )   <-- rem out
       oRtf:bGotFocus = { || oRtf:SetSel( 0, 0 ) }


       REDEFINE BTNBMP oBtn1 ID 111 of oUSERS   ;     // ok
         RESOURCE "OK", "DOK", "DOK" ;
         PROMPT "&Ok" LEFT 2007;
         ACTION ( lOk := .t.,;
          If( lOk = .t., (cLetter := oRtf:SaveAsRTF(),oRsLetter:Fields("Body"):Value := cLetter,;  // made change here as well
                                  oRsLetter:Update()),  ),;
                  If( lOk = .t., oUSERS:END(),)  )

 
User avatar
Rick Lipkin
 
Posts: 2663
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: RichType Print

Postby Enrico Maria Giordano » Fri May 12, 2017 7:38 am

Great! Many thanks to "Cristobal" not "Cristobol". :-D

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: RichType Print ( solved )

Postby Rick Lipkin » Fri May 12, 2017 1:23 pm

Cristobol

Thanks for all your Help !!

Rick Lipkin
User avatar
Rick Lipkin
 
Posts: 2663
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: RichType Print

Postby Rick Lipkin » Fri May 12, 2017 5:44 pm

Cristobol

One request change to both tRichText Classes .. Please add the MODAL clause to the Preview Method .. in my tests the preview slides behind non modal dialogs and gets hidden.

Thanks
Rick Lipkin


Code: Select all  Expand view


METHOD Preview( cName ) CLASS TRichEdit5

   local aMargins := PageGetMargins()
   local nLen     := ::Len()
   local nPrint   := 0
   local oPrn
   //local aPrinters := aGetPrinters()

   DEFAULT cName := cFileNoExt( ::cFileName ) + " Report" //"FWH RichEdit Report"


      PRINT oPrn NAME cName PREVIEW MODAL   // add MODAL here

      if Empty( oPrn:hDC )
         MsgStop( "Printer not ready!" )
         return nil
      endif

      CursorWait()

      AEval( aMargins, { | x, y | aMargins[ y ] := x * 1440 / 2540 } )

      do while nPrint < nLen
         PAGE
            nPrint := REPreview5( ::hWnd, oPrn:hDC, oPrn:hDCOut, aMargins, nPrint )
         ENDPAGE
      enddo

      CursorArrow()

   ENDPRINT

return nil


 
User avatar
Rick Lipkin
 
Posts: 2663
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: RichType Print

Postby cnavarro » Fri May 12, 2017 6:59 pm

Rick, change your CLASS
Code: Select all  Expand view


METHOD Preview( cName, lModal ) CLASS TRichEdit5

   local aMargins := PageGetMargins()
   local nLen     := ::Len()
   local nPrint   := 0
   local oPrn
   //local aPrinters := aGetPrinters()

   DEFAULT cName   := cFileNoExt( ::cFileName ) + " Report" //"FWH RichEdit Report"
   DEFAULT lModal  := .F.

   if lModal
      PRINT oPrn NAME cName PREVIEW MODAL  
   else
      PRINT oPrn NAME cName PREVIEW
   endif


 
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
User avatar
cnavarro
 
Posts: 6541
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Previous

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 49 guests