Richedit on a dialog

Re: Richedit on a dialog

Postby Silvio.Falconi » Wed Apr 20, 2016 11:28 am

Please try it

Code: Select all  Expand view
   #include "Fivewin.ch"
    #include "constant.ch"
    #include "ttitle.ch"
    #include "richedit.ch"


    #define  LIGHTCYAN    nRGB( 203, 225, 252 )


    REQUEST DBFCDX
    REQUEST DBFFPT
    EXTERNAL ORDKEYNO,ORDKEYCOUNT,ORDCREATE,ORDKEYGOTO

    Function Test()

       Local  nBottom   := 29.2
       Local  nRight    :=  58
       Local  nWidth    :=  Max( nRight * DLG_CHARPIX_W, 180 )
       Local  nHeight   :=  nBottom * DLG_CHARPIX_H


        Local cDlgTitle  :="Family"
        Local hDLL


        Local oDlgModelli,oBarMemo
       Local aGet[5],oSay[2]
       Local oFontmodelli,oFontBoldModelli

       Local oLbx
       Local cMessage := space(200)
       Local cSubject := space(60)
       Local cModello := space(60)
       Local aBrowse,i, oCol



     RddSetDefault( "DBFCDX" )


      Create_Archive_Modelli_mail()


      USE MAILMOD ALIAS MM


       DEFINE FONT oFontmodelli NAME 'Tahoma' SIZE 0, -12
       DEFINE FONT oFontBoldModelli NAME 'Tahoma' SIZE 0, -12 BOLD



     DEFINE DIALOG oDlgModelli          ;
             SIZE nWidth, nHeight   PIXEL   ;
             TITLE cDlgTitle


        oDlgModelli:lHelpIcon := .F.
        oDlgModelli:nStyle    := nOr( WS_OVERLAPPED,WS_THICKFRAME,WS_SYSMENU,WS_MAXIMIZEBOX,   0  )





      @ 42, 1 XBROWSE  oLbx OF oDlgModelli ;
          SIZE 100 ,oDlgModelli:nBottom-150 PIXEL NOBORDER


               aBrowse   := { { { ||MM->MAILNAME}, i18n("Nome Modello"), 50, }}


     FOR i := 1 TO Len(aBrowse)
          oCol := oLbx:AddCol()
         oCol:bEditValue := aBrowse[ i, 1 ]
       *   oCol:bStrData := aBrowse[ i, 1 ]
          oCol:cHeader  := aBrowse[ i, 2 ]
          oCol:nWidth   := aBrowse[ i, 3 ]
           if !Empty(aBrowse[ i, 4 ])
                oCol:cEditPicture:=aBrowse[ i, 4 ]
             Endif

       NEXT




       oLbx:nStretchCol           := -1
       oLbx:nMarqueeStyle       := MARQSTYLE_HIGHLWIN7 //MARQSTYLE_HIGHLROW
       oLbx:nColDividerStyle    := LINESTYLE_LIGHTGRAY
       oLbx:lColDividerComplete := .t.
       oLbx:lRecordSelector     := .f.
       oLbx:lHScroll            := .f.
       oLbx:CreateFromCode()

        oLbx:bChange  := { || Rinfresca_get(aGet,"MM") }




          @ 45,oLbx:nWidth+10 SAY oSay[1] Prompt  "Nome modello:" of oDlgModelli  size 80,10 PIXEL FONT oFontBoldModelli  COLOR CLR_BLACK
          @ 55,oLbx:nWidth+10 GET aGet[1] VAR MM->MAILNAME  size 115,10 PIXEL of oDlgModelli FONT oFontmodelli  UPDATE
          @ 66,oLbx:nWidth+10 SAY oSay[2] Prompt "Oggetto:" of oDlgModelli  size 80,10 PIXEL FONT oFontBoldModelli  COLOR CLR_BLACK
          @ 76,oLbx:nWidth+10 GET aGet[2] VAR MM->SUBJECT  size 115,10 PIXEL of oDlgModelli FONT oFontmodelli  UPDATE

           hDLL  = LoadLibrary( 'riched20.dll' )
          @ 90,110  RICHEDIT aGet[3] VAR MM->MESSAGE of oDlgModelli PIXEL SIZE 100,100




      oDlgModelli:bResized := {||Rinfresca_oDlgModelli(oDlgModelli,oLbx,oSay,aGet ,oBarMemo) }




      ACTIVATE DIALOG oDlgModelli  CENTERED;
        ON INIT  BuildRichEditBar( oDlgModelli, aGet[3],oBarMemo )

        oFontmodelli:Release()
        oFontBoldModelli:Release()

          if hDLL != nil
          FreeLibrary( hDLL )
       endif

       return nil


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


     static function BuildRichEditBar( oWnd, oRtf, oBarMemo )

       local oBtn, oBullet, oBold, oItalic, oNumber, oUnderline, oCursor
       local lBold := .F., ;
             lItalic := .F., ;
             lUnderline := .F.,;
             lBullet := .F.,;
             lNumber := .F.



                DEFINE CURSOR oCursor HAND


          @ oRtf:nTop,oRtf:nLeft BUTTONBAR oBarMemo  ;
                 SIZE oRtf:nWidth+100,27  3D;
                 BUTTONSIZE  26, 27;
                 OF oWnd  ;
                 CURSOR oCursor

              DEFINE BUTTON oBtn OF oBarMemo ;
              MESSAGE "Create a new file" TOOLTIP "New" NOBORDER ;
              ACTION oRTF:SetText( "" )

       oBtn:hBitmap1 = FWBitmap( "new16" )

       DEFINE BUTTON oBtn OF oBarMemo ;
              MESSAGE "Open a file" TOOLTIP "Open" NOBORDER ;
              ACTION Open()

       oBtn:hBitmap1 = FWBitmap( "open16" )

       DEFINE BUTTON oBtn OF oBarMemo ;
              MESSAGE "Save a file" TOOLTIP "Save" NOBORDER ;
              ACTION Save()

       oBtn:hBitmap1 = FWBitmap( "save16" )

       DEFINE BUTTON oBtn OF oBarMemo ;
              MESSAGE "Close a file" TOOLTIP "Close" NOBORDER ;
              ACTION oWnd:End()

       oBtn:hBitmap1 = FWBitmap( "close16" )

       DEFINE BUTTON oBtn OF oBarMemo GROUP ;
              MESSAGE "Print" TOOLTIP "Print" NOBORDER ;
              ACTION ( oRTF:Print(), oRTF:SetFocus() )

       oBtn:hBitmap1 = FWBitmap( "printer16" )

       DEFINE BUTTON oBtn OF oBarMemo ;
              MESSAGE "Displays full pages" ;
              TOOLTIP "Print Preview" NOBORDER ;
              ACTION oRTF:Preview( "Class TRichEdit")

       oBtn:hBitmap1 = FWBitmap( "preview16" )

       DEFINE BUTTON oBtn OF oBarMemo GROUP ;
              MESSAGE "Search" TOOLTIP "Search" NOBORDER ;
              ACTION ( Find(), oRTF:SetFocus() )

       oBtn:hBitmap1 = FWBitmap( "search16" )

       DEFINE BUTTON oBtn OF oBarMemo GROUP ;
              MESSAGE "Cut" TOOLTIP "Cut" NOBORDER ;
              WHEN ( ! Empty( oRTF:GetSel() ) .and. ! oRTF:lReadOnly ) ;
              ACTION ( oRTF:Cut(), oRTF:SetFocus() )

       oBtn:hBitmap1 = FWBitmap( "cut16" )

       DEFINE BUTTON oBtn OF oBarMemo ;
              MESSAGE "Copy" TOOLTIP "Copy" NOBORDER ;
              WHEN ( ! Empty( oRTF:GetSel() ) ) ;
              ACTION ( oRTF:Copy(), oRTF:SetFocus() )

       oBtn:hBitmap1 = FWBitmap( "copy16" )

       DEFINE BUTTON oBtn OF oBarMemo ;
              MESSAGE "Paste" TOOLTIP "Paste" NOBORDER ;
              WHEN ( /* ! Empty( oClp:GetText() ) .and. */ ! oRTF:lReadOnly ) ;
              ACTION ( oRTF:Paste(), oRTF:SetFocus() )

       oBtn:hBitmap1 = FWBitmap( "paste16" )

       DEFINE BUTTON oBtn OF oBarMemo GROUP ;
              MESSAGE "Undo" TOOLTIP "Undo" NOBORDER ;
              WHEN ( oRTF:SendMsg( EM_CANUNDO ) != 0 ) ;
              ACTION ( oRTF:Undo(), oRTF:SetFocus() )

       oBtn:hBitmap1 = FWBitmap( "undo16" )

       DEFINE BUTTON oBtn OF oBarMemo ;
              MESSAGE "Redo" TOOLTIP "Redo" NOBORDER ;
              WHEN ( oRTF:SendMsg( EM_CANREDO ) != 0 ) ;
              ACTION ( oRTF:Redo(), oRTF:SetFocus() )

       oBtn:hBitmap1 = FWBitmap( "redo16" )

       DEFINE BUTTON oBold OF oBarMemo GROUP ;
              MESSAGE "Bold" TOOLTIP "Bold" NOBORDER ;
              WHEN ! oRTF:lReadOnly ;
              ACTION ( lBold := !lBold, ;
                       oBold:lPressed := lBold, ;
                       oBold:Refresh(), ;
                       oRTF:SetBold( lBold ), oRTF:SetFocus() )

       oBold:hBitmap1 = FWBitmap( "bold16" )
       oBold:Show()

       DEFINE BUTTON oItalic OF oBarMemo ;
              MESSAGE "Italic" TOOLTIP "Italic" NOBORDER ;
              WHEN ! oRTF:lReadOnly ;
              ACTION ( lItalic := !lItalic, ;
                       oItalic:lPressed := lItalic, ;
                       oItalic:Refresh(), ;
                       oRTF:SetItalic( lItalic ), oRTF:SetFocus() )

       oItalic:hBitmap1 = FWBitmap( "italic16" )
       oItalic:Show()

       DEFINE BUTTON oUnderline RESOURCE "Underline" OF oBarMemo ;
              MESSAGE "Underline" TOOLTIP "Underline" NOBORDER ;
              WHEN ! oRTF:lReadOnly ;
              ACTION ( lUnderline := !lUnderline, ;
                       oUnderline:lPressed := lUnderline, ;
                       oUnderline:Refresh(), ;
                       oRTF:SetUnderline( lUnderline ), oRTF:SetFocus() )

       oUnderline:hBitmap1 = FWBitmap( "underline16" )
       oUnderline:Show()

       DEFINE BUTTON RESOURCE "Left" OF oBarMemo GROUP ;
              MESSAGE "Align Left" TOOLTIP "Left" NOBORDER ;
              WHEN ! oRTF:lReadOnly ;
              ACTION ( oRTF:SetAlign( PFA_LEFT ), oRTF:SetFocus() )

       DEFINE BUTTON RESOURCE "Center" OF oBarMemo ;
              MESSAGE "Center" TOOLTIP "Center" NOBORDER ;
              WHEN ! oRTF:lReadOnly ;
              ACTION ( oRTF:SetAlign( PFA_CENTER ), oRTF:SetFocus() )

       DEFINE BUTTON RESOURCE "Right" OF oBarMemo ;
              MESSAGE "Align Right" TOOLTIP "Right" NOBORDER ;
              WHEN ! oRTF:lReadOnly ;
              ACTION ( oRTF:SetAlign( PFA_RIGHT ), oRTF:SetFocus() )

       DEFINE BUTTON RESOURCE "Justify" OF oBarMemo ;
              MESSAGE "Justify" TOOLTIP "Justify" NOBORDER ;
              WHEN ! oRTF:lReadOnly ;
              ACTION ( oRTF:SetAlign( PFA_JUSTIFY ), oRTF:SetFocus() )

       DEFINE BUTTON oNumber RESOURCE "Number" OF oBarMemo GROUP ;
              MESSAGE "Numbering" TOOLTIP "Numbering" NOBORDER ;
              WHEN ! oRTF:lReadOnly .AND. ! oRTF:GetBullet() ;
              ACTION ( lNumber := !lNumber, ;
                       oNumber:lPressed := lNumber, ;
                       oNumber:Refresh(), ;
                       oRTF:SetNumbering( lNumber ), oRTF:SetFocus() )

       DEFINE BUTTON oBullet RESOURCE "Bullet" OF oBarMemo ;
              MESSAGE "Bullets" TOOLTIP "Bullets" NOBORDER ;
              WHEN ! oRTF:lReadOnly .AND. ! oRTF:GetNumbering() ;
              ACTION ( lBullet := !lBullet, ;
                       oBullet:lPressed := lBullet, ;
                       oBullet:Refresh(), ;
                       oRTF:SetBullet( lBullet ), oRTF:SetFocus() )

       DEFINE BUTTON RESOURCE "Exit" OF oBarMemo GROUP ;
              MESSAGE "Exit" ACTION oWnd:End() ;
              TOOLTIP "Salir" NOBORDER

       // AEval( oBar:aControls, { |x| x:nLeft += 272, x:nRight += 272 }, 13 )

       oBarMemo:bLClicked := { || nil }
       oBarMemo:bRClicked := { || nil }

       AEval( oBarMemo:aControls, { |x| x:oCursor := oCursor } )

       return nil



       static function Open()

    return nil

    static function Save()

    return nil

    static function Find()

    return nil

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


    static Function Rinfresca_oDlgModelli(oDlg,oLbx,oSay,aGet,oBarMemo )
       Local aClient := GetClientRect ( oDlg:hWnd )





      //xBrowse
                   oLbx:nHeight := oDlg:nHeight-150
                   oLbx:nwidth  := oDlg:nwidth/2  -200
                   oLbx:refresh()




     //get /say

       oSay[1]:nLeft:= oLbx:nWidth+10
       oSay[2]:nLeft:= oLbx:nWidth+10

       aGet[1]:nLeft:= oLbx:nWidth+10
       aGet[2]:nLeft:= oLbx:nWidth+10

       aGet[3]:nTop:=aGet[2]:nTop+60
       aGet[3]:nLeft:= oLbx:nWidth+10

       aGet[3]:nwidth:= oDlg:nwidth -200
       aGet[3]:nHeight:= oDlg:nHeight-280


       aGet[3]:SetSize( aClient[ 4 ] - aGet[3]:nLeft-10, oDlg:nHeight-280)

       aGet[3]:Refresh()
       aGet[2]:SetSize( aClient[ 4 ] - aGet[2]:nLeft-10, 20)
       aGet[1]:SetSize( aClient[ 4 ] - aGet[1]:nLeft-10, 20)

       IF   oBarMemo != NIL

          oBarMemo:nTop    :=  aGet[3]:nTop-30
          oBarMemo:nRight  :=   aClient[ 4 ] - aGet[3]:nLeft-10
          oBarMemo:nleft   :=  aGet[3]:nLeft

           oBarMemo:setpos(aGet[3]:nTop-30,aGet[3]:nLeft )
           oBarMemo:Refresh()
       endif


        return nil



    //------------------------------------------------------------------------------------------//
     static   Function Create_Archive_Modelli_mail()
          Local cDir :=""

        DbCreate(cDir+'mm', {  {'MAILNAME' , 'C',  30,   0} ,;
                          {'SUBJECT'  , 'C',  30,   0} ,;
                          {'MESSAGE'  , 'M',  10,  0}}, 'DBFCDX')

         close all
          use &(cDir+'mm') new
          select mm
          if FILE(cDir+'MailMod.DBF')
             delete file &(cdir+'MailMod.cdx')
             append from &(cdir+'MailMod')
             dbcommitall()
             close all
             delete file &(cdir+'MailMod.dbf')
             delete file &(cdir+'MailMod.fpt')
          endif
          close all
          rename &(cdir+'mm.dbf') to &(cdir+'MailMod.dbf')
          rename &(cDir+'mm.fpt') to &(cDir+'MailMod.fpt')
          close all
        return nil



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

    Function Rinfresca_get(aGet,cDbf)

     Local   nRecAdd := (cDbf)->(RecNo())

       aGet[1]:ctext:=   MM->MAILNAME
       aGet[2]:ctext:=   MM->SUBJECT
       aGet[3]:ctext:=   MM->MESSAGE

       return nil





 
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 6868
Joined: Thu Oct 18, 2012 7:17 pm

Re: Richedit on a dialog

Postby Antonio Linares » Wed Apr 20, 2016 11:38 am

You missed to pass the oBarMemo by reference:

ACTIVATE DIALOG oDlgModelli CENTERED;
ON INIT BuildRichEditBar( oDlgModelli, aGet[3], @oBarMemo )
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41469
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Richedit on a dialog

Postby Silvio.Falconi » Thu Apr 21, 2016 9:35 am

thanks
and I can erase border of the bar ?
I make

@ oRtf:nTop,oRtf:nLeft BUTTONBAR oBarMemo ;
SIZE oRtf:nWidth+100,27 ;
BUTTONSIZE 26, 27;
OF oWnd ;
CURSOR oCursor

oBarMemo:lborder:= .f.


but not run ok because I see all ways the border ( on fivewin.ch the command @ x,y buutonbar buttonsize no have the param NOBORDER )

if I erase the command 3D then it show spaces with gray color as u can see here

Image
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 6868
Joined: Thu Oct 18, 2012 7:17 pm

Previous

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 106 guests