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 (Honeywell Pocket PC デバイスの場合):

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:

試したことはありませんが、Honeywell デバイスを持っていない場合は 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)

2 番目の部分はソリューション 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 に答える