Share via


方法 : 通知を送信します。

[このドキュメントはプレビュー版であり、後のリリースで変更されることがあります。 空白のトピックは、プレースホルダーとして挿入されています。]

ユーザー データを送信するメッセージを表示するなど、アプリケーション内のアクションを考慮するたびに、Notification を使用できます。 通常、ときに通知イベントの発生または条件が満たさが、次の使用説明を簡単にするために、例、通知とき表示ボタンがクリックされたします。 ResponseSubmitted イベントを処理するコードを提供して通知への応答を処理することができます。

通知でメッセージは、プレーン テキスト、または HTML です。 HTML では、チェック ボックス、ボタン、リスト、およびその他の HTML 要素を含む小さな HTML フォームを送信できます。 この例では、単純なフォームを使用して送信の キャンセル ボタンとします。

キャンセル ボタンは、"cmd:2"、通知を消すには Windows CE を使用するによって識別されます。 cmd:2 が、メッセージ バルーンの HTML ボタンまたは他の要素の名前の場合、ResponseSubmitted イベントは発生しません。 通知が消されたがそのアイコンがタイトル バーに配置されますは後で応答できます。

通知を送信するには

  1. Pocket PC の Windows アプリケーションを作成します。

  2. フォームに Notification および Button を追加します。

  3. Notification インスタンスを作成します。

                                Me.Notification1 = New Microsoft.WindowsCE.Forms.Notification
    
                                this.notification1 = new Microsoft.WindowsCE.Forms.Notification();
    
  4. ボタンの Click イベントを処理次のコード追加します。

                                Private
                                Sub Button1_Click(ByVal sender As System.Object, _
        ByVal e As System.EventArgs) Handles Button1.Click
    
        ' Use a StringBuilder for better performance.Dim HTMLString AsNew StringBuilder
    
        HTMLString.Append("<html><body>")
        HTMLString.Append("Submit data?")
        HTMLString.Append("<form method=\'GET\' action=notify>")
        HTMLString.Append("<input type='submit'>")
        HTMLString.Append( _
            "<input type=button name='cmd:2' value='Cancel'>")
        HTMLString.Append("</body></html>")
    
        ' Set the Text property to the HTML string.
        Notification1.Text = HTMLString.ToString()
    
        Dim IconStream AsNew FileStream(".\My Documents\notify.ico", _
            FileMode.Open, FileAccess.Read)
        Notification1.Icon = new Icon(IconStream, 16, 16)
        Notification1.Caption="Notification Demo"
        Notification1.Critical = false
    
        ' Display icon up to 10 seconds.
        Notification1.InitialDuration = 10
        Notification1.Visible = true
    EndSub
    
                                private
                                void button1_Click(object sender, System.EventArgs e)
    {
    
        StringBuilder HTMLString = new StringBuilder();
        HTMLString.Append("<html><body>");
        HTMLString.Append("Submit data?");
        HTMLString.Append("<form method=\'GET\' action=notify>");
        HTMLString.Append("<input type='submit'>");
        HTMLString.Append("<input type=button name='cmd:2' value='Cancel'>");
        HTMLString.Append("</body></html>");
    
        //Set the Text property to the HTML string.
        notification1.Text = HTMLString.ToString();
    
        FileStream IconStream = new FileStream(".\\My Documents\\notify.ico",
            FileMode.Open, FileAccess.Read);
        notification1.Icon = new Icon(IconStream, 16, 16);
        notification1.Caption="Notification Demo";
        notification1.Critical = false;
    
        // Display icon up to 10 seconds.
        notification1.InitialDuration = 10;
        notification1.Visible = true;
    }
    
  5. ResponseSubmitted イベントを処理する次のコード追加します。

                                ' When a ResponseSubmitted event occurs, this event handler
                                ' parses the response to determine values in the HTML form.
                                Private
                                Sub Notification1_ResponseSubmitted(ByVal sender AsObject, _
        ByVal resevent As Microsoft.WindowsCE.Forms.ResponseSubmittedEventArgs) _
        Handles Notification1.ResponseSubmitted
    
        If resevent.Response.Substring(0,6) = "notify"Then        ' Add code here to respond to the notification.EndIfEndSub
    
                                // When a ResponseSubmitted event occurs, this event handler
                                // parses the response to determine values in the HTML form.
    notification1.ResponseSubmitted += 
        delegate (object obj, ResponseSubmittedEventArgs resevent)
        {
            if (resevent.Response.Substring(0,6) == "notify")
            {
                // Add code here to respond to the notification.
            }
        };
    

コードのコンパイル方法

この例では、次の名前空間への参照が必要です。

参照

処理手順

Notification Sample

参照

Notification

その他の技術情報

Pocket PC の開発と、.NET Framework を最適化します。