locked
htc keyboard slide event capture RRS feed

  • Question

  • Hi, I am currently writing code for a htc TyTN II. The TyTN II does not have a tilt sensor, only a slider. I cant seem to figure out how to capture the slide event in my code. The reason I want to do this is to resize the current form being displayed between landscape and portrait mode. Is this the correct way of doing this, or is there a better way? I am using VS2008 and coding in C#. I dont think htc released a sdk to do this. Any help would be appreciated. Thanks
    Friday, September 18, 2009 7:19 AM

Answers

  • Hi Paul,

    Thanks for the quick reply. I actually managed to capture the slide event by using RegistryState. The registry key value SlideKey returns either a 0 or a 1 depending on whether the slider is open or closed. Here's the code I used in case somebody else might find it useful one day:

    using System;
    using System.Linq;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    using System.Runtime.InteropServices;
    using Microsoft.Win32;
    using System.Net.Sockets;
    using Microsoft.WindowsMobile.Status;
    
    namespace AMMS
    {
        public partial class Test : Form
        {
            RegistryState state; // defined globally to class
    
            public Test()
            {            
                try
                {
                    InitializeComponent();                        
                    state = new RegistryState("HKEY_LOCAL_MACHINE\\System\\GDI\\Rotation", "SlideKey");
                    state.Changed += new ChangeEventHandler(state_Changed);
      
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
                finally
                {
                    Cursor.Current = Cursors.Default;
                }
            }
    
            private void state_Changed(object sender, ChangeEventArgs args)
            {           
                try
                {
                    MessageBox.Show(args.NewValue.ToString(), "Registry value");
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            }
        }

    Regards

    Johan van der Merwe

     
    • Marked as answer by Supervan007 Friday, September 18, 2009 9:05 AM
    Friday, September 18, 2009 9:04 AM

All replies

  • Hi,

    You might be able to hook into the DisplayRotation System State :-

    http://msdn.microsoft.com/en-us/library/microsoft.windowsmobile.status.systemstate.displayrotation.aspx

    Hope this helps.

    Paul Diston
    http://www.smartmobiledevice.co.uk/
    Friday, September 18, 2009 7:25 AM
  • Hi Paul,

    Thanks for the quick reply. I actually managed to capture the slide event by using RegistryState. The registry key value SlideKey returns either a 0 or a 1 depending on whether the slider is open or closed. Here's the code I used in case somebody else might find it useful one day:

    using System;
    using System.Linq;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    using System.Runtime.InteropServices;
    using Microsoft.Win32;
    using System.Net.Sockets;
    using Microsoft.WindowsMobile.Status;
    
    namespace AMMS
    {
        public partial class Test : Form
        {
            RegistryState state; // defined globally to class
    
            public Test()
            {            
                try
                {
                    InitializeComponent();                        
                    state = new RegistryState("HKEY_LOCAL_MACHINE\\System\\GDI\\Rotation", "SlideKey");
                    state.Changed += new ChangeEventHandler(state_Changed);
      
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
                finally
                {
                    Cursor.Current = Cursors.Default;
                }
            }
    
            private void state_Changed(object sender, ChangeEventArgs args)
            {           
                try
                {
                    MessageBox.Show(args.NewValue.ToString(), "Registry value");
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            }
        }

    Regards

    Johan van der Merwe

     
    • Marked as answer by Supervan007 Friday, September 18, 2009 9:05 AM
    Friday, September 18, 2009 9:04 AM
  • hey supervan, can we use the same code for other htc slide devices...say eg touch pro 2, and can i set this particular registry value to disallow the device from going in landscape mode even if the keyboard is slid out???
    Friday, January 15, 2010 5:07 PM