TX Text controll

This forum is for eXpress++ general support.
Post Reply
Message
Author
User avatar
jdsoft
Posts: 113
Joined: Thu Jan 28, 2010 1:13 pm
Location: Overberg
Contact:

TX Text controll

#1 Post by jdsoft »

Hello,
I need extended text editing in my Express++ application.
Therefore i downloaded the demo version of this product.
Has anybody succesfuly integrated Express++ and TX text control?
Some Xbase++ or Express++ samplecode would be much appreciated.

Regards,
Jack Duijf
Regards,
Jack Duijf

User avatar
Markus Walter
Posts: 54
Joined: Thu Jan 28, 2010 12:49 am
Location: Germany

Re: TX Text controll

#2 Post by Markus Walter »

Hi Jack,

i did this and it works well. But i have a special layer around express, so some sample code is a problem.

I use a DCSTATIC and create the txcontrol in the eval of the static like this:

Code: Select all

  @ aPos[2], aPos[1]  DCSTATIC TYPE XBPSTATIC_TYPE_TEXT ;
                      OBJECT oStaticRtf ;
                      SIZE asize[1], asize[2] ;
                      EVAL bEvalStd ;
                      PARENT oParent  ;
                      _TABSTOP lTabStop ;
                      _VISIBLE lVisible ;
                      PRESENTATION aPres;
                      HIDE bHide


function wGuiDCRtfGenerate(oStaticRtf, cRtfText, xReadOnly, oRtf, nZoom, getlist)

  // damit der Eingabefocus des Static an das TxTextControl weitergegeben wird
  oStaticRtf:setInputFocus := {| uNIL1, uNIL2, self | dc_setappfocus(oRtf) }

  oRtf := wRtfControl():New()

  if !empty(xReadOnly)
    oRtf:Editable := .f.
  endif

  oRtf:create(oStaticRtf, , {0, 0}, oStaticRtf:currentsize())
  oRtf:DATALINK := {|| oRtf:SelectAll(), cRtfText := oRtf:RTFSelText }

  if !empty(nZoom)
    oRtf:ZoomFactor := nZoom
  endif

  if !empty(xReadOnly)
    oRtf:EditMode := TXTEXT_EDITMODE_DISPLAYSELECT
  endif

  if left(cRtfText, 5) == "{\rtf"
    oRtf:LoadRtf(cRtfText)
  else
    oRtf:SelText := ""
  endif

  DC_GetCargo(oRtf, {"TYP", "TXTEXTCONTROL"} )

  // damit nach Umschalten mit Alt-Tab das TxTextcontrol wieder den Focus hat, wenn es ihn vor Alt-Tab hatte
  oRtf:setinputfocus := {| uNIL1, uNIL2, self | if(readinsert(), oRtf:InsertionMode := .t., oRtf:InsertionMode := .f.), dc_lastfocus(getlist, oRtf) }

return nil

-----------------
Greetings
Markus Walter

User avatar
jdsoft
Posts: 113
Joined: Thu Jan 28, 2010 1:13 pm
Location: Overberg
Contact:

Re: TX Text controll

#3 Post by jdsoft »

Hello Markus,

Thank you for the input.
Would it be possible if you show me how codeblock bEvalStd looks like?
I als would like to see the code for class wRtfControl():New()

My first goal is to build a Xbase++ sample programm.

Regards,
Jack Duijf
Regards,
Jack Duijf

User avatar
Tom
Posts: 1176
Joined: Thu Jan 28, 2010 12:59 am
Location: Berlin, Germany

Re: TX Text controll

#4 Post by Tom »

This is a very simple sample I created for someone years ago. It will work with TX 15 and any further version. Insert your license-code and it will create a simple word processor with a context menu in it. It needs the name of an RTF-file als parameter. Slight changes needed to add support for any other format. The used function "RTFImport" may be replaced by others (LoadFromMemory). Used in a program, this function will also work with any ASCII text oder stored RTF-text from memos.

Code: Select all

#include 'dcdialog.ch'
#pragma library("dclipx.lib")
#PRAGMA LIBRARY("ASCOM10.LIB")

function main(cTextFile)
local oStatic1, oTxDlgArea, oDialog, oTxControl,oTxButtonBar,oTxStatusBar,;
      cText := '', oTxMenu, GetList := {}, GetOptions := {}

if pcount()>0
  cText := cTextFile
endif

@ 2,2 DCSTATIC type XBPSTATIC_TYPE_TEXT object oStatic1 SIZE 120,22

DCGET OPTIONS AUTORESIZE

DCREAD GUI ;
  TITLE "TX Text Control Test" ;
  OPTIONS GetOptions ;
  PARENT @oDialog ;
  eval {||MyCreateTxControl(@oTxMenu,.T.,.T.,oDialog,oStatic1,@oStatic1,@oTxControl,@oTxButtonBar,@oTxStatusBar,cText,.T.),SetAppFocus(oTxControl)} ;
  FIT

RETURN nil

FUNCTION MyCreateTxControl(oTxMenu,lResizeable,lEditAble,oOwner,oWindow, oDlgArea,oTxControl,oTxButtonBar,oTxStatusBar,cMemoText,lIsDatei )
Local oThread,cTxFile, oTwDlg
Local w,h,hbutton,htext,hstatus, xWhatEver, xWhatSav

DEFAULT lIsDatei := .F.

w:=oDlgArea:currentSize()[1]
h:=oDlgArea:currentSize()[2]
hButton := if(lEditAble,32,0)
hstatus := 20
htext := h-(hbutton+hstatus)

oTxControl := XbpActiveXControl():new( oDlgArea )
oTxControl:CLSID := 'TIS.TX.TextControl.15'
oTxControl:license := 'TP-XXXXXXXXXXX'
oTxControl:Userevents := .F.

oTxControl:create(oDlgArea,,{0,hstatus},{w,htext} )

if lEditable
  // Buttonbar
  oTXButtonBar := XbpActiveXControl():new( oDlgArea )
  oTXButtonBar:CLSID := 'TIS.TX.ButtonBarControl.15'
  oTXButtonBar:create(oDlgArea,,{0,hstatus+htext},{w,hbutton} )
  oTxButtonBar:Userevents := .F.
endif

// Statusbar
oTXStatusBar := XbpActiveXControl():new( oDlgArea )
oTXStatusBar:CLSID := 'TIS.TX.StatusBarControl.15'
oTXStatusBar:create(oDlgArea,,{0,0},{w,hstatus} )
oTxStatusBar:Userevents := .F.
if lEditAble
  oTxControl:ButtonBarHandle := oTXButtonBar:hWnd
  oTXButtonBar:Appearance := 2
  oTXStatusBar:Enabled := .T.
  oTXStatusBar:Language := 49
  oTXButtonBar:PosControlChars := 1
endif

oTxControl:StatusBarHandle := oTXStatusBar:hWnd
oTXControl:Enabled := .T.
oTXControl:EditMode := if(lEditAble,0,1)
oTxControl:InsertionMode := .T.
oTXControl:PageHeight := 16160
oTXControl:ScrollBars := 3
oTXControl:SizeMode := 0
oTXControl:PageWidth := 12000 // was 14000
oTXControl:FontName := "Tahoma"
oTXControl:FontSize := 8
oTXStatusBar:TextColumn := "Spalte"
oTXStatusBar:TextLine := "Zeile"
oTXStatusBar:TextPage := "Seite"
oTXStatusBar:FontName := "Tahoma"

if len(cMemoText) > 0
  if lIsDatei
    oTXStatusBar:Text := (cMemoText)
    oTxControl:RTFImport(cMemoText)
  else
    if left(cMemoText,5) = "{\rtf"
      oTxControl:RTFSelText := cMemoText
    else
      oTxControl:Text := (hardcr(cMemoText))
    endif

  endif
endif

if lEditable
  oTxMenu := XbpMenu():new( oDlgArea ):create( )
  oTxMenu:AddItem( {"Format (Font)",{ || oTxControl:FontDialog(),SetAppFocus(oTxControl) } } )
  oTxMenu:AddItem( {NIL, NIL, XBPMENUBAR_MIS_SEPARATOR, 0  } )
  oTxMenu:AddItem( {"Delete",{ || oTxControl:Clip(4) } } )
  oTxMenu:AddItem( {"Cut",{ || oTxControl:Clip(1) } } )
  oTxMenu:AddItem( {"Copy",{ || oTxControl:Clip(2) } } )
  oTxMenu:AddItem( {"Paste",{ || oTxControl:Clip(3) } } )
  oTxControl:RbDown  := { |mp1, mp2, obj|oTxMenu:PopUp ( oDlgArea, mp1 , 1 ,XBPMENU_PU_DEFAULT + XBPMENU_PU_MOUSE_RBDOWN) }
endif


RETURN nil

procedure AppSys() ; return

Best regards,
Tom

"Did I offend you?"
"No."
"Okay, give me a second chance."

skiman
Posts: 1186
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

Re: TX Text controll

#5 Post by skiman »

Hi Tom,

Very simple sample :?:
I was wondering what you would post if you said 'complex sample'. :P
Best regards,

Chris.
www.aboservice.be

User avatar
Tom
Posts: 1176
Joined: Thu Jan 28, 2010 12:59 am
Location: Berlin, Germany

Re: TX Text controll

#6 Post by Tom »

Hi, Chris.

This is simple, it just shows how to create the control with status- and buttonbar (other ways possible), to add a context menu and to load a text (rtf). A complex sample would show how to do this very elegant and flexible, how to use all the functions of TX, play around with all kinds of formats (even for export) and change the control's appearance. Anyway, this is friday, and I tend to become a little more complex on fridays. ;)
Best regards,
Tom

"Did I offend you?"
"No."
"Okay, give me a second chance."

User avatar
jdsoft
Posts: 113
Joined: Thu Jan 28, 2010 1:13 pm
Location: Overberg
Contact:

Re: TX Text controll

#7 Post by jdsoft »

Hello,

I just tried to run your sample. Got a runtime error:

oError:description : Could not create ActiveX control
oError:genCode : 6503
oError:operation : XBPACTIVEXCONTROL:CREATE
oError:subCode : 6500
oError:subSystem : Automation

Called from MYCREATETXCONTROL(43)
Called from (B)MAIN(22)
Called from DC_GETLIST:READGUI(3590)
Called from DC_READGUI(103)
Called from MAIN(22)

I changed the CLSID to 'TIS.TX.TextControl.15.1', and stil got the error.
Then also changed the CLSID to {3CE7A701-9BC2-11DE-A4C1-0013D350667C}, same result.

It looks as Tx Text controll is not installed, but i find the registry keys in regedit.
I downloaded and installed the VB6 version of Tx Text controll.

Please advise.
Regards,
Jack Duijf
Regards,
Jack Duijf

Post Reply