1

我在 Windows Mobile 6.5 应用程序的 Windows 窗体中使用主菜单控件。它是经过编程的,所以如果我扫描条形码,程序会将我带到不同的页面。但是,如果我在主菜单打开时扫描页面,我将无法再在子屏幕上打开主菜单。我尝试在我的解码器事件(隐藏菜单)中对父表单执行“单击”,但菜单仍然不会显示在子屏幕上。如何让菜单在子屏幕上再次工作?如果扫描时菜单未打开,它工作正常。

Public Shared Sub DecodeEvent(ByVal sender As System.Object, ByVal e As HandHeldProducts.Embedded.Decoding.DecodeAssembly.DecodeEventArgs, ByVal scanInformation As ICurrentScanInformation, ByVal dashboardScreenServiceClient As DashboardScreenServiceClient)
    Dim oDecodeAssembly As New DecodeAssembly
    If scanInformation IsNot Nothing AndAlso scanInformation.AllowedScans IsNot Nothing Then
        ShowOffenderDialog(scanInformation.ScreenName, CType(scanInformation, Form), sourceId, source, True, e.Message) 
    Else
        MsgBox.ExclamationMsg("This type of barcode scan is not allowed.")
    End If
End Sub


Public Shared Sub ShowOffenderDialog(ByVal parentScreenName As String, ByVal owner As Form, ByVal sourceId As System.Int32, ByVal source As System.String, ByVal scan As System.Boolean, Optional ByVal offenderCd As String = "")
    Try
        /*open up a new screen*/
        offenderDetails = New frmOffenderDetails(parentScreenName, offenderCd, sourceId, source, scan)
        offenderDetails.ShowDialog()

        owner.BringToFront()
    Catch ex As Exception
        Utility.DisplayApplicationMessage(parentScreenName, "ShowDialog", ex)
    End Try
End Sub

如果我跳过所有的 frmOffenderDetails 代码,菜单仍然不会显示,因此它与该表单没有任何关系。

4

1 回答 1

0

使用 RemoteSpy++,我确定菜单的名称是我设备上的 MNU。所以我使用以下代码来查找菜单:

解决方案 1(适用于霍尼韦尔掌上电脑设备):

Dim menuHandle As IntPtr = HandHeldProducts.Embedded.Utility.WinAPI.sysFindWindow("MNU", Nothing)

我无法通过在解码事件之前关闭菜单来修复 Honeywell Pocket PC 设备上的错误,所以我只是通知用户它已打开并在关闭菜单的情况下重试:

If Not menuHandle.ToInt64 = 0 Then
    MsgBox.ExclamationMsg("The menu must be closed before scanning a barcode. Please try your scan again with the menu closed.")
Else
    Decoder.DecodeEvent(sender, e, CurrentScanInformation, dashboardScreenServiceClient)
End If

解决方案2:

我没有尝试过,但假设如果您没有霍尼韦尔设备,您也可以 P/Invoke。

声明以下函数:

<DllImport("coredll.dll", EntryPoint:="FindWindow")> _
Private Shared Function FindWindow(ByVal lpClassName As String, _
                                   ByVal lpWindowName As String) As IntPtr
End Function

并像这样调用它来找到菜单的句柄:

Dim menuHandle As IntPtr = FindWindow("MNU", Nothing)

第二部分与解决方案1相同:

If Not menuHandle.ToInt64 = 0 Then
    MsgBox.ExclamationMsg("The menu must be closed before scanning a barcode. Please try your scan again with the menu closed.")
Else
    Decoder.DecodeEvent(sender, e, CurrentScanInformation, dashboardScreenServiceClient)
End If
于 2012-11-30T15:35:30.097 回答