触摸屏键盘 [英] Touch Screen KeyBoard

查看:158
本文介绍了触摸屏键盘的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直对触摸屏的应用程序。我需要知道,如果存在,我可以为我的应用程序控制器使用现成的触摸屏键盘。

I have been working on a touch screen application. I need to know if there exists a ready touch screen keyboard that I can use as a Controller for my application.

我尝试使用窗口准备好键盘,但它太小对于触摸屏。

I tried using the windows ready keyboard but it is too small for a touch screen.

Process.Start(Environment.GetFolderPath(Environment.SpecialFolder.System) + Path.DirectorySeparatorChar + "osk.exe");



任何想法如何开始在最短的时间建立人会不胜感激......

any ideas how to start building one in minimal time will be greatly appreciated....

新问题

我抄从别人的代码,做了一些修改它:

I have copied this code from someone and did some modifications to it :

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Windows;
using System.Diagnostics;
using System.IO;
using System.Runtime.InteropServices;


 class Win32
{
[DllImport("user32.dll", EntryPoint = "SetWindowPos")]
public static extern bool SetWindowPos(
int hWnd, // window handle
int hWndInsertAfter, // placement-order handle
int X, // horizontal position
int Y, // vertical position
int cx, // width
int cy, // height
uint uFlags); // window positioning flags
public const int HWND_BOTTOM = 0x0001;
public const int HWND_TOP = 0x0000;
public const int SWP_NOSIZE = 0x0001;
public const int SWP_NOMOVE = 0x0002;
public const int SWP_NOZORDER = 0x0004;
public const int SWP_NOREDRAW = 0x0008;
public const int SWP_NOACTIVATE = 0x0010;
public const int SWP_FRAMECHANGED = 0x0020;
public const int SWP_SHOWWINDOW = 0x0040;
public const int SWP_HIDEWINDOW = 0x0080;
public const int SWP_NOCOPYBITS = 0x0100;
public const int SWP_NOOWNERZORDER = 0x0200;
public const int SWP_NOSENDCHANGING = 0x0400;
}


namespace Keyboard
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            this.KeyText.MouseDoubleClick += new MouseEventHandler(KeyText_MouseDoubleClick);

        }
        private Process process;
        private string getKeyboardText()
        {
            KeyScreen k = new KeyScreen();
            k.ShowDialog();
            if (k.DialogResult.ToString().Equals("OK"))
                return k.Text1;
            else
                return null;
        }

        void KeyText_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            this.KeyText.Text = getKeyboardText();
        }

        private void KeyBtn_Click(object sender, EventArgs e)
        {

            this.showKeypad();

            //Process.Start(Environment.GetFolderPath(Environment.SpecialFolder.System) + Path.DirectorySeparatorChar + "osk.exe");
        }
        private void showKeypad()
        {
            Process process = new Process();
            process.StartInfo.UseShellExecute = false;
            process.StartInfo.RedirectStandardOutput = true;
            process.StartInfo.RedirectStandardError = true;
            process.StartInfo.CreateNoWindow = true;
            process.StartInfo.FileName = "c:\\Windows\\system32\\osk.exe";
            process.StartInfo.Arguments = "";
            process.StartInfo.WorkingDirectory = "c:\\";
            process.Start(); // Start Onscreen Keyboard
            process.WaitForInputIdle();
            Win32.SetWindowPos((int)process.MainWindowHandle,
            Win32.HWND_BOTTOM,
            300, 300, 1200, 600,
            Win32.SWP_SHOWWINDOW | Win32.SWP_NOZORDER);


        }



    }
}

这工作得很好我有一个很好的键盘(好尺寸触摸屏),但是,我不熟悉C#和VB在所有....改变文中根据触摸屏键盘I显示一个文本框。

This works just fine I have a nice keypad (good size for a touch screen), However, i am not familiar with C# and VB at all.... change the Text in a textbox according to the touch screen keyboard I show.

谢谢,

推荐答案

要创建自己的屏幕键盘上,你基本上需要做到以下几点。

To create your own on screen keyboard you basically need to do the following.

1 - 创建一个Windows键盘应用程序,您可以用交互但不从当前控件偷输入焦点,其中每个应用程序你在哪里目前的工作。

1- Create a windows keyboard application that you can interact with but does not steal the input focus from the current control in which every application you where currently working.

2-键盘应用程序应该发送按键当前激活的控制响应点击在键盘的应用程序按钮。

2- The keyboard application should send key presses to the currently active control in response to clicking of buttons in the keyboard application.

我以前提供的以下的答案提供了如何做到这一点使用的WinForms一个简单的演示。

The following answer I provided previously provides a simple demonstration of how to do this using WinForms.

http://stackoverflow.com/questions/2795558/c-sending-keyboard-events-to-last-selected-window/2796547#2796547

基本上与 WS_EX_NOACTIVATE 式,从而防止窗口从becomming活性和钢化输入焦点。然后响应按钮点击它使用的SendKeys 送选择恰当的按键消息到具有输入焦点的控制。

Basically the window is created with the WS_EX_NOACTIVATE style, which prevents the window from becomming active and steeling input focus. Then in response to button clicks it uses SendKeys to send the approriate key press message to the control that has input focus.

以下的答案必须说明如何应用的 WS_EX_NOACTIVATE 风格WPF应用程序。

The following answer shows how to apply the WS_EX_NOACTIVATE style to a WPF application.

http://stackoverflow.com/questions/2868893/trying-to-create-a-wpf-touch-screen-keyboard-appliaction-cant-get-wpf-app-to-se/2868974#2868974

有比WS_EX_NOACTIVATE其他其他解决方案,但是这是简单和角落找寻拖动窗口时只从一个次要表象的毛刺缺点。它与可以克服一些聪明的消息处理。

There are other solutions other than WS_EX_NOACTIVATE, but this is simple and only suffers from a minor presentational glitch when dragging the window arround. Which with some clever message processing can be overcome.

这篇关于触摸屏键盘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆