Hide

SftTree/OCX 7.5 - ActiveX Tree Control

Display
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

    Private Sub menuItem3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles menuItem3.Click
        MessageBox.Show("This sample doesn't implement any actions for the item menu.  Try the column headers instead.")
    End Sub

    Private Sub menuItem4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles menuItem4.Click
        MessageBox.Show("This sample doesn't implement any actions for the item menu.  Try the column headers instead.")
    End Sub

    Private Sub AxSftTree1_ContextMenuEvent(ByVal sender As Object, ByVal e As AxSftTreeLib75._DSftTreeEvents_ContextMenuEvent) Handles AxSftTree1.ContextMenuEvent
        Dim P As Point
        P = AxSftTree1.PointToScreen(New Point(e.x, e.y))

        ' Determine click context menu for header or item
        Dim L As Integer, T As Integer, H As Integer, W As Integer
        AxSftTree1.Headers.GetPositionPix(L, T, W, H)
        If e.x >= L And e.x < L + W And e.y >= T And e.y <= T + H Then

VB6

    End If

    MenuForm.ShowAll.Enabled = Count < 3

    SftTree1.CancelMode
    PopupMenu MenuForm.HeaderPopup
End Sub

Private Sub SftTree1_ContextMenu(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)

    ' Determine click context menu for header or item
    Dim l As Single, t As Single, h As Single, w As Single
    SftTree1.Headers.GetPosition l, t, w, h
    If X >= l And X < l + w And Y >= t And Y <= t + h Then
        HeaderMenu
        Exit Sub

C#

        private void menuItem3_Click(object sender, System.EventArgs e) {
            MessageBox.Show("This sample doesn't implement any actions for the item menu.  Try the column headers instead.");
        }

        private void menuItem4_Click(object sender, System.EventArgs e) {
            MessageBox.Show("This sample doesn't implement any actions for the item menu.  Try the column headers instead.");
        }

        private void axSftTree1_ContextMenuEvent(object sender, AxSftTreeLib75._DSftTreeEvents_ContextMenuEvent e)
        {
            Point point = axSftTree1.PointToScreen(new Point(e.x, e.y));

            // Determine click context menu for header or item
            int l, t, h, w;
            axSftTree1.Headers.GetPositionPix(out l, out t, out w, out h);
            if (e.x >= l && e.x < l + w && e.y >= t && e.y <= t + h) {

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()

See Also SftTree Object | Object Hierarchy


Last Updated 08/13/2020 - (email)
© 2024 Softel vdm, Inc.