Datalogic .NET SDK

PostRequestMsgEx (Method)

 

Syntax

 

    public int PostRequestMsgEx(DecodeRequest reqType, MessageWindow wnd, uint uDataMsg, uint uTimeoutMsg);

 

 

Class                           : DecodeHandle

Namespace                : Datalogic.API

Assembly                   : Datalogic.API.DLL

 

 

Description

Posts a request for data from a decoding device. The method will return immediately, and post a message to the specified window when either the request is fulfilled or the scan times out.

 

Parameters Table

 

Type

Parameter

Description

[in]

DecodeRequest

reqType

Type of request being posted. It is a logical OR'ing of any of the values.

[in]

MessageWindow

wnd

A reference to an instance of the Microsoft.WindowsCE.Forms.MessageWindow class whose window procedure is to receive a message when the request is fulfilled.

[in]

uint

uDataMsg

Specifies the message to be posted when the request is fulfilled. This should be a value of WM_USER (defined in winuser.h) or higher.

[in]

uint

uTimeoutMsg

Specifies the message to be posted if the scan times out before the request is fulfilled. This should be a value of WM_USER (defined in winuser.h) or higher.

 

 

 

 

[return]

int

 

On success, a request ID is returned. This should be used in a subsequent call Datalogic.API.DecodeHandle.ReadString and/or Datalogic.API.DecodeHandle.CancelRequest.

[on error]

-1

 

-

 

 

Example

This example shows the noteworthy code lines to rise and manage a Request message: the message is sent to a customized MessageWindows that is able to manage our custom message (see WM_SCANNED) adding functionalities to WinProc method of standard MessageWindow Class.

(See Example page for the complete and executable example)

 

// Standard using ...

using Microsoft.WindowsCE.Forms;

using Datalogic.API;

 

namespace Example

{

       public class MainDlg : System.Windows.Forms.Form

       {

          // Private variables used for our sample

          private WndMessageWindow wndMsg;

          private DecodeHandle hDcd;

          private int reqID;

          // Other...

         

         public MainDlg() { /*...*/ }

 

         private void MainDlg_Load(object sender, System.EventArgs e)

         {

            try

            {

               hDcd = new DecodeHandle(DecodeDeviceCap.Exists |

                                       DecodeDeviceCap.Barcode);

            }catch(DecodeException){ /*...*/ }

      

            DecodeRequest reqType = (DecodeRequest)1 | DecodeRequest.PostRecurring;

      

            reqID = hDcd.PostRequestMsgEx(reqType,

                                          wndMsg,

                                          Constants.WM_SCANNED,

                                          Constants.WM_TIMEOUT);

         }

 

         /* Other methods and settings ...*/   

         // ...

         public class WndMessageWindow : MessageWindow

         {

             // Reference to the window we will subclass.

             private MainDlg dlgParent;

 

             public WndMessageWindow(MainDlg frm)

             {

                    this.dlgParent = frm;

             }

             protected override void WndProc(ref Message msg)

             {

                    switch(msg.Msg)

                    {

                           case Constants.WM_SCANNED:

                                  // Action to be performed ...    

                                  break;

                           case Constants.WM_TIMEOUT:

                                  // Action to be performed ...    

                                  break;

 

                    }

                    base.WndProc(ref msg);

             }

         }

         internal sealed class Constants

         {

             public const int WM_APP = 0x8000;

             public const int WM_SCANNED = WM_APP + 1;

             public const int WM_TIMEOUT = WM_APP + 2;

         }
   
 }

}

 

 

See Also

DecodeHandle.ReadString (Method), DecodeRequest (Enum), Microsoft.WindowsCE.Forms.MessageWindow, WM_USER,  DecodeHandle.CancelRequest (Method), Example #016.

 

Copyright © Datalogic ADC. All Right Reserved