Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Formatting text retrieved from a memo field
Message
 
À
02/03/2003 00:09:27
Bruno Di Lalla
Bdl Computer Consulting
Greely, Ontario, Canada
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00760074
Message ID:
00760115
Vues:
15
Hi Burno,

I have use the MS Rich Text Control to develope help files for an application. The Rich Text ActiveX Control is bound to an ordinary memo field.

I put the following code into the edit button of the form:
************************** Edit/Revert Button When method  *************************

If ("WZUNDO.BMP"$UPPER(thisform.buttonset1.cmdEdit.picture)) && Edit Button Clicked

    ********************************************************************************
    * When the edit button is clicked, use =strtofile to put the content of the    *
    * memo field into temp.rtf file.  Then call the default Rich Text File         *
    * handler to open the file for editing or printing. The Default Rich Text File *
    * handler is usually either word or wordpad.  I used "Microsoft Rich Textbox   *
    * activeX control" to display the rich text in thisform, using the memo field  *
    * as the controlsource of the Rich Textbox Control.  LelandJ                   *
    ********************************************************************************

    thisform.fldname.Enabled=.T.
    thisform.qfname.Enabled=.T.
    thisform.dictdata.backcolor = RGB(192,255,255)  &&ActiveX Rich Text control
    thisform.dictdata.Locked = .F.
    thisform.dictdata.enabled=.T.

    the_path=Sys(5)+Sys(2003)+'\temp.rtf'
   
    SELECT pshelp

    SET SAFETY off

   =STRTOFILE(ALLTRIM(pshelp.dictdata),the_path,0)

    SET SAFETY ON

    DECLARE INTEGER ShellExecute IN shell32.dll ; 
      INTEGER hndWin, ; 
      STRING cAction, ; 
      STRING cFileName, ; 
      STRING cParams, ;  
      STRING cDir, ; 
      INTEGER nShowWin

    cFileName = the_path

    cAction = "open"
    
    ShellExecute(0,cAction,cFileName,"","",1)

ELSE  && Revert Button was clicked

    thisform.fldname.Enabled=.F.

    thisform.qfname.Enabled=.F.

    thisform.dictdata.backcolor = RGB(255,255,255)

    thisform.dictdata.Locked = .T.

Endif
Return
The following code I put in the Save button of the form:
*********************  Add/Save button vaild method  ***************

*************************************************************************
* When the user is finished editing the temp.rtf with word or wordpad,  *
* the temp.rtf is saved.  Then word or wordpad is closed returning      *
* control back to thisform.  When the user clicks on the save button of *
* thisform, =FILETOSTR copies the temp.rtf to memory and it is then     *
* placed back into the memo field.                                      *
*************************************************************************

If ("WZSAVE.BMP"$Upper(Thisform.buttonset1.cmdAdd.Picture))  && the Add button was clicked

    thisform.dictdata.change()
    thisform.dictdata.backcolor = RGB(192,255,255)
    thisform.dictdata.locked = .F.
    thisform.dictdata.Enabled=.T.

ELSE  && user clicked the save button

    SELECT pshelp  

    the_path=Sys(5)+Sys(2003)+'\temp.rtf'
   
    IF FILE(the_path)
        thisform.dictdata.textRTF = FILETOSTR(the_path)
    ENDIF

    Thisform.fldname.Enabled=.T.
    Thisform.qfname.Enabled=.T.

    thisform.dictdata.backcolor = RGB(255,255,255)

    thisform.dictdata.Parent.Refresh
    
    thisform.dictdata.locked = .T.

Endif
Return
Leland F. Jackson, CPA
Software - Master (TM)
smvfp@mail.smvfp.com
Software Master TM
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform