HeaderPane
Main
Hide

SftTree/OCX 8.0 - ActiveX Tree Control

Share Link
Print

ContextMenu Event, SftTree Object

The right mouse button is released or Shift-F10 is pressed requesting a context menu.

Syntax

VB.NETPrivate Sub object_ContextMenuEvent(ByVal sender As Object, ByVal e As EventArgumentType) Handles object.ContextMenuEvent
VBPrivate Sub object_ContextMenu(ByVal Button As Integer, ByVal Shift As Integer, ByVal x As OLE_XPOS_PIXELS, ByVal y As OLE_YPOS_PIXELS)
C#.NETvoid object_ContextMenuEvent(object sender, EventArgumentType e);
VC++void OnContextMenuobject(short Button, short Shift, OLE_XPOS_PIXELS x, OLE_YPOS_PIXELS y);
CHRESULT OnContextMenuobject(short Button, short Shift, OLE_XPOS_PIXELS x, OLE_YPOS_PIXELS y);

object

A SftTree object.

Button

The button that is pressed during the event (see SftTreeButtonConstants). The button argument is a bit field with bits corresponding to the left button, right button and middle button. These bits correspond to the values shown below. Only one of the bits is set, indicating the button that caused the event.

ButtonValueDescription
constSftTreeLeftButton1The left mouse button was pressed.
constSftTreeRightButton2The right mouse button was pressed.
constSftTreeMiddleButton4The middle mouse button was pressed.

Shift

The state of the SHIFT, CONTROL and ALT keys during the event (see SftTreeKeyConstants). A bit is set if the key is down. The Shift argument is a bit field with bits corresponding to the SHIFT, CONTROL and ALT keys. The Shift variable indicates the state of these keys. Some, all, or none of the bits can be set, indicating which of the keys are pressed.

ShiftValueDescription
constSftTreeShiftMask1The SHIFT key was pressed.
constSftTreeCtrlMask2The CONTROL key was pressed.
constSftTreeAltMask4The ALT key was pressed.

x

The x coordinate of the mouse cursor when the button was pressed. If x and y are -1, the user pressed Shift-F10.

y

The y coordinate of the mouse cursor when the button was pressed. If x and y are -1, the user pressed Shift-F10.

Comments

The ContextMenu event occurs when the right mouse button is released or Shift-F10 is pressed requesting a context menu.

An application can display a context menu in response to this event. Before displaying the popup menu, the CancelMode method must be called.

Examples

VB.NET

    End Sub

    Private Sub menuHeaderShowAll_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        AxSftTree1.ColumnsObj.MakeOptimal()
    End Sub

    Private Sub HeaderMenu(ByVal cursor As Point)

        Dim Menu As System.Windows.Forms.ContextMenu
        Menu = New ContextMenu()
        Dim mItem As System.Windows.Forms.MenuItem

        Dim Count As Integer
        Count = 0
        Dim C As Integer
        For C = 0 To AxSftTree1.ColumnsObj.Count - 1

C#

        }

        private void menuHeaderShowAll_Click(object sender, System.EventArgs e) {
            axSftTree1.ColumnsObj.MakeOptimal();
        }

        private void HeaderMenu(Point cursor) {

            System.Windows.Forms.ContextMenu menu = new ContextMenu();
            System.Windows.Forms.MenuItem mItem;

            int count = 0;
            for (short c = 0 ; c < axSftTree1.ColumnsObj.Count ; ++c) {
                mItem = new System.Windows.Forms.MenuItem();
                mItem.Text = axSftTree1.get_Header(c).Text;
                if (axSftTree1.get_Column(c).WidthPix > 0) {

C++

        m_vTree->Column[colIndex]->WidthPix = 0;
    else
        m_vTree->Column[colIndex]->MakeOptimal();
    m_vTree->Items->RecalcHorizontalExtent();
}

BEGIN_EVENTSINK_MAP(CBookTableDlg, CDialog)
    //{{AFX_EVENTSINK_MAP(CBookTableDlg)
    ON_EVENT(CBookTableDlg, IDC_SFTTREE1, 35 /* ContextMenu */, OnContextMenuSftTree1, VTS_I2 VTS_I2 VTS_I4 VTS_I4)
    ON_EVENT(CBookTableDlg, IDC_SFTTREE1, 4 /* ItemClick */, OnItemClickSftTree1, VTS_I4 VTS_I2 VTS_I2 VTS_I2 VTS_I2)
    ON_EVENT(CBookTableDlg, IDC_SFTTREE1, 5 /* ItemDblClick */, OnItemDblClickSftTree1, VTS_I4 VTS_I2 VTS_I2 VTS_I2 VTS_I2)
    //}}AFX_EVENTSINK_MAP
END_EVENTSINK_MAP()

BOOL CBookTableDlg::OnWndMsg(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pResult)
{

See Also SftTree Object | Object Hierarchy


Last Updated 05/24/2026 - (email)
© 2026 Softel vdm, Inc.