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.

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:

*>>>> 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-2011 Exontrol.COM, Software. All rights reserved.