Thursday, January 9, 2014

Windows CE Double Click Issue solved

Issue in Windows CE with Double Click...

Thank God..!! At last I could able to solve the issue in Windows Mobile 6.0 Application.
I think Windows Mobile Developer could have experienced this issue.
The issue was there is a button on click of it redirects me to a form which has list values to be selected. As you may be aware of it, in our Windows Mobiles Deceives don't have that much efficient RAM, Processor as compared to our desktop. So there will be great performance issue here.

So when use dos double click(of course as a developer we have to think) the redirected form is shown and on the position of 2nd click the respective value is selected automatically.


So, How to Resolve...


After a long R & D I found that it can be possible If we disable touch event after a first click until respective form is show and then enable.


That’s it...It solve my problem..

Here is the Code...
In Windows.cs Declaring the functions to be used:

#region TouchDisableOrEnable

        [DllImport("coredll.dll", SetLastError = true)]
        private static extern IntPtr GetDesktopWindow();

        [DllImport("touch.dll", SetLastError = true)]
        private static extern bool TouchRegisterWindow(IntPtr hwnd);

        [DllImport("touch.dll", SetLastError = true)]
        private static extern void TouchUnregisterWindow(IntPtr hwnd);

        public static Boolean TouchDisable()
        {
            return TouchRegisterWindow(GetDesktopWindow());
        }
        public static void TouchEnable()
        {
            TouchUnregisterWindow(GetDesktopWindow());

        }

#endregion

Now in your Button Click:

private void btnYourButtonName_Click(object sender, System.EventArgs e)
        {
            try
            {
                Cursor.Current = Cursors.WaitCursor;
                Windows.TouchDisable(); // Disabling Touch
//Do your stuff whatever you want……. And then enable touch  
                Windows.TouchEnable(); // Enabling Touch
                frmDetails.ShowDialog();
            }
            catch (Exception ex)
            {
                Utilities.LogException(ex, "btnChLocation_Click");
            }
            finally
            {
            //Be smarter to include here also..else your current app touch disabled     if exception is raised
              Windows.TouchEnable();// Enabling Touch
               Cursor.Current = Cursors.Default;
            }
        }
 
Note: Don't test it in Emulator which does not support (logically you can think here touch enable & disable is there)


No comments: