exhtml - sample code

How can I get the current selection?

VBA (MS Access, Excell...)

' SelChange event - Occurs when the user selects text in the control.
Private Sub HTML1_SelChange()
	With HTML1
		Debug.Print( .SelText )
	End With
End Sub

With HTML1
	.Text = "This is a bit of <b>HTML</b> text."
End With

VB6

' SelChange event - Occurs when the user selects text in the control.
Private Sub HTML1_SelChange()
	With HTML1
		Debug.Print( .SelText )
	End With
End Sub

With HTML1
	.Text = "This is a bit of <b>HTML</b> text."
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( .SelText )
	End With
End Sub

With Exhtml1
	.Text = "This is a bit of <b>HTML</b> text."
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( .SelText )
	End With
End Sub

With AxHTML1
	.Text = "This is a bit of <b>HTML</b> text."
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->GetSelText() );
}

EXHTMLLib::IHTMLPtr spHTML1 = GetDlgItem(IDC_HTML1)->GetControlUnknown();
spHTML1->PutText(L"This is a bit of <b>HTML</b> text.");

C++ Builder

// SelChange event - Occurs when the user selects text in the control.
void __fastcall TForm1::HTML1SelChange(TObject *Sender)
{
	OutputDebugString( HTML1->SelText );
}

HTML1->Text = L"This is a bit of <b>HTML</b> text.";

C#

// SelChange event - Occurs when the user selects text in the control.
private void exhtml1_SelChange(object sender)
{
	System.Diagnostics.Debug.Print( exhtml1.SelText );
}
//this.exhtml1.SelChange += new exontrol.EXHTMLLib.exg2antt.SelChangeEventHandler(this.exhtml1_SelChange);

exhtml1.Text = "This is a bit of <b>HTML</b> text.";

JScript/JavaScript

<BODY onload='Init()'>
<SCRIPT FOR="HTML1" EVENT="SelChange()" LANGUAGE="JScript">
	alert( HTML1.SelText );
</SCRIPT>

<OBJECT CLASSID="clsid:0036F83C-D892-4B7B-AA0B-BEDD8D16A738" id="HTML1"></OBJECT>

<SCRIPT LANGUAGE="JScript">
function Init()
{
	HTML1.Text = "This is a bit of <b>HTML</b> text.";
}
</SCRIPT>
</BODY>

VBScript

<BODY onload='Init()'>
<SCRIPT LANGUAGE="VBScript">
Function HTML1_SelChange()
	With HTML1
		alert( .SelText )
	End With
End Function
</SCRIPT>

<OBJECT CLASSID="clsid:0036F83C-D892-4B7B-AA0B-BEDD8D16A738" id="HTML1"></OBJECT>

<SCRIPT LANGUAGE="VBScript">
Function Init()
	With HTML1
		.Text = "This is a bit of <b>HTML</b> text."
	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.SelText );
}
//this.axHTML1.SelChange += new EventHandler(this.axHTML1_SelChange);

axHTML1.Text = "This is a bit of <b>HTML</b> text.";

X++ (Dynamics Ax 2009)

// SelChange event - Occurs when the user selects text in the control.
void onEvent_SelChange()
{
	;
	print( exhtml1.SelText() );
}

public void init()
{
	;

	super();

	exhtml1.Text("This is a bit of <b>HTML</b> text.");
}

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( SelText );
	end
end;

with AxHTML1 do
begin
	Text := 'This is a bit of <b>HTML</b> text.';
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( SelText );
	end
end;

with HTML1 do
begin
	Text := 'This is a bit of <b>HTML</b> text.';
end

VFP

*** SelChange event - Occurs when the user selects text in the control. ***
LPARAMETERS nop
	with thisform.HTML1
		DEBUGOUT( .SelText )
	endwith

with thisform.HTML1
	.Text = "This is a bit of <b>HTML</b> text."
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.SelText 
return

local oHTML

oHTML = form.Activex1.nativeObject
oHTML.Text = "This is a bit of <b>HTML</b> text."

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.SelText 
end function

Dim oHTML as P

oHTML = topparent:CONTROL_ACTIVEX1.activex
oHTML.Text = "This is a bit of <b>HTML</b> text."

Visual Objects

METHOD OCX_Exontrol1SelChange() CLASS MainDialog
	// SelChange event - Occurs when the user selects text in the control.
	OutputDebugString(String2Psz( oDCOCX_Exontrol1:SelText ))
RETURN NIL


oDCOCX_Exontrol1:Text := "This is a bit of <b>HTML</b> text."

PowerBuilder

/*begin event SelChange() - Occurs when the user selects text in the control.*/
/*
	OleObject oHTML
	oHTML = ole_1.Object
	MessageBox("Information",string( oHTML.SelText ))
*/
/*end event SelChange*/

OleObject oHTML

oHTML = ole_1.Object
oHTML.Text = "This is a bit of <b>HTML</b> text."

Visual DataFlex

// Occurs when the user selects text in the control.
Procedure OnComSelChange 
	Forward Send OnComSelChange 
	Showln (ComSelText(Self))
End_Procedure

Procedure OnCreate
	Forward Send OnCreate
	Set ComText to "This is a bit of <b>HTML</b> text."
End_Procedure

XBase++

PROCEDURE OnSelChange(oHTML)
	DevOut( oHTML:SelText() )
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:Text := "This is a bit of <b>HTML</b> text."

	oForm:Show()
	DO WHILE nEvent != xbeP_Quit
		nEvent := AppEvent( @mp1, @mp2, @oXbp )
		oXbp:handleEvent( nEvent, mp1, mp2 )
	ENDDO 
RETURN
Copyright 1999-2017 Exontrol. All rights reserved.