property HTML.Locked as Boolean
Determines whether a control can be edited.

TypeDescription
Boolean A Boolean expression that specifies whether the control is locked.
By default, the Locked property is False, which indicates that the control can make changes to the control. The user can not make changes to the control while the control is locked. The BackColorLocked property specifies the control's background while it is locked. The ForeColorLocked property specifies the control's foreground while it is locked. The ShowCaret property specifies whether the control's caret is visible or hidden. The difference between Locked vs Enabled, is that user can select/scroll the text into a locked control, and can not select/scroll the text into a disabled control. The Enabled property specifies whether the control is enable or disable.

How do I make the control read-only?

VBA (MS Access, Excell...)

With HTML1
	.Text = "This is a bit of <b>HTML</b> text."
	.BackColorLocked = .BackColor
	.ForeColorLocked = .ForeColor
	.Locked = True
	.AllowContextMenu = 0
	.ShowCaret = False
End With

VB6

With HTML1
	.Text = "This is a bit of <b>HTML</b> text."
	.BackColorLocked = .BackColor
	.ForeColorLocked = .ForeColor
	.Locked = True
	.AllowContextMenu = exHideContextMenu
	.ShowCaret = False
End With

VB.NET

With Exhtml1
	.Text = "This is a bit of <b>HTML</b> text."
	.BackColorLocked = .BackColor
	.ForeColorLocked = .ForeColor
	.Locked = True
	.AllowContextMenu = exontrol.EXHTMLLib.HTMLEditContextMenuEnum.exHideContextMenu
	.ShowCaret = False
End With

VB.NET for /COM

With AxHTML1
	.Text = "This is a bit of <b>HTML</b> text."
	.BackColorLocked = .BackColor
	.ForeColorLocked = .ForeColor
	.Locked = True
	.AllowContextMenu = EXHTMLLib.HTMLEditContextMenuEnum.exHideContextMenu
	.ShowCaret = False
End With

C++

/*
	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();
spHTML1->PutText(L"This is a bit of <b>HTML</b> text.");
spHTML1->PutBackColorLocked(spHTML1->GetBackColor());
spHTML1->PutForeColorLocked(spHTML1->GetForeColor());
spHTML1->PutLocked(VARIANT_TRUE);
spHTML1->PutAllowContextMenu(EXHTMLLib::exHideContextMenu);
spHTML1->PutShowCaret(VARIANT_FALSE);

C++ Builder

HTML1->Text = L"This is a bit of <b>HTML</b> text.";
HTML1->BackColorLocked = HTML1->BackColor;
HTML1->ForeColorLocked = HTML1->ForeColor;
HTML1->Locked = true;
HTML1->AllowContextMenu = Exhtmllib_tlb::HTMLEditContextMenuEnum::exHideContextMenu;
HTML1->ShowCaret = false;

C#

exhtml1.Text = "This is a bit of <b>HTML</b> text.";
exhtml1.BackColorLocked = exhtml1.BackColor;
exhtml1.ForeColorLocked = exhtml1.ForeColor;
exhtml1.Locked = true;
exhtml1.AllowContextMenu = exontrol.EXHTMLLib.HTMLEditContextMenuEnum.exHideContextMenu;
exhtml1.ShowCaret = false;

JScript/JavaScript

<BODY onload='Init()'>
<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.";
	HTML1.BackColorLocked = HTML1.BackColor;
	HTML1.ForeColorLocked = HTML1.ForeColor;
	HTML1.Locked = true;
	HTML1.AllowContextMenu = 0;
	HTML1.ShowCaret = false;
}
</SCRIPT>
</BODY>

VBScript

<BODY onload='Init()'>
<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."
		.BackColorLocked = .BackColor
		.ForeColorLocked = .ForeColor
		.Locked = True
		.AllowContextMenu = 0
		.ShowCaret = False
	End With
End Function
</SCRIPT>
</BODY>

C# for /COM

axHTML1.Text = "This is a bit of <b>HTML</b> text.";
axHTML1.BackColorLocked = axHTML1.BackColor;
axHTML1.ForeColorLocked = axHTML1.ForeColor;
axHTML1.Locked = true;
axHTML1.AllowContextMenu = EXHTMLLib.HTMLEditContextMenuEnum.exHideContextMenu;
axHTML1.ShowCaret = false;

X++ (Dynamics Ax 2009)

public void init()
{
	;

	super();

	exhtml1.Text("This is a bit of <b>HTML</b> text.");
	exhtml1.BackColorLocked(exhtml1.BackColor());
	exhtml1.ForeColorLocked(exhtml1.ForeColor());
	exhtml1.Locked(true);
	exhtml1.AllowContextMenu(0/*exHideContextMenu*/);
	exhtml1.ShowCaret(false);
}

Delphi 8 (.NET only)

with AxHTML1 do
begin
	Text := 'This is a bit of <b>HTML</b> text.';
	BackColorLocked := BackColor;
	ForeColorLocked := ForeColor;
	Locked := True;
	AllowContextMenu := EXHTMLLib.HTMLEditContextMenuEnum.exHideContextMenu;
	ShowCaret := False;
end

Delphi (standard)

with HTML1 do
begin
	Text := 'This is a bit of <b>HTML</b> text.';
	BackColorLocked := BackColor;
	ForeColorLocked := ForeColor;
	Locked := True;
	AllowContextMenu := EXHTMLLib_TLB.exHideContextMenu;
	ShowCaret := False;
end

VFP

with thisform.HTML1
	.Text = "This is a bit of <b>HTML</b> text."
	.BackColorLocked = .BackColor
	.ForeColorLocked = .ForeColor
	.Locked = .T.
	.AllowContextMenu = 0
	.ShowCaret = .F.
endwith

dBASE Plus

local oHTML

oHTML = form.Activex1.nativeObject
oHTML.Text = "This is a bit of <b>HTML</b> text."
oHTML.BackColorLocked = oHTML.BackColor
oHTML.ForeColorLocked = oHTML.ForeColor
oHTML.Locked = true
oHTML.AllowContextMenu = 0
oHTML.ShowCaret = false

XBasic (Alpha Five)

Dim oHTML as P

oHTML = topparent:CONTROL_ACTIVEX1.activex
oHTML.Text = "This is a bit of <b>HTML</b> text."
oHTML.BackColorLocked = oHTML.BackColor
oHTML.ForeColorLocked = oHTML.ForeColor
oHTML.Locked = .t.
oHTML.AllowContextMenu = 0
oHTML.ShowCaret = .f.

Visual Objects


oDCOCX_Exontrol1:Text := "This is a bit of <b>HTML</b> text."
oDCOCX_Exontrol1:BackColorLocked := oDCOCX_Exontrol1:BackColor
oDCOCX_Exontrol1:ForeColorLocked := oDCOCX_Exontrol1:ForeColor
oDCOCX_Exontrol1:Locked := true
oDCOCX_Exontrol1:AllowContextMenu := exHideContextMenu
oDCOCX_Exontrol1:ShowCaret := false

PowerBuilder

OleObject oHTML

oHTML = ole_1.Object
oHTML.Text = "This is a bit of <b>HTML</b> text."
oHTML.BackColorLocked = oHTML.BackColor
oHTML.ForeColorLocked = oHTML.ForeColor
oHTML.Locked = true
oHTML.AllowContextMenu = 0
oHTML.ShowCaret = false

Visual DataFlex

Procedure OnCreate
	Forward Send OnCreate
	Set ComText to "This is a bit of <b>HTML</b> text."
	Set ComBackColorLocked to (ComBackColor(Self))
	Set ComForeColorLocked to (ComForeColor(Self))
	Set ComLocked to True
	Set ComAllowContextMenu to OLEexHideContextMenu
	Set ComShowCaret to False
End_Procedure

XBase++

#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:Text := "This is a bit of <b>HTML</b> text."
		oHTML:SetProperty("BackColorLocked",oHTML:BackColor())
		oHTML:SetProperty("ForeColorLocked",oHTML:ForeColor())
		oHTML:Locked := .T.
		oHTML:AllowContextMenu := 0/*exHideContextMenu*/
		oHTML:ShowCaret := .F.

	oForm:Show()
	DO WHILE nEvent != xbeP_Quit
		nEvent := AppEvent( @mp1, @mp2, @oXbp )
		oXbp:handleEvent( nEvent, mp1, mp2 )
	ENDDO 
RETURN