# ContextMenuOpening Event

> Occurs before a built-in context menu opens, with DocumentLocation flags for selection, margins, frames, tables or fields and Cancel to show your own menu.

- **Product:** TX Text Control ActiveX
- **Section:** Documentation
- **Kind:** Event
- **Path:** TX Text Control ActiveX > API Reference > TXTextControl > ContextMenuOpening Event
- **397 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/contextmenuopening-event/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/contextmenuopening-event/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/contextmenuopening-event/llms-full.txt

---

Occurs before a built-in context menu is opened.

Introduced: 19.0.

### Syntax

```vbscript
ContextMenuOpening(DocumentLocation, Cancel)
```

### Parameters

| Parameter | Description |
|---|---|
| DocumentLocation | Specifies the part of the document for which the menu is opened. It can be one or more of the following values: |
| Cancel | When this parameter is set to TRUE, processing is aborted and no context menu is opened. It can be used to display an own menu. |

#### DocumentLocation

| Value | Description |
|---|---|
| &H1 | The menu context is a text selection. |
| &H2 | The menu context is the text input position. |
| &H4 | The menu context is the top page margin which contains a header. |
| &H8 | The menu context is the top page margin which contains no header. |
| &H10 | The menu context is the bottom page margin which contains a footer. |
| &H20 | The menu context is the bottom page margin which contains no footer. |
| &H40 | The menu context is the top or the bottom page margin. |
| &H80 | The menu context is a pagenumber field. |
| &H100 | The menu context is a selected frame (text frame, image, or OLE object). |
| &H200 | The menu context is a text selection or a text input position in a table. |
| &H400 | The menu context is a text selection or a text input position in a marked text field. |

### Data Types

| Name | Data type |
|---|---|
| DocumentLocation | Integer |
| Cancel | Boolean |

### See Also

- [Programming Category: Control Settings](https://docs.textcontrol.com/tx-text-control-activex/reference/categories/control-settings/llms-full.txt)

---

## Nearby

- **Previous:** [ConnectTools Event](https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/connecttools-event/llms-full.txt)
- **Next:** [ControlChars Property](https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/controlchars-property/llms-full.txt)
