Exemplo n.º 1
0
        /// <summary>
        /// Gets the lines of text in a text box control.
        /// </summary>
        /// <param name="textBox">The <see cref="TextBox"/> control.</param>
        /// <returns>An array of strings that contains the text in a text box control.</returns>
        public static string[] GetLines(this TextBox textBox)
        {
            if (textBox == null)
            {
                throw new ArgumentNullException("textBox");
            }

            Microsoft.WindowsCE.Forms.Message m = Microsoft.WindowsCE.Forms.Message.Create(textBox.Handle, EM_GETLINECOUNT, IntPtr.Zero, IntPtr.Zero);
            Microsoft.WindowsCE.Forms.MessageWindow.SendMessage(ref m);
            int count = m.Result.ToInt32();

            string[] lines = new string[count];
            if (count > 0)
            {
                IntPtr buffer = Marshal.AllocHGlobal(512);
                for (int i = 0; i < count; i++)
                {
                    Marshal.WriteInt16(buffer, 0x255);
                    Microsoft.WindowsCE.Forms.Message ml = Microsoft.WindowsCE.Forms.Message.Create(textBox.Handle, EM_GETLINE, (IntPtr)i, buffer);
                    Microsoft.WindowsCE.Forms.MessageWindow.SendMessage(ref ml);
                    int lineLen = ml.Result.ToInt32();
                    lines[i] = Marshal.PtrToStringUni(buffer, lineLen);
                }
                Marshal.FreeHGlobal(buffer);
            }
            return(lines);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Event handler for registered messages forwarding the event
 /// </summary>
 private static void _messageWindow_OnRegisteredMessage(ref Microsoft.WindowsCE.Forms.Message message)
 {
     if (OnRegisteredMessage != null)
     {
         OnRegisteredMessage(ref message);
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// Appends text to the current text of a text box.
        /// </summary>
        /// <param name="textBox">The <see cref="TextBox"/> control.</param>
        /// <param name="text">The text to append to the current contents of the text box.</param>
        public static void AppendText(this TextBox textBox, string text)
        {
            if (textBox == null)
            {
                throw new ArgumentNullException("textBox");
            }

            if (string.IsNullOrEmpty(text))
            {
                throw new ArgumentNullException("text");
            }

            IntPtr pText = MarshalInTheHand.StringToHGlobalUni(text);

            try
            {
                textBox.SelectionStart = textBox.TextLength;
                Microsoft.WindowsCE.Forms.Message m = Microsoft.WindowsCE.Forms.Message.Create(textBox.Handle, EM_REPLACESEL, new IntPtr(-1), pText);
                Microsoft.WindowsCE.Forms.MessageWindow.SendMessage(ref m);
            }
            finally
            {
                Marshal.FreeHGlobal(pText);
            }
        }
Exemplo n.º 4
0
        private void FormMain_Load(
            object sender,
            System.EventArgs e)
        {
            // Textbox origin is (-1,-1)
            // Adjust textbox size to available screen space.
            // Add *two* to hide right and bottom borders.
            textEditor.Width = this.Width + 2;
            SetEditorHeight();

            // Set focus to text box window.
            textEditor.Focus();

            // Fetch window handle of text box.
            IntPtr hwndEditor = GetFocus();

            // Create message structure for sending Win32 messages
            m_msg = Message.Create(hwndEditor, 0, IntPtr.Zero,
                                   IntPtr.Zero);

            // MessageWindow-derived object receives MouseDown
            m_emw = new EventGrabberWindow(textEditor, hwndEditor);

            // Event grabber sends MouseDown event
            m_eg = new EventGrabber(hwndEditor, m_emw,
                                    EVENT_MOUSEDOWN);
        }
Exemplo n.º 5
0
        protected override void OnNotifyMessage(ref Microsoft.WindowsCE.Forms.Message m)
        {
            if (m.Msg == 0x004E)
            {
                NMHDR nh = (NMHDR)Marshal.PtrToStructure(m.LParam, typeof(OpenNETCF.Win32.NMHDR));
            }

            base.OnNotifyMessage(ref m);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Message notification for InkX
        /// </summary>
        /// <param name="m"></param>
        protected override void OnNotifyMessage(ref Microsoft.WindowsCE.Forms.Message m)
        {
            if (!OpenNETCF.Windows.Forms.StaticMethods.IsDesignMode(this))
            {
                //I wonder what was intended here...
                NMHDR nh = (NMHDR)Marshal.PtrToStructure(m.LParam, typeof(OpenNETCF.Win32.NMHDR));

                base.OnNotifyMessage(ref m);
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Copies the current selection of the text editing control to the Clipboard.
        /// </summary>
        /// <param name="textBox">The <see cref="TextBox"/> control.</param>
        /// <remarks>A copy operation copies the selected text to the Clipboard.
        /// Note that the selected text is not removed from the text editing control in the process.
        /// A similar method, <see cref="Cut"/>, moves the current selection to the Clipboard and removes the selected text from the text editing control in the process.</remarks>
        public static void Copy(this TextBox textBox)
        {
            if (textBox == null)
            {
                throw new ArgumentNullException("textBox");
            }

            Microsoft.WindowsCE.Forms.Message m = Microsoft.WindowsCE.Forms.Message.Create(textBox.Handle, WM_COPY, IntPtr.Zero, IntPtr.Zero);
            Microsoft.WindowsCE.Forms.MessageWindow.SendMessage(ref m);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Clears information about the most recent operation from the undo buffer of the text box.
        /// </summary>
        /// <param name="textBox">The <see cref="TextBox"/> control.</param>
        /// <remarks>You can use this method to prevent an undo operation from repeating, based on the state of your application.</remarks>
        /// <returns></returns>
        public static void ClearUndo(this TextBox textBox)
        {
            if (textBox == null)
            {
                throw new ArgumentNullException("textBox");
            }

            Microsoft.WindowsCE.Forms.Message m = Microsoft.WindowsCE.Forms.Message.Create(textBox.Handle, EM_EMPTYUNDOBUFFER, IntPtr.Zero, IntPtr.Zero);
            Microsoft.WindowsCE.Forms.MessageWindow.SendMessage(ref m);
        }
        private IntPtr Callback(IntPtr hWnd, uint msg, IntPtr wparam, IntPtr lparam)
        {
            Microsoft.WindowsCE.Forms.Message message = Microsoft.WindowsCE.Forms.Message.Create(hWnd, (int)msg, wparam, lparam);
            this.WndProc(ref message);

            if (msg == 130)
            {
                this.ReleaseHandle();
            }
            return(message.Result);
        }
Exemplo n.º 10
0
 protected override void WndProc(ref Microsoft.WindowsCE.Forms.Message m)
 {
     foreach (IMessageFilter filter in filters)
     {
         if (filter.PreFilterMessage(ref m))
         {
             return;
         }
     }
     base.WndProc(ref m);
 }
Exemplo n.º 11
0
        /// <summary>
        /// Retrieves the line number from the specified character position within the text of the control.
        /// </summary>
        /// <param name="textBox">The <see cref="TextBox"/> control.</param>
        /// <param name="index">The character index position to search.</param>
        /// <returns>The zero-based line number in which the character index is located.</returns>
        public static int GetLineFromCharIndex(this TextBox textBox, int index)
        {
            if (textBox == null)
            {
                throw new ArgumentNullException("textBox");
            }

            Microsoft.WindowsCE.Forms.Message m = Microsoft.WindowsCE.Forms.Message.Create(textBox.Handle, EM_LINEFROMCHAR, (IntPtr)index, IntPtr.Zero);
            Microsoft.WindowsCE.Forms.MessageWindow.SendMessage(ref m);
            return(m.Result.ToInt32());
        }
 /// <summary>
 /// Invokes the default window procedure associated with this window.
 /// It is an error to call this method when the <see cref="Handle"/> property is 0.
 /// </summary>
 /// <param name="m">A <see cref="Message"/> that is associated with the current Windows message.</param>
 public void DefWndProc(ref Microsoft.WindowsCE.Forms.Message m)
 {
     if (this.defWindowProc == IntPtr.Zero)
     {
         m.Result = NativeMethods.DefWindowProc(m.HWnd, m.Msg, m.WParam, m.LParam);
     }
     else
     {
         m.Result = NativeMethods.CallWindowProc(this.defWindowProc, m.HWnd, (uint)m.Msg, m.WParam, m.LParam);
     }
 }
Exemplo n.º 13
0
        // End -- SHRecognizeGesture declarations.

        protected override void WndProc(
            ref Microsoft.WindowsCE.Forms.Message msg)
        {
            switch (msg.Msg)
            {
            case WM_MOUSEMOVE:
                break;

            case WM_LBUTTONDOWN:
                int xyBundle = (int)msg.LParam;
                int x        = xyBundle & 0xffff;
                int y        = (xyBundle >> 16);

                SHRGINFO shinfo;
                shinfo            = new SHRGINFO();
                shinfo.cbSize     = Marshal.SizeOf(shinfo);
                shinfo.hwndClient = m_hwndTarget;
                shinfo.ptDown.X   = x;
                shinfo.ptDown.Y   = y;
                shinfo.dwFlags    = SHRG_RETURNCMD;

                if (SHRecognizeGesture(ref shinfo) == GN_CONTEXTMENU)
                {
                    Point pt  = new Point(x, y);
                    Point pt2 = m_ctrlTarget.PointToScreen(pt);
                    m_ctrlTarget.ContextMenu.Show(m_ctrlTarget, pt2);

                    // We handle event.
                    // Do not pass to original wndproc
                    msg.Result = IntPtr.Zero;
                }
                else
                {
                    // Tell handler to send to original wndproc
                    msg.Result = (IntPtr)1;
                }
                break;

            case WM_LBUTTONUP:
                break;

            case WM_KEYDOWN:
                break;

            case WM_KEYUP:
                break;

            case WM_CHAR:
                break;
            } // switch
        }     // WndProc
Exemplo n.º 14
0
        private void FormMain_Load(object sender, EventArgs e)
        {
            mitemSettingsRestore_Click(this, EventArgs.Empty);

            // Set focus to text box window.
            this.tboxInput.Focus();

            // Fetch window handle of text box.
            IntPtr hwndEditor = GetFocus();

            // Create message structure for sending Win32 messages
            m_msg = Message.Create(hwndEditor, 0, IntPtr.Zero,
                                   IntPtr.Zero);
        }
Exemplo n.º 15
0
    private void myThreadStart()
    {
        System.Diagnostics.Debug.WriteLine("Entering thread proc");
        int _i = 0;

        Intermec.Device.Sensor theSensor = new Intermec.Device.Sensor(Intermec.Device.Sensor.SensorsEnabled.AccelerometerEnabled);
        theSensor.SensorDataUpdateInterval = 50;
        ShakeDetection.GVector gv = new ShakeDetection.GVector();
        try
        {
            do
            {
                //The blocking function...
                gv.X = theSensor.Acceleration.GForceX;
                gv.Y = theSensor.Acceleration.GForceY;
                gv.Z = theSensor.Acceleration.GForceZ;

                System.Diagnostics.Debug.WriteLine("Calling into UI thread...");
                Microsoft.WindowsCE.Forms.Message msg = Message.Create(bgWnd.Hwnd, msgID, new IntPtr(_i), IntPtr.Zero);
                //to avoid reading and writing to var at same time from different threads
                lock (theLock)
                {
                    _BGeventArgs._gvector = gv;
                    //the PostMessage is catched in WndProc and the arguments are stored
                    //retrived using the _BGeventArgs variable
                    MessageWindow.PostMessage(ref msg);     //hopefully there is no other posted msg
                }
                System.Diagnostics.Debug.WriteLine("Thread sleeps...");
                _i++;
                Thread.Sleep(50);
            } while (bRunThread);
        }
        catch (ThreadAbortException)
        {
            System.Diagnostics.Debug.WriteLine("Thread will abort");
            bRunThread = false;
        }
        catch (Exception ex)
        {
            System.Diagnostics.Debug.WriteLine("Exception in ThreadStart: " + ex.Message);
        }
        System.Diagnostics.Debug.WriteLine("ThreadProc ended");
    }
Exemplo n.º 16
0
            // <summary>
            // Handles incoming windows Messages and acts accordingly
            // </summary>
            // <param name="m">Windows Message</param>
            protected override void WndProc(ref Microsoft.WindowsCE.Forms.Message m)
            {
                //notification message received
                if (m.Msg == (int)WM.NOTIFY)
                {
                    //switch on action
                    switch ((int)m.LParam)
                    {
                    case 0x0201:
                        //left button mouse down
                        parent.OnMouseDown(new MouseEventArgs(MouseButtons.Left, 1, 0, 0, 0));
                        break;

                    case 0x0202:
                        //left button mouse up
                        parent.OnMouseUp(new MouseEventArgs(MouseButtons.Left, 1, 0, 0, 0));
                        //only fire click if this is not the second click of a doubleclick sequence
                        break;

                    case 0x0203:
                        //left button doubleclick
                        parent.OnMouseDown(new MouseEventArgs(MouseButtons.Left, 2, 0, 0, 0));
                        parent.doubleclick = true;
                        parent.OnDoubleClick(new EventArgs());
                        break;

                    case 0x204:
                        //r button down
                        parent.OnMouseDown(new MouseEventArgs(MouseButtons.Right, 1, 0, 0, 0));
                        break;

                    case 0x0205:
                        //r button up
                        parent.OnMouseUp(new MouseEventArgs(MouseButtons.Right, 1, 0, 0, 0));
                        break;
                    }
                }

                //let windows handle any other messages
                base.WndProc(ref m);
            }
Exemplo n.º 17
0
            protected override void WndProc(ref Microsoft.WindowsCE.Forms.Message m)
            {
                // Check for notification message here

                if (m.Msg == 0x401)
                {
                    _oid     = m.LParam.ToInt32();
                    m.Result = IntPtr.Zero;

                    _callerQ_Load_Oid(_callerQ, null);
                    return;
                }
                else if (m.Msg == 0x402)
                {
                    m.Result = IntPtr.Zero;

                    _callerQ_Load_Notify(_callerQ, null);
                    return;
                }

                base.WndProc(ref m);
            }
Exemplo n.º 18
0
        protected override void WndProc(ref CEForms.Message msg)
        {
            switch (msg.Msg)
            {
            case WM_HOTKEY:
                int keyId = msg.WParam.ToInt32();

                if (keyId == 288 || (248 <= keyId && keyId <= 257))
                {
                    // X - 0x58 (88)
                    // 0 - 0x30 (48)
                    // 9 - 0x39 (57)
                    onNumeralBarcodeSymbol(Convert.ToChar(keyId - 200));
                }
                else
                {
                    BarcodeTimeStart = 0;
                    OnHotKeyPressed((KeyAction)keyId);
                }
                return;
            }
            base.WndProc(ref msg);
        }
Exemplo n.º 19
0
 //used internally by the ControlMessageWindow to pass through messages
 protected virtual void OnEraseBkgndMessage(ref Microsoft.WindowsCE.Forms.Message m)
 {
 }
Exemplo n.º 20
0
        protected override void WndProc(ref Microsoft.WindowsCE.Forms.Message m)
        {
            if (m.Msg == WM_RASDIALEVENT)
            {
                switch ((tagRASCONNSTATE)m.WParam)
                {
                case tagRASCONNSTATE.RASCS_OpenPort:
                    break;

                case tagRASCONNSTATE.RASCS_PortOpened:
                    VirtualConsole(false, "端口已打开", 0);
                    break;

                case tagRASCONNSTATE.RASCS_ConnectDevice:
                    VirtualConsole(false, "正在连接设备", 0);
                    break;

                case tagRASCONNSTATE.RASCS_DeviceConnected:
                    VirtualConsole(false, "设备已连接", 0);
                    break;

                case tagRASCONNSTATE.RASCS_AllDevicesConnected:
                    VirtualConsole(false, "物理连接已建立", 0);
                    break;

                case tagRASCONNSTATE.RASCS_Authenticate:
                    VirtualConsole(false, "正在验证...", 0);
                    break;

                case tagRASCONNSTATE.RASCS_AuthNotify:
                    VirtualConsole(false, "验证出错", 0);
                    break;

                case tagRASCONNSTATE.RASCS_AuthRetry:
                    VirtualConsole(false, "正在重新验证...", 0);
                    break;

                case tagRASCONNSTATE.RASCS_AuthCallback:
                    break;

                case tagRASCONNSTATE.RASCS_AuthChangePassword:
                    break;

                case tagRASCONNSTATE.RASCS_AuthProject:
                    break;

                case tagRASCONNSTATE.RASCS_AuthLinkSpeed:
                    break;

                case tagRASCONNSTATE.RASCS_AuthAck:
                    break;

                case tagRASCONNSTATE.RASCS_ReAuthenticate:
                    VirtualConsole(false, "正在重新验证...", 0);
                    break;

                case tagRASCONNSTATE.RASCS_Authenticated:
                    VirtualConsole(false, "验证已通过", 0);
                    break;

                case tagRASCONNSTATE.RASCS_PrepareForCallback:
                    break;

                case tagRASCONNSTATE.RASCS_WaitForModemReset:
                    break;

                case tagRASCONNSTATE.RASCS_WaitForCallback:
                    break;

                case tagRASCONNSTATE.RASCS_Projected:
                    break;

                case tagRASCONNSTATE.RASCS_Interactive:
                    break;

                case tagRASCONNSTATE.RASCS_RetryAuthentication:
                    break;

                case tagRASCONNSTATE.RASCS_CallbackSetByCaller:
                    break;

                case tagRASCONNSTATE.RASCS_PasswordExpired:
                    break;

                case tagRASCONNSTATE.RASCS_Connected:
                    uint   sign  = ConnectHelp.G3_ReadCSQ();
                    string stemp = "网络已连接,信号强度:" + sign.ToString();
                    VirtualConsole(false, stemp, 0);
                    ConnectHelp.isConencting = false;
                    break;

                case tagRASCONNSTATE.RASCS_Disconnected:
                    VirtualConsole(false, "网络连接失败", 0);
                    ConnectHelp.isConencting = false;
                    break;

                default:
                    base.WndProc(ref m);    //一定要调用基类函数,以便系统处理其它消息。
                    break;
                }
            }
            base.WndProc(ref m);//一定要调用基类函数,以便系统处理其它消息。
        }
Exemplo n.º 21
0
 /// <summary>
 /// Processes incoming notification messages.
 /// </summary>
 /// <param name="m"></param>
 protected virtual void OnNotifyMessage(ref Microsoft.WindowsCE.Forms.Message m)
 {
     //don't handle any messages by default - leave this up to inheritors
 }
Exemplo n.º 22
0
 //used internally by the ControlMessageWindow to pass through messages
 internal void OnMessage(ref Microsoft.WindowsCE.Forms.Message m)
 {
     //call the controls OnNotifyMessage method
     OnNotifyMessage(ref m);
 }
 /// <summary>
 /// Invokes the default window procedure associated with this window.
 /// </summary>
 /// <param name="m">A <see cref="Message"/> that is associated with the current Windows message.</param>
 protected virtual void WndProc(ref Microsoft.WindowsCE.Forms.Message m)
 {
     this.DefWndProc(ref m);
 }