myForm.myListView.SelectedItem.Selected=.t.Or in the ListView's ITemClick Method:
PROCEDURE itemclick(loItem) IF loItem.key#this.tag IF this.tag=[x] this.HideSelection=.f. ENDIF loItem.Selected=.t. loItem.EnsureVisible ENDIF ENDPROCIn this case, you would not need the hittest. You could just take the "node" info and run a GUI or a popup menu.
public unLTVX,unLTVY && Twip metric scalars DeclareWindowsAPIFunctions() && Run these first to assign unLTVX and unLTVY GetDisplayMetrics() PROCEDURE DeclareWindowsAPIFunctions() declare integer GetActiveWindow in WIN32API declare integer GetDC in WIN32API integer iHDC declare integer GetDeviceCaps in WIN32API integer iHDC,integer iIndex ENDPROC &&R6_PSA_DeclareWindowsAPIFunctions procedure GetDisplayMetrics() local liHwnd,liHDC,liPixelsPerInchX,liPixelsPerInchY liHwnd=GetActiveWindow() liHDC=GetDC(liHwnd) * Pixels per Inch liPixelsPerInchX=GetDeviceCaps(liHDC,88) liPixelsPerInchY=GetDeviceCaps(liHDC,90) * Twips per pixel and store unLTVX=1440/liPixelsPerInchX &&The twips scaling are now in the public unLTVY=1440/liPixelsPerInchY && vars, unLTVX and unLTVYNow that you have your scalars, you can fire a hittest in your mousemove:
PROCEDURE MouseMove(button, shift, x, y) * Implements a scanning preview of the the * of the ListView nodes when the chkHotTracker is true. *(You may not want to fire it all the time IF thisform.chkHotTracker.Value=1 oNode=this.HitTest(X*unLTVX,Y*unltvY) && See the scalars! IF type('oNode.text')==[C] && A hit! this.ItemClick(oNode) && Run the item click(above) ENDIF &&type('oNode.text')==[C] ENDIF &&.chkHotTracker.Value=1 ENDPROC &&MouseMoveIf the goal is to fire a popup - you will have to define it depending on the node you hit.
PROCEDURE mouseup (button, shift, x, y) if button=2 external array aMSL && MultiSelectList container filled in another proc this.hideselection=.f. llMultiSelected=TestForMulitiSelects(thisform,this) oTagNameNode; =this.ListItems(this.selecteditem.key).ListSubitems(this.COLUMNHEADERS([myListCol]).SubItemIndex) oTagValueNode; =this.ListItems(this.selecteditem.key).ListSubitems(this.COLUMNHEADERS([OtherCol]).SubItemIndex) cTagName=iif(llMultiSelected,[Multiple Items Selected],oTagNameNode.text) cTagKey=iif(llMultiSelected,[_MULTIBLE],this.selecteditem.key) Define_ItemPopUpMenu(thisform,cTagName) && See Below * Now, open the popup - see below after definition OpenPopUP_Menu_Item(y/10,x,thisform,this.object,cTagName,cTagKey,llMultiSelected) ulRightButtonDown=.F. && A control for multiple right mouses && The menu opens to select - then loses && Then opens to paste endif endprocDefine the ItemPopUpMenu:
PROCEDURE Define_ItemPopUpMenu(oform,lcTagName) DEFINE POPUP pop_Item MARGIN RELATIVE shortcut TITLE lcTagName COLOR SCHEME 4 ENDPROC &&Define_ItemPopUpMenu(oform,lcTagName)And the ItemPopUpMenu definition might look like this:
PROCEDURE OpenPopUP_Menu_Item(nRow,nCol,oform,oListView,lcTagName,lcTagKey,lMulti) push key clear *Note variables beginning with "U" are public vars DEFINE BAR 1 OF pop_Item PROMPT 'Insert '+ucCopy_Key+' \<before '+lcTagKey key ALT+B, "ALT+B" ; skip for ucActionStatus#[MOVE] or lcTagKey=[_MULTIBLE] DEFINE BAR 2 OF pop_Item PROMPT '\<Insert '+ucCopy_Key+' after '+lcTagKey key ALT+I, "ALT+I" ; skip for ucActionStatus#[MOVE] or lcTagKey=[_MULTIBLE] ON SELECTION BAR 1 of pop_Item DO pop_InsertItem with oform,lcTagKey,.F. && Before ON SELECTION BAR 2 of pop_Item do pop_InsertItem with oform,lcTagKey,.T. && AFter ACTIVATE popup pop_Item at nRow,nCol DEACTIVATE POPUP pop_Item pop key ENDPROC &&OpenPopUP_Menu_Item(nRow,nCol,oform,oT2CF,lcTagName,lcTagKey,lMulti)If you want more infor ion Hittest - Download RIO.ZIP on the UT. Don't pay attention to the VFP 7 message (disable it in the source code if you want). Use messageboxes to help you understand what is happening. And - if you can - build a simple model with a test form and ListView and the drive it from COMMAND WINDOW - it sure saves time that re-runing a PRG will cost - just to find you misspelled a reference or skipped a comma!