Page 1 of 1

Error RICHEDIT en Formulario DIALOG

Posted: Wed Apr 01, 2020 11:00 pm
by jnavas
Saludos
Necesito crear Formulario Dialog con Control TRICHEDIT necesario para pegar imagenes, textos, colores y afines-


Called from: .\source\classes\DIALOG.PRG => CREATEDLGERROR( 561 )
Called from: .\source\classes\DIALOG.PRG => TDIALOG:ACTIVATE( 299 )
Called from: dpcrpe.prg => SAVEPASTE( 2105 )
Called from: dpcrpe.prg => MAIN( 285 )

Code: Select all


FUNCTION SAVEPASTE(cFileMem)
   LOCAL oDlg,oMemo,cMemo:=SPACE(10)

   PRIVATE n_Top   :=130
   PRIVATE n_Left  :=0
   PRIVATE n_Width :=600
   PRIVATE n_Height:=450

   RESTORE FROM (cFileMem) ADDI

   DEFINE DIALOG oDlg TITLE "Pegar contenido del ClipBoard"

   @ 0,0 RICHEDIT oMemo VAR cMemo OF oDlg

   ACTIVATE DIALOG oDlg CENTERED ;
          ON INIT (oDlg:Move(n_Top,n_Left),;
                   oDlg:SetSize(n_Width,n_Height),;
                   DLGINICIO(oDlg),.T.)

RETURN .T.

FUNCTION DLGINICIO(oDlg)
   LOCAL oCursor,oBar,oBtn

   DEFINE CURSOR oCursor HAND
   DEFINE BUTTONBAR oBar SIZE 52-15,60-15 OF oDlg 3D CURSOR oCursor

   DEFINE BUTTON oBtn;
          OF oBar;
          NOBORDER;
          FILENAME "BITMAPS\XSAVE.BMP";
          ACTION MsgAlert("GUARDAR")

   DEFINE BUTTON oBtn;
          OF oBar;
          NOBORDER;
          FILENAME "BITMAPS\PASTE.BMP";
          ACTION MsgAlert("PASTE")

   DEFINE BUTTON oBtn;
          OF oBar;
          NOBORDER;
          FILENAME "BITMAPS\XSALIR.BMP";
          ACTION oDlg:End()

   oBar:SetColor(CLR_BLACK,15724527)

   AEVAL(oBar:aControls,{|o,n|o:SetColor(CLR_BLACK,15724527)})

RETURN .F.


 

Re: Error RICHEDIT en Formulario DIALOG

Posted: Thu Apr 02, 2020 2:11 am
by cnavarro
Esto funciona perfectamente, si le das al botón derecho del ratón te aparece el menu contextual o con SHIFT+INSERT o CTRL+V para pegar como siempre

Code: Select all

//
// FWH New Class RichEdit5 sample
// 

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

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

function Main()

   local oDlg, oRich
   local lSyntaxHL := .f.
   local cRTF   := ""
   local cText2 := ""
   local cText3 := ""
   
   cText2  += "{\rtf1\ansi\deff0"
   cText2  += "{\colortbl;\red0\green0\blue0;\red255\green0\blue0;}"
   cText2  += "This line is the default color\line"
   cText2  += "\cf2"
   cText2  += "This line is red\line"
   cText2  += "\cf1"
   cText2  += "This line is the default color"
   cText2  += "}"
   //cRtf    := cText2
   
   //TEXT INTO cText3
   cText3  += "{\rtf1\ansi\ansicpg1252\deff0\nouicompat\deflang3082{\fonttbl{\f0\fnil\fcharset0 Arial;}{\f1\fnil\fcharset2 Webdings;}{\f2\fnil\fcharset0 MS Shell Dlg 2;}}"
   cText3  += "{\colortbl ;\red255\green0\blue0;\red0\green0\blue0;}"
   cText3  += "{\*\generator Riched20 10.0.14393}\viewkind4\uc1"
   cText3  += "\pard\fs20{\pict{\*\picprop{\sp{\sn wzDescription}{\sv Image}}{\sp{\sn posv}{\sv 1}}"
   cText3  += "}\pngblip\picw847\pich847\picwgoal480\pichgoal480"
   cText3  += "89504e470d0a1a0a0000000d4948445200000020000000200802000000fc18eda3000000017352"
   cText3  += "474200aece1ce90000000467414d410000b18f0bfc6105000000097048597300000ec300000ec3"
   cText3  += "01c76fa8640000014949444154484bed95c1ae453010866f89b520120b5ec1fbbf8667602111ec"
   cText3  += "6ddcdff97b05ad963a77e75bcce9b439f3b7d3ce10f33cffec89e318b6280aba2a755dc30ec340"
   cText3  += "d78c277ff718a203ae621f4208ce18d09f0021aaaa92fe1eae728ca340a3ef7bba5af427b0c22c"
   cText3  += "4109fb634acf7014004dd3c042c39c287781200898c63ccf0d87701768db1676cdd599c6a34b3e"
   cText3  += "00b1711c0f016f0b00ed66f11708f8bedf759d9cfa703b45b85294988a5c56b82da09ed88cfb25"
   cText3  += "5fe415b0f20a585904ae7c372eb22d638695ad82d5bf2aa141f26342d70a82a055b081d3854579"
   cText3  += "6759b608244982885c73e0b0953514e6a121a2283aeb8e576014e97cd8b65bac7a4f2e003941f4"
   cText3  += "344de96a4389b22ce5d009ec518efe80cc36e14f05acbc956cc59fa6290c43e97d1b3cb3ff3d01"
   cText3  += "aad8c343569fda579095ccbe816e01fba4616ce18e97e842fc023588aa818e87e6910000000049"
   cText3  += "454e44ae426082"
   cText3  += "}\par"
   cText3  += "\par"
   cText3  += "This line is the default color\line\cf1 This line is red\line\cf2 This line is the default color\par"
   cText3  += "\par"
   cText3  += "\cf0\f1\fs18\'9f\f2\fs17\par"
   cText3  += "\f0\fs20\par"
   cText3  += "}"
   //ENDTEXT

   DEFINE DIALOG oDlg NAME "Test"

   REDEFINE RICHEDIT5 oRich VAR cRTF ID 100 OF oDlg HIGHLIGHT
   //oRich:lHighLight = .f.
   oRich:bGotFocus = { || oRich:SetSel( 0, 0 ) }
   
   REDEFINE BUTTON ID 110 ;
      ACTION oRich:SetText( MemoRead( "TestRich.prg" ) )

   REDEFINE CHECKBOX lSyntaxHL ID 115 OF oDlg ;
      ON CHANGE ( oRich:lHighLight := lSyntaxHL,;
                  oRich:SetText( oRich:GetText() ) )

   REDEFINE BUTTON ID 120 ;
      ACTION oRich:LoadFromRTFFile( cGetFile( "RTF file (*.rtf) | *.rtf" ) )

   REDEFINE BUTTON ID 130 ;
      ACTION oRich:SaveToRTFFile( cGetFile( "RTF file (*.rtf) | *.rtf",;
                                  "Please write a filename", "test" ) )

   REDEFINE BUTTON ID 998 ACTION ( oRich:GotoLine( 2 ) )

   ACTIVATE DIALOG oDlg CENTERED ON INIT ( oRich:LoadRTF( cText3 )  ) //; cText2
      // ON INIT oRich:AutoURLDetect( .t. )

   //FreeLibrary( hRichDLL )

return nil

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

 

Re: Error RICHEDIT en Formulario DIALOG

Posted: Thu Apr 02, 2020 11:43 am
by jnavas
Navarro
Saludos y agradecido por tu aporte,
En mi caso no trabajo con recursos.

Re: Error RICHEDIT en Formulario DIALOG

Posted: Thu Apr 02, 2020 12:08 pm
by cnavarro
Juan en tu carpeta Samples de Fivewin hay varios ejemplos: TestRtf.prg y TestRtf5.prg por ejemplo