Type | Description | |||
Position as Long | A long expression that specifies the position of the cursor to insert/replace the text. The Position parameter could be a value between CursorStart and CursorEnd properties. If -1, end of the text is considered. The SelStart property returns or sets the number of characters selected. | |||
Length as Long | A long expression that indicates the length of the text to be replaced. The SelLength property to specifies the length of the control's selection. | |||
PlainText as Variant | A Boolean expression that specifies whether the CursorText method gets the un-formatted ( plain text ) / formatted text. If missing, the PlaintText parameters is True, or un-formatted ( plain text ). | |||
String | A String expression that specifies the un-formatted ( plain text ) / formatted text, based on the PlainText parameter. |
from any position of any length.
The CursorPos property specifies the position of the cursor inside the text. The CursorStart property gives the starting position of the text. The CursorEnd property gives the ending position of the text. Use the Text property to access/replace the entire control's text. Use the SelText property to insert text at cursor position. The SelStart property returns or sets the number of characters selected. The SelLength property to specifies the length of the control's selection. The Find method finds and selects programmatically a string within the control's text.
The following samples get the selection as plain text with no HTML formatting:
VBA (MS Access, Excell...)
' SelChange event - Occurs when the user selects text in the control. Private Sub HTML1_SelChange() With HTML1 Debug.Print( .CursorText(.SelStart,.SelLength,True) ) End With End Sub With HTML1 .WordWrap = True .Text = "<font ;12><sha ;;0>This is a bit of <b><fgcolor 808080><u>HTML</u></fgcolor></b> text. Select " & _ "a portion of text and you will get the text with no HTML formatting." End With
VB6
' SelChange event - Occurs when the user selects text in the control. Private Sub HTML1_SelChange() With HTML1 Debug.Print( .CursorText(.SelStart,.SelLength,True) ) End With End Sub With HTML1 .WordWrap = True .Text = "<font ;12><sha ;;0>This is a bit of <b><fgcolor 808080><u>HTML</u></fgcolor></b> text. Select " & _ "a portion of text and you will get the text with no HTML formatting." End With
VB.NET
' SelChange event - Occurs when the user selects text in the control. Private Sub Exhtml1_SelChange(ByVal sender As System.Object) Handles Exhtml1.SelChange With Exhtml1 Debug.Print( .get_CursorText(.SelStart,.SelLength,True) ) End With End Sub With Exhtml1 .WordWrap = True .Text = "<font ;12><sha ;;0>This is a bit of <b><fgcolor 808080><u>HTML</u></fgcolor></b> text. Select " & _ "a portion of text and you will get the text with no HTML formatting." End With
VB.NET for /COM
' SelChange event - Occurs when the user selects text in the control. Private Sub AxHTML1_SelChange(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AxHTML1.SelChange With AxHTML1 Debug.Print( .get_CursorText(.SelStart,.SelLength,True) ) End With End Sub With AxHTML1 .WordWrap = True .Text = "<font ;12><sha ;;0>This is a bit of <b><fgcolor 808080><u>HTML</u></fgcolor></b> text. Select " & _ "a portion of text and you will get the text with no HTML formatting." End With
C++
// SelChange event - Occurs when the user selects text in the control. void OnSelChangeHTML1() { /* Copy and paste the following directives to your header file as it defines the namespace 'EXHTMLLib' for the library: 'ExHTML 1.0 Control Library' #import <ExHTML.dll> using namespace EXHTMLLib; */ EXHTMLLib::IHTMLPtr spHTML1 = GetDlgItem(IDC_HTML1)->GetControlUnknown(); OutputDebugStringW( spHTML1->GetCursorText(spHTML1->GetSelStart(),spHTML1->GetSelLength(),VARIANT_TRUE) ); } EXHTMLLib::IHTMLPtr spHTML1 = GetDlgItem(IDC_HTML1)->GetControlUnknown(); spHTML1->PutWordWrap(VARIANT_TRUE); spHTML1->PutText(_bstr_t("<font ;12><sha ;;0>This is a bit of <b><fgcolor 808080><u>HTML</u></fgcolor></b> text. Select ") + "a portion of text and you will get the text with no HTML formatting.");
C++ Builder
// SelChange event - Occurs when the user selects text in the control. void __fastcall TForm1::HTML1SelChange(TObject *Sender) { OutputDebugString( HTML1->CursorText[HTML1->SelStart,HTML1->SelLength,TVariant(true)] ); } HTML1->WordWrap = true; HTML1->Text = TVariant(String("<font ;12><sha ;;0>This is a bit of <b><fgcolor 808080><u>HTML</u></fgcolor></b> text. Select ") + "a portion of text and you will get the text with no HTML formatting.");
C#
// SelChange event - Occurs when the user selects text in the control. private void exhtml1_SelChange(object sender) { System.Diagnostics.Debug.Print( exhtml1.get_CursorText(exhtml1.SelStart,exhtml1.SelLength,true) ); } //this.exhtml1.SelChange += new exontrol.EXHTMLLib.exg2antt.SelChangeEventHandler(this.exhtml1_SelChange); exhtml1.WordWrap = true; exhtml1.Text = "<font ;12><sha ;;0>This is a bit of <b><fgcolor 808080><u>HTML</u></fgcolor></b> text. Select " + "a portion of text and you will get the text with no HTML formatting.";
JScript/JavaScript
<BODY onload='Init()'> <SCRIPT FOR="HTML1" EVENT="SelChange()" LANGUAGE="JScript"> alert( HTML1.CursorText(HTML1.SelStart,HTML1.SelLength,true) ); </SCRIPT> <OBJECT CLASSID="clsid:0036F83C-D892-4B7B-AA0B-BEDD8D16A738" id="HTML1"></OBJECT> <SCRIPT LANGUAGE="JScript"> function Init() { HTML1.WordWrap = true; HTML1.Text = "<font ;12><sha ;;0>This is a bit of <b><fgcolor 808080><u>HTML</u></fgcolor></b> text. Select " + "a portion of text and you will get the text with no HTML formatting."; } </SCRIPT> </BODY>
VBScript
<BODY onload='Init()'> <SCRIPT LANGUAGE="VBScript"> Function HTML1_SelChange() With HTML1 alert( .CursorText(.SelStart,.SelLength,True) ) End With End Function </SCRIPT> <OBJECT CLASSID="clsid:0036F83C-D892-4B7B-AA0B-BEDD8D16A738" id="HTML1"></OBJECT> <SCRIPT LANGUAGE="VBScript"> Function Init() With HTML1 .WordWrap = True .Text = "<font ;12><sha ;;0>This is a bit of <b><fgcolor 808080><u>HTML</u></fgcolor></b> text. Select " & _ "a portion of text and you will get the text with no HTML formatting." End With End Function </SCRIPT> </BODY>
C# for /COM
// SelChange event - Occurs when the user selects text in the control. private void axHTML1_SelChange(object sender, EventArgs e) { System.Diagnostics.Debug.Print( axHTML1.get_CursorText(axHTML1.SelStart,axHTML1.SelLength,true) ); } //this.axHTML1.SelChange += new EventHandler(this.axHTML1_SelChange); axHTML1.WordWrap = true; axHTML1.Text = "<font ;12><sha ;;0>This is a bit of <b><fgcolor 808080><u>HTML</u></fgcolor></b> text. Select " + "a portion of text and you will get the text with no HTML formatting.";
X++ (Dynamics Ax 2009)
// SelChange event - Occurs when the user selects text in the control. void onEvent_SelChange() { ; print( exhtml1.CursorText(exhtml1.SelStart(),exhtml1.SelLength(),COMVariant::createFromBoolean(true)) ); } public void init() { str var_s; ; super(); exhtml1.WordWrap(true); var_s = "<font ;12><sha ;;0>This is a bit of <b><fgcolor 808080><u>HTML</u></fgcolor></b> text. Select a"; var_s = var_s + " portion of text and you will get the text with no HTML formatting."; exhtml1.Text(var_s); }
Delphi 8 (.NET only)
// SelChange event - Occurs when the user selects text in the control. procedure TWinForm1.AxHTML1_SelChange(sender: System.Object; e: System.EventArgs); begin with AxHTML1 do begin OutputDebugString( get_CursorText(SelStart,SelLength,TObject(True)) ); end end; with AxHTML1 do begin WordWrap := True; Text := '<font ;12><sha ;;0>This is a bit of <b><fgcolor 808080><u>HTML</u></fgcolor></b> text. Select a' + ' portion of text and you will get the text with no HTML formatting.'; end
Delphi (standard)
// SelChange event - Occurs when the user selects text in the control. procedure TForm1.HTML1SelChange(ASender: TObject; ); begin with HTML1 do begin OutputDebugString( CursorText[SelStart,SelLength,OleVariant(True)] ); end end; with HTML1 do begin WordWrap := True; Text := '<font ;12><sha ;;0>This is a bit of <b><fgcolor 808080><u>HTML</u></fgcolor></b> text. Select a' + ' portion of text and you will get the text with no HTML formatting.'; end
VFP
*** SelChange event - Occurs when the user selects text in the control. *** LPARAMETERS nop with thisform.HTML1 DEBUGOUT( .CursorText(.SelStart,.SelLength,.T.) ) endwith with thisform.HTML1 .WordWrap = .T. var_s = "<font ;12><sha ;;0>This is a bit of <b><fgcolor 808080><u>HTML</u></fgcolor></b> text. Select a" var_s = var_s + " portion of text and you will get the text with no HTML formatting." .Text = var_s endwith
dBASE Plus
/* with (this.ACTIVEX1.nativeObject) SelChange = class::nativeObject_SelChange endwith */ // Occurs when the user selects text in the control. function nativeObject_SelChange() local oHTML oHTML = form.Activex1.nativeObject ? oHTML.CursorText(oHTML.SelStart,oHTML.SelLength,true) return local oHTML oHTML = form.Activex1.nativeObject oHTML.WordWrap = true oHTML.Text = "<font ;12><sha ;;0>This is a bit of <b><fgcolor 808080><u>HTML</u></fgcolor></b> text. Select a portion of text and you will get the text with no HTML formatting."
XBasic (Alpha Five)
' Occurs when the user selects text in the control. function SelChange as v () Dim oHTML as P oHTML = topparent:CONTROL_ACTIVEX1.activex ? oHTML.CursorText(oHTML.SelStart,oHTML.SelLength,.t.) end function Dim oHTML as P oHTML = topparent:CONTROL_ACTIVEX1.activex oHTML.WordWrap = .t. oHTML.Text = "<font ;12><sha ;;0>This is a bit of <b><fgcolor 808080><u>HTML</u></fgcolor></b> text. Select a portion of text and you will get the text with no HTML formatting."
Visual Objects
METHOD OCX_Exontrol1SelChange() CLASS MainDialog // SelChange event - Occurs when the user selects text in the control. OutputDebugString(String2Psz( oDCOCX_Exontrol1:[CursorText,oDCOCX_Exontrol1:SelStart,oDCOCX_Exontrol1:SelLength,true] )) RETURN NIL oDCOCX_Exontrol1:WordWrap := true oDCOCX_Exontrol1:Text := "<font ;12><sha ;;0>This is a bit of <b><fgcolor 808080><u>HTML</u></fgcolor></b> text. Select a portion of text and you will get the text with no HTML formatting."
PowerBuilder
/*begin event SelChange() - Occurs when the user selects text in the control.*/ /* OleObject oHTML oHTML = ole_1.Object MessageBox("Information",string( oHTML.CursorText(oHTML.SelStart,oHTML.SelLength,true) )) */ /*end event SelChange*/ OleObject oHTML oHTML = ole_1.Object oHTML.WordWrap = true oHTML.Text = "<font ;12><sha ;;0>This is a bit of <b><fgcolor 808080><u>HTML</u></fgcolor></b> text. Select a portion of text and you will get the text with no HTML formatting."
Visual DataFlex
// Occurs when the user selects text in the control. Procedure OnComSelChange Forward Send OnComSelChange Showln (ComCursorText(Self,(ComSelStart(Self)),(ComSelLength(Self)),True)) End_Procedure Procedure OnCreate Forward Send OnCreate Set ComWordWrap to True Set ComText to "<font ;12><sha ;;0>This is a bit of <b><fgcolor 808080><u>HTML</u></fgcolor></b> text. Select a portion of text and you will get the text with no HTML formatting." End_Procedure
XBase++
PROCEDURE OnSelChange(oHTML) DevOut( oHTML:CursorText(oHTML:SelStart(),oHTML:SelLength(),.T.) ) RETURN #include "AppEvent.ch" #include "ActiveX.ch" PROCEDURE Main LOCAL oForm LOCAL nEvent := 0, mp1 := NIL, mp2 := NIL, oXbp := NIL LOCAL oHTML oForm := XbpDialog():new( AppDesktop() ) oForm:drawingArea:clipChildren := .T. oForm:create( ,,{100,100}, {640,480},, .F. ) oForm:close := {|| PostAppEvent( xbeP_Quit )} oHTML := XbpActiveXControl():new( oForm:drawingArea ) oHTML:CLSID := "Exontrol.HTML.1" /*{0036F83C-D892-4B7B-AA0B-BEDD8D16A738}*/ oHTML:create(,, {10,60},{610,370} ) oHTML:SelChange := {|| OnSelChange(oHTML)} /*Occurs when the user selects text in the control.*/ oHTML:WordWrap := .T. oHTML:Text := "<font ;12><sha ;;0>This is a bit of <b><fgcolor 808080><u>HTML</u></fgcolor></b> text. Select a portion of text and you will get the text with no HTML formatting." oForm:Show() DO WHILE nEvent != xbeP_Quit nEvent := AppEvent( @mp1, @mp2, @oXbp ) oXbp:handleEvent( nEvent, mp1, mp2 ) ENDDO RETURN