event Select (ID as Long)
Occurs when an item is selected by clicking or by pressing RETURN key.

 TypeDescription 
   ID as Long A long expression that indicates the item's identifier.  

Use the Select event to notify your application that a new item was selected. Use the Item property to retrieve the item giving its identifier. Use the SelectOn property to specify whether the control selects an item if the user presses or releases the mouse button. Use the Caption property to specify the caption of the item. The control sends the WM_COMMAND message to the parent window, where the wParam is the ID ( identifier ) of the item being clicked.

Syntax for Select event, /NET version, on:

private void Select(object sender,int ID)
{
}

Private Sub Select(ByVal sender As System.Object,ByVal ID As Integer) Handles Select
End Sub

Syntax for Select event, /COM version, on:

private void Select(object sender, AxEXMENULib._IMenuEvents_SelectEvent e)
{
}

void OnSelect(long ID)
{
}

void __fastcall Select(TObject *Sender,long ID)
{
}

procedure Select(ASender: TObject; ID : Integer);
begin
end;

procedure Select(sender: System.Object; e: AxEXMENULib._IMenuEvents_SelectEvent);
begin
end;

begin event Select(long ID)
end event Select

Private Sub Select(ByVal sender As System.Object, ByVal e As AxEXMENULib._IMenuEvents_SelectEvent) Handles Select
End Sub

Private Sub Select(ByVal ID As Long)
End Sub

Private Sub Select(ByVal ID As Long)
End Sub

LPARAMETERS ID

PROCEDURE OnSelect(oExMenu,ID)
RETURN

Syntax for Select event, /COM version (others), on:

<SCRIPT EVENT="Select(ID)" LANGUAGE="JScript">
</SCRIPT>

<SCRIPT LANGUAGE="VBScript">
Function Select(ID)
End Function
</SCRIPT>

Procedure OnComSelect Integer llID
	Forward Send OnComSelect llID
End_Procedure

METHOD OCX_Select(ID) CLASS MainDialog
RETURN NIL

void onEvent_Select(int _ID)
{
}

function Select as v (ID as N)
end function

function nativeObject_Select(ID)
return

In VFP9, if using the _SCREEN.AddObject on modal forms, the Select may not be fired, instead you can use the BINDEVENT to collect the WM_COMMAND messages as shown in the following sample. The lParam of the WM_COMMAND message is 0 for the Select event.

*>>>> This is a replacement for the Select event using the BINDEVENT command
LOCAL _aka
_aka = CREATEOBJECT("AKA")
BINDEVENT( _SCREEN.hWnd, 273, _aka, "myselect" )
*<<<< BINDEVENT

where the AKA object could be as:

DEFINE class AKA as Custom

 function myselect(m,h,w,p)
    MESSAGEBOX(STR(w),64, "Your command's identifier is:")
    return 0
  endfunc

ENDDEFINE

The following VB sample displays the caption of the item being selected:

Private Sub ExMenu1_Select(ByVal ID As Long)
    ' The user has selected an item
    Debug.Print "You have selected '" & ExMenu1(ID).Caption & "'"
End Sub

The following Javascript sample displays the caption of the item being selected:

<SCRIPT FOR="ExMenu1" EVENT="Select(id)" LANGUAGE="javascript">
 
 obj = document.getElementById ( "ExMenu1" );
 window.alert(obj.Item(id).Caption);
 
</SCRIPT>

The following C++ sample displays the caption of the item being selected:

void OnSelectExmenu1(long ID) 
{
	OutputDebugString( m_menu.GetItem( COleVariant(ID) ).GetCaption() );
}

The following VB.NET sample displays the caption of the item being selected:

Private Sub AxExMenu1_SelectEvent(ByVal sender As System.Object, ByVal e As AxEXMENULib._IMenuEvents_SelectEvent) Handles AxExMenu1.SelectEvent
    Debug.WriteLine(AxExMenu1.item(e.iD).Caption)
End Sub

The following C# sample displays the caption of the item being selected:

private void axExMenu1_SelectEvent(object sender, AxEXMENULib._IMenuEvents_SelectEvent e)
{
	System.Diagnostics.Debug.WriteLine(axExMenu1[e.iD].Caption);
}

The following VFP sample displays the caption of the item being selected:

*** ActiveX Control Event ***
LPARAMETERS id

with thisform.ExMenu1.Item(id)
	wait window nowait .Caption
endwith

 


Send comments on this topic.
1999-2015 Exontrol.COM, Software. All rights reserved.