Control.MousePosition & ContextMenu Problem

  • Thread starter Thread starter yououtthere
  • Start date Start date
Y

yououtthere

Hello All,

I have looked back through the postings in this group and there seems to be
a recognised problem with getting the MousePosition for a control when a
ContextMenu is assigned to that control. It seems that a tap 'n hold event
does not update the MousePosition. There doesn't seem to be a problem when
using the emulator only when running code on an actual device. The following
code shows this problem.

Private Sub ctxList_Popup(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles ctxList.Popup

Dim hti As System.Windows.Forms.DataGrid.HitTestInfo

mousePoint = Me.grdList.PointToClient(Control.MousePosition)
hti = grdList.HitTest(mousePoint.X, mousePoint.Y)
If hti.Type = DataGrid.HitTestType.ColumnHeader Then
MsgBox("Header")
Else
MsgBox("Not Header")
End If

End Sub

When you click on a column header you will occasionally get the correct
message. I have not been able to find a resolution to this problem - Has any
one else? This seems to me to be a major Bug, but maybe that's because I
need the functionality.

TIA

Geoff
 
I have had a similar problem but not exactly what your
experiencing, including the "working on the emu but not
device". Try overriding the onMouseDown of the control
and saving those x,y values to a Point member variable.
Use this member variable when you show your context menu.
It's a little more work but it's working good for me so
far.

HTH
Mark Arteaga
 
I believe it's possible to use GetMouseMovePoints API to
get a more up-to-date mouse position. I'll probably post
in my blog a code sample on how to do that...
 
Back
Top