1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
<html dir="ltr"><head>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<META HTTP-EQUIV="assetid" CONTENT="HV01104102"><META NAME="lcid" CONTENT="1033"><title>OnContextChange Event</title><link rel="stylesheet" type="text/css" href="office10.css"><script type="text/javascript" language="Javascript" src="ExpCollapse.js"></script><script type="text/javascript" language="JavaScript" src="inline.js"></script></head><body><p id="ExpandAllLine" class="ExpFav"><a href="#" onclick="ExpandAll()" onkeypress="ExpandAll()" class="DropDown"><img id="picHeader" border="0" src="expandtri.gif" alt="Show All"><span id="ExpandAll">Show All</span></a></p><h1>OnContextChange Event</h1><DIV class="ofvbanav"><span class="ofvbanavreuse" id="seealso" onclick="toggleList()" onkeypress="toggleList()"></span><span class="ofvbanavreuse" id="appliesto" onclick="toggleList()" onkeypress="toggleList()"></span><a class="ofvbanavex" href="#example"><span class="ofvbanavreuse" id="example"></span></a><span class="ofvbanavreuse" id="specifics" onclick="toggleList()" onkeypress="toggleList()"></span></DIV><p>
<p>Occurs after the context node changes.</p>
<p class="signature">Function <i>XDocument</i>::<b class="bterm">OnContextChange</b>(ByRef <b class="bterm"><i>pEvent</i></b> As DocContextChangeEvent)</p>
<p>
<i><b class="bterm">
pEvent</b> </i> Required <b class="bterm">DocContextChangeEvent</b>. A reference to the <a href="xdobjDocContextChangeEventObject_HV01104103.htm" id="HV01104103" lcid=" "><b class="bterm">DocContextChangeEvent</b></a> object.</p>
</p><h2>Remarks</h2><p>
<p>The context node is the XML DOM node mapped to the view that corresponds to the container (or item) with the current XML selection. For example, if the current selection in the view is in a <a href="#" class="glossary" onclick="AppendPopup(this,'xdtextbox')" onkeypress="AppendPopup(this,'xdtextbox')">text box</a>, the context node is the node to which the text box is bound. If the current selection is a <a href="#" class="glossary" onclick="AppendPopup(this,'xdrepeatingsection')" onkeypress="AppendPopup(this,'xdrepeatingsection')">repeating section</a>, the context node is the node for that item. If two repeating sections are selected, the context node is the ancestor XML DOM for both items mapped to the view.</p><p>The <b class="bterm">OnContextChange</b> event is asynchronous. It does not fire on every change in the context node; instead, it fires after the application has stopped processing other events.</p><p>When the document loads, or when a view change occurs, the <b class="bterm">OnContextChange</b> event will occur after the <a href="xdevtOnLoad.htm" id="HV01021369" lcid=" "><b class="bterm">OnLoad</b></a> and <a href="xdevtOnSwitchView.htm" id="HV01021371" lcid=" "><b class="bterm">OnSwitchView</b></a> events occur.</p><p>When the <a href="xdproIsUndoRedo.htm" id="HV01021293" lcid=" "><b class="bterm">IsUndoRedo</b></a> property of the <b class="bterm">DocContextChangeEvent</b> object is <b class="bterm">True</b>, the context change was caused by a user's undo or redo operation rather than an explicit user context change. Operations performed within the <b class="bterm">OnContextChange</b> event handler that modify the XML DOM should be avoided in response to undo or redo operations, because they may interfere with the user's intention to revert data to a previous state.</p><p>For rich text box controls, the <b class="bterm">OnContextChange</b> event is not raised for context changes within the XHTML content<nbsp />— that is, selection changes to the rich text in the control. The <a href="xdmthGetContextNodes.htm" id="HV01021388" lcid=" "><b class="bterm">GetContextNodes</b></a> method can be used to determine the selection within rich text box controls.</p>
<p><p><b>Note</b> This object model member is not supported when the <b class="ui">Disable Service Pack features</b> option on the <b class="ui">Advanced</b> tab of the <b class="ui">Options</b> dialog box in InfoPath is selected or when Microsoft Office 2003 Service Pack 1 or later is not installed. Any form that implements this object model member in its code will generate an error message if it is opened in InfoPath when service pack features are disabled or unavailable.</p></p></p><h2><a id="#example" name="#example">Example</a></h2><p>
<p>In the following example, instructions specific to different context nodes in a form are added to the body of a custom task pane. A custom HTML task pane should be added to the form template in <a href="#" class="glossary" onclick="AppendPopup(this,'xddesignmode')" onkeypress="AppendPopup(this,'xddesignmode')">design mode</a>:</p>
<pre><code>function XDocument::OnContextChange(eventObj)
{
var oContextNode = eventObj.Context;
var strText = "";
if( oContextNode.nodeName == "my:root" )
strText = "";
else if( oContextNode.nodeName == "my:singleName" )
strText = "Type your full name.";
else if( oContextNode.nodeName == "my:webSite" )
strText = "Type the Web address of your personal web page.";
var oTaskPane = XDocument.View.Window.TaskPanes.Item(0);
oTaskPane.HTMLDocument.body.innerText = strText;
}</code></pre>
</p><script type="text/javascript" language="JScript" src="ofvbanl.js"></script><span id="ofVBAISpan" class="ofvbaispan"><iframe id="ofVBAIFrame" frameborder="0" marginheight="0" marginwidth="4" scrolling="auto" width="100%" src="../links/xdevtOnContextChange_HV01104102_l.htm"></iframe></span><center><a href="XMLSchemaCopyright_HV01147162.htm">©2003-2004 Microsoft Corporation. All rights reserved.</a>
Permission to copy, display and distribute this document is available at: <a
href="http://r.office.microsoft.com/r/rlidAWSContentRedir?AssetID=XT010988631033&CTT=11&Origin=HV011232471033"
target="_new">http://msdn.microsoft.com/library/en-us/odcXMLRef/html/odcXMLRefLegalNotice.asp</a></center></body></html>
|