C# 开发PDA程序中软键盘(sip)覆盖录入区域的解决办法
来源:互联网 发布:百度 mysql 编辑:程序博客网 时间:2024/05/01 10:44
C# 开发PDA程序中软键盘(sip)覆盖录入区域的解决办法
15:46:03 2009-05-20
父窗体
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace SmartDeviceProjectWcfTest
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
this.Load += new EventHandler(MainForm_Load);
}
private const int GWL_WNDPROC = -4;
private const int WM_SETTINGCHANGE = 0x1A;
private const int SPI_SETSIPINFO = 0xE0;
private enum SIPStatus
{
SIPF_OFF = 0,
SIPF_ON
}
[StructLayout(LayoutKind.Sequential)]
public struct RECT
{
public Int32 left;
public Int32 top;
public Int32 right;
public Int32 bottom;
}
[StructLayout(LayoutKind.Sequential)]
public struct IMINFO
{
public Int32 cbSize;
public IntPtr hImageNarrow;
public IntPtr hImageWide;
public Int32 iNarrow;
public Int32 iWide;
public Int32 fdwFlags;
public RECT rcSipRect;
}
[StructLayout(LayoutKind.Sequential)]
public struct SIPINFO
{
public Int32 cbSize;
public Int32 fdwFlags;
public RECT rcVisibleDesktop;
public RECT rcSipRect;
public Int32 dwImDataSize;
public IntPtr pvImData;
}
delegate IntPtr WndProcDelegate(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam);
[DllImport ("coredll.dll", EntryPoint = "GetWindowLong")]
private static extern IntPtr GetWindowLong (IntPtr hWnd, int nIndex);
[DllImport ("coredll.dll")]
static extern int SetWindowLong (IntPtr hWnd, int nIndex, IntPtr newWndProc);
[DllImport ("coredll.dll")]
static extern IntPtr CallWindowProc (IntPtr lpPrevWndFunc, IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
[DllImport ("coredll")]
static extern bool SipGetInfo (ref SIPINFO si);
[DllImport("coredll.dll")]
private static extern bool SipSetInfo(ref SIPINFO pSipInfo);
private static IntPtr oldWndProc = IntPtr.Zero;
private static WndProcDelegate newWndProc;
protected virtual void SipPannelShow(){}
protected virtual void SipPannelHide() { }
private void MainForm_Load (object sender, EventArgs e)
{
newWndProc = new WndProcDelegate (WndProc);
oldWndProc = GetWindowLong (this.Handle, GWL_WNDPROC);
int success = SetWindowLong (this.Handle, GWL_WNDPROC, Marshal.GetFunctionPointerForDelegate (newWndProc));
}
public IntPtr WndProc (IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam)
{
if (msg == WM_SETTINGCHANGE && wParam.ToInt32() == SPI_SETSIPINFO)
{
SIPINFO sipInfo = new SIPINFO();
sipInfo.cbSize = Marshal.SizeOf (typeof(SIPINFO));
SipGetInfo(ref sipInfo);
if ((sipInfo.fdwFlags & (int)SIPStatus.SIPF_ON) == (int)SIPStatus.SIPF_ON)
{
// Do something if the SIP is showing
SipPannelShow();
}
else
{
// Do something if the SIP is NOT showing
SipPannelHide();
}
}
return CallWindowProc (oldWndProc, this.Handle, msg, wParam, lParam);
}
public static bool SipSetRect(int x, int y, int width, int height)
{
SIPINFO sipinfo = new SIPINFO();
if (!SipGetInfo(ref sipinfo))
return false;
IMINFO iminfo = (IMINFO)Marshal.PtrToStructure(sipinfo.pvImData, typeof(IMINFO));
iminfo.rcSipRect.left = x;
iminfo.rcSipRect.right = x + width - 1;
iminfo.rcSipRect.top = y;
iminfo.rcSipRect.bottom = y + height - 1;
Marshal.StructureToPtr(iminfo, sipinfo.pvImData, true);
return SipSetInfo(ref sipinfo);
}
}
}
子窗体
override protected void SipPannelShow()
{
this.panelMain.Height = this.panelMain.Height + 180;
this.panelMain.Location = new Point(0, -180);
}
override void SipPannelHide()
{
base.SipPannelHide();
this.panelMain.Height = this.panelMain.Height - 180;
this.panelMain.Location = new Point(0, 0);
}
- C# 开发PDA程序中软键盘(sip)覆盖录入区域的解决办法
- VS2008中开发智能设备程序(PDA手机软件)的总结
- 关于activity和fragment中点击edittext之外的空白区域使软键盘消失的解决办法
- C++实现PDA中打开和关闭软键盘的方法
- C++实现PDA中打开和关闭软键盘的方法
- PDA上控制软键盘
- iso中输入框被软键盘覆盖的解决方案
- WP7平台开发——如何隐藏点击textbox时出现的软键盘(即隐藏SIP)
- C#开发WINCE系统的PDA程序,GetSystemMetrics获取屏幕长宽以达到自适应分辨率
- TV中一款自定义的软键盘(覆盖了系统原生的键盘)
- PDA开发之控件背景不透明的解决办法
- Android开发中软键盘的常见问题
- VS2008中开发手持终端程序(PDA软件)总结
- PDA上的程序不能远程调试的问题(C# WinCE OS)
- android 软键盘覆盖布局的问题
- IOS中输入框被软键盘遮挡的解决办法
- IOS中输入框被软键盘遮挡的解决办法
- IOS中输入框被软键盘遮挡的解决办法
- Flex中的AactionScript和JavaScript互调的小例子
- extern "C"的用法解析
- 全文索引
- 移动文件夹后ln原文件夹
- 使用samba用linux连接windows
- C# 开发PDA程序中软键盘(sip)覆盖录入区域的解决办法
- 两个文件之间的字符串匹配
- 基于内容的信息存取与MPEG-7
- .net关于xml文件命名空间的解析读取
- r+树
- Java 鼠标事件 plus 图形
- 质量管理八项原则及其应用指南
- 图片连续上下滚动代码JavaScript
- 逆向程序员这么值钱?