|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
VBEvents ContextMenu MapObjects2I have a strange problem with MapObjects and ContextMenu when I show a context menu in the MouseDown event of a MapObjects2.1-Map something goes wrong: after the next DoubleClick on the map (it must be the one that caused the ContextMenu in MouseDown), this Map somehow catches all further MouseEvents until the Form looses focus. the Problem does not occur in any other event (mouseup, click, ...). the Problem does not occur with any other control I tried. the Problem does not occur when I use Me.PopupMenu does anyone know about this problem (or similiar problems) can anyone imagine why this happens thanks Peter ' ----------------------------------------------------- ' Form: Form1 ' Label: Label1 ' (ESRI) MapObjects2.Map: Map1 ' ----------------------------------------------------- Option Explicit Private Const MF_CHECKED = &H8& Private Const MF_APPEND = &H100& Private Const TPM_LEFTALIGN = &H0& Private Const TPM_RETURNCMD = &H100& Private Const TPM_RIGHTBUTTON = &H2& Private Const MF_DISABLED = &H2& Private Const MF_GRAYED = &H1& Private Const MF_SEPARATOR = &H800& Private Const MF_STRING = &H0& Private Type POINTAPI X As Long Y As Long End Type Private Declare Function CreatePopupMenu Lib "user32" () As Long Private Declare Function TrackPopupMenu Lib "user32" ( _ ByVal hMenu As Long, ByVal wFlags As Long, _ ByVal X As Long, ByVal Y As Long, ByVal nReserved As Long, _ ByVal hwnd As Long, ByVal lprc As Any) As Long Private Declare Function GetSystemMenu Lib "user32" ( _ ByVal hwnd As Long, ByVal bRevert As Long) As Long Private Declare Function AppendMenu _ Lib "user32" Alias "AppendMenuA" (ByVal hMenu As Long, _ ByVal wFlags As Long, ByVal wIDNewItem As Long, _ ByVal lpNewItem As Any) As Long Private Declare Function DestroyMenu Lib "user32" ( _ ByVal hMenu As Long) As Long Private Declare Function GetCursorPos Lib "user32" ( _ lpPoint As POINTAPI) As Long Private Sub Label1_MouseDown( _ Button As Integer, Shift As Integer, _ X As Single, Y As Single) Dim sMenuInfo As String Dim nRetVal As Long If Button = vbRightButton And Shift = 0 Then sMenuInfo = "Item1|1;Item2|2" nRetVal = showContextMenu(Me.hwnd, sMenuInfo) End If End Sub Private Sub Map1_MouseDown( _ Button As Integer, Shift As Integer, _ X As Single, Y As Single) Dim sMenuInfo As String Dim nRetVal As Long If Button = vbRightButton And Shift = 0 Then sMenuInfo = "ItemA|100;ItemB|200" nRetVal = showContextMenu(Me.hwnd, sMenuInfo) End If End Sub Public Function showContextMenu( _ hwnd As Long, _ sMenuDescription As String _ ) As Long On Error GoTo Proc_Error Dim uPt As POINTAPI Dim asMenuItems() As String Dim nCurrItem As Long Dim sCurrItem As String Dim nSelectedItem As Long Dim sCaption As String Dim nMenuItemStyle As Long Dim nLastPipePosition As Long Dim hMenu As Long Dim nItemID As Long Dim nRetVal As Long hMenu = CreatePopupMenu() If hMenu = 0 Then Err.Raise 1001, , "Could not create ContextMenu." End If asMenuItems = Split(sMenuDescription, ";") For nCurrItem = 0 To UBound(asMenuItems) sCurrItem = asMenuItems(nCurrItem) nLastPipePosition = InStrRev(sCurrItem, "|") nItemID = -1 If nLastPipePosition > 0 Then sCaption = Left$(sCurrItem, nLastPipePosition - 1) On Error Resume Next nItemID = CLng(Mid$(sCurrItem, nLastPipePosition + 1)) On Error GoTo Proc_Error If sCaption = "-" Then nMenuItemStyle = MF_SEPARATOR sCaption = vbNullString Else nMenuItemStyle = MF_STRING End If If nItemID < 0 Then nMenuItemStyle = MF_GRAYED Or MF_DISABLED End If Else sCaption = sCurrItem nMenuItemStyle = MF_GRAYED Or MF_DISABLED End If AppendMenu hMenu, nMenuItemStyle, nItemID, sCaption Next GetCursorPos uPt nSelectedItem = TrackPopupMenu( _ hMenu, TPM_LEFTALIGN Or TPM_RETURNCMD Or TPM_RIGHTBUTTON, _ uPt.X, uPt.Y, ByVal 0&, hwnd, ByVal 0&) nRetVal = DestroyMenu(hMenu) hMenu = 0 showContextMenu = nSelectedItem Proc_Exit: Exit Function Proc_Error: MsgBox "Error in showContextMenu" & Err.Description, vbCritical End Function Peter Plumber schrieb:
Show quoteHide quote > Hi, PS.:> > I have a strange problem with MapObjects and ContextMenu > when I show a context menu in the MouseDown event of > a MapObjects2.1-Map something goes wrong: > > after the next DoubleClick on the map (it must be the one > that caused the ContextMenu in MouseDown), this Map somehow > catches all further MouseEvents until the Form looses focus. > > the Problem does not occur in any other event (mouseup, click, ...). > the Problem does not occur with any other control I tried. > the Problem does not occur when I use Me.PopupMenu > > does anyone know about this problem (or similiar problems) > can anyone imagine why this happens > > thanks > > Peter I think the the MapObjects-Map some looses the MouseUp-event. On Fri, 24 Mar 2006 12:21:29 +0100, Peter Plumber
<Klemp***@gmxdot.net> wrote: >I have a strange problem with MapObjects and ContextMenu I don't have MapObjects here, so this is a guess, but you could try>when I show a context menu in the MouseDown event of >a MapObjects2.1-Map something goes wrong: > >after the next DoubleClick on the map (it must be the one >that caused the ContextMenu in MouseDown), this Map somehow >catches all further MouseEvents until the Form looses focus. > >the Problem does not occur in any other event (mouseup, click, ...). >the Problem does not occur with any other control I tried. >the Problem does not occur when I use Me.PopupMenu calling ReleaseCapture after TrackPopupMenu returns. Also displaying a menu in a MouseDown is a bit unusual. Be interesting to see if the problem also occurs if moved to a MouseUp. -Tom MVP - Visual Basic (please post replies to the newsgroup) Tom Esh schrieb:
Show quoteHide quote > On Fri, 24 Mar 2006 12:21:29 +0100, Peter Plumber as I alread wrote, this problem occurs only in the MouseDown-event.> <Klemp***@gmxdot.net> wrote: > > >>I have a strange problem with MapObjects and ContextMenu >>when I show a context menu in the MouseDown event of >>a MapObjects2.1-Map something goes wrong: >> >>after the next DoubleClick on the map (it must be the one >>that caused the ContextMenu in MouseDown), this Map somehow >>catches all further MouseEvents until the Form looses focus. >> >>the Problem does not occur in any other event (mouseup, click, ...). >>the Problem does not occur with any other control I tried. >>the Problem does not occur when I use Me.PopupMenu > > > > I don't have MapObjects here, so this is a guess, but you could try > calling ReleaseCapture after TrackPopupMenu returns. Also displaying a > menu in a MouseDown is a bit unusual. Be interesting to see if the > problem also occurs if moved to a MouseUp. > > > -Tom > MVP - Visual Basic > (please post replies to the newsgroup) calling it in MouseUp or Click does not show this behavior. ReleaseCapture seem not to cure the problem. a lot of LINUX programs show a context-menu in MouseDown (I have not found anything else so far) but you are right, Windows standard seems to be Mouseup (I never noticed this, and there are some programs that handle context-menues in mous down) Peter
AND Operator and Currency data type
FTP(not boring) Produktlokalisierung - wie funktioniert's? Consume Web Map Service (WMS) with VB6 "Save As" question & file extensions list of files in directories? Obtain MCSE certificaiton without exams(Pay after check results)100% passing gaurantee Syntax Error - Missing Operator - When Using Date ! 3 problems VB.NET throws "Application is ambiguous" exception |
|||||||||||||||||||||||