- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我的应用程序当前正在运行 Windows Mobile 6.5 的手持设备上运行。我希望能够捕获应用程序中的左/右软键按钮按下,并将用户带到“主页”表单或应用程序中经常使用的其他表单。在操作系统级别,这些软键被设置为分别转到日历/联系人,但是在我的应用程序中,我希望这些按钮像上面提到的那样。我如何着手捕获或拦截 Compact Framework 中的这些软键按钮按下操作?我做了一些研究,看到了一些关于注册热键的引用资料?任何帮助将不胜感激。
旁注:我的应用程序使用 MainMenu 控件,但左/右软键不控制任何菜单选择。
最佳答案
试试这个:
public class HButtons : System.Windows.Forms.Form
{
private MainMenu mainMenu1;
private MenuItem mnuBack;
myMessageWindow messageWindow;
public HButtons()
{
InitializeComponent();
this.messageWindow = new myMessageWindow(this);
RegisterHKeys.RegisterRecordKey(this.messageWindow.Hwnd);
}
protected override void Dispose(bool disposing)
{
RegisterHKeys.UnRegisterRecordKey();
base.Dispose(disposing);
}
public void ButtonPressed(int button)
{
switch (button)
{
case (int)KeysHardware.VK_APP1:
MessageBox.Show("VK_APP1 pressed!");
break;
case (int)KeysHardware.GreenPhoneButton:
MessageBox.Show("GreenPhoneButton pressed!");
break;
case (int)KeysHardware.RedPhoneButton:
MessageBox.Show("RedPhoneButton pressed!");
break;
case (int)KeysHardware.VK_TSOFT1:
MessageBox.Show("VK_TSOFT1 pressed!");
break;
}
}
private void InitializeComponent()
{
this.mainMenu1 = new System.Windows.Forms.MainMenu();
this.mnuBack = new System.Windows.Forms.MenuItem();
this.SuspendLayout();
//
// mainMenu1
//
this.mainMenu1.MenuItems.Add(this.mnuBack);
//
// mnuBack
//
this.mnuBack.Text = "Back";
this.mnuBack.Click += new System.EventHandler(this.mnuBack_Click);
//
// HButtons
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
this.ClientSize = new System.Drawing.Size(240, 268);
this.Menu = this.mainMenu1;
this.MinimizeBox = false;
this.Name = "HButtons";
this.Text = "HW buttons";
this.ResumeLayout(false);
}
private void mnuBack_Click(object sender, EventArgs e)
{
this.Close();
}
}
public class myMessageWindow : MessageWindow
{
public const int WM_HOTKEY = 0x0312;
HButtons example;
public myMessageWindow(HButtons anExample)
{
this.example = anExample;
}
protected override void WndProc(ref Message msg)
{
switch (msg.Msg)
{
case WM_HOTKEY:
example.ButtonPressed(msg.WParam.ToInt32());
return;
}
base.WndProc(ref msg);
}
}
public class RegisterHKeys
{
[DllImport("coredll.dll", SetLastError = true)]
public static extern bool RegisterHotKey(
IntPtr hWnd, // handle to window
int id, // hot key identifier
KeyModifiers Modifiers, // key-modifier options
int key //virtual-key code
);
[DllImport("coredll.dll")]
private static extern bool UnregisterFunc1(
KeyModifiers modifiers,
int keyID);
public static void RegisterRecordKey(IntPtr hWnd)
{
UnregisterFunc1(KeyModifiers.Windows, (int)KeysHardware.VK_APP1);
RegisterHotKey(hWnd, (int)KeysHardware.VK_APP1, KeyModifiers.Windows, (int)KeysHardware.VK_APP1);
UnregisterFunc1(KeyModifiers.None, (int)KeysHardware.GreenPhoneButton);
RegisterHotKey(hWnd, (int)KeysHardware.GreenPhoneButton, KeyModifiers.None, (int)KeysHardware.GreenPhoneButton);
UnregisterFunc1(KeyModifiers.None, (int)KeysHardware.RedPhoneButton);
RegisterHotKey(hWnd, (int)KeysHardware.RedPhoneButton, KeyModifiers.None, (int)KeysHardware.RedPhoneButton);
UnregisterFunc1(KeyModifiers.None, (int)KeysHardware.VK_TSOFT1);
RegisterHotKey(hWnd, (int)KeysHardware.VK_TSOFT1, KeyModifiers.None, (int)KeysHardware.VK_TSOFT1);
}
public static void UnRegisterRecordKey()
{
UnregisterFunc1(KeyModifiers.Windows, (int)KeysHardware.VK_APP1);
UnregisterFunc1(KeyModifiers.None, (int)KeysHardware.GreenPhoneButton);
UnregisterFunc1(KeyModifiers.None, (int)KeysHardware.RedPhoneButton);
UnregisterFunc1(KeyModifiers.None, (int)KeysHardware.VK_TSOFT1);
}
}
///// <summary>
///// Summary description for hwButtons.
///// </summary>
//public class hwButtons
//{
// public hwButtons()
// {
// HButtons theBtns = new HButtons();
// }
//}
public enum KeyModifiers
{
None = 0,
Alt = 1,
Control = 2,
Shift = 4,
Windows = 8,
Modkeyup = 0x1000,
}
//public enum KeysHardware : int
//{
// Hardware1 = 193, //0xC1
// Hardware2 = 194,
// Hardware3 = 195,
// Hardware4 = 196,
// Hardware5 = 197
//}
public enum KeysHardware : int
{
VK_F1 = 0x70,
VK_F2 = 0x71,
VK_F3 = 0x72,
VK_F4 = 0x73,
VK_F5 = 0x74,
VK_F6 = 0x75,
VK_F7 = 0x76,
VK_F8 = 0x77,
VK_F9 = 0x78,
VK_F10 = 0x79,
VK_F11 = 0x7A,
VK_F12 = 0x7B,
VK_TSOFT1 = VK_F1, // Softkey 1
VK_TSOFT2 = VK_F2, // Softkey 2
VK_TTALK = VK_F3, // Talk = Green Phone Button
VK_TEND = VK_F4, // End = Red Phone Button
VK_APP1 = 0xC1, // up to 6 other hardware buttons
VK_APP2 = 0xC2,
VK_APP3 = 0xC3,
VK_APP4 = 0xC4,
VK_APP5 = 0xC5,
VK_APP6 = 0xC6,
RedPhoneButton = VK_TEND,
GreenPhoneButton = VK_TTALK
}
关于c# - 捕获左/右软键按下——C# .net CF 3.5,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5626078/
这个问题已经有答案了: Declaring multiple object pointers on one line causes compiler error (5 个回答) 已关闭 6 年前。 l
我目前正在学习语言处理器,经常出现的一个话题是语法中元素的使用方向。从左到右或从右到左。 我理解这个概念,但似乎有很多方法可以编写这些规则,我不确定它们是否都相同。到目前为止我看到的是: 右/左递归,
我有一个很长的线性(分支不多)流程图,在 graphviz 中显示为要么太高而无法放在单个页面上,要么太宽(如果方向是从左到右) 是否有一种简单的方法可以让 graphviz 以从左到右,然后向下,然
我一直摸不着头脑,但运气不好。设计器有一个包含 3 栏的站点、两个侧边栏和一个主要内容区域。 专为桌面设计,左栏、主要内容、右栏。但是,在较小的设备上,我们希望首先堆叠主要内容。 所以通常情况下,你可
我想要从上到下和从左到右组织的 css block 。 为了更好地解释这是一张图片,其中包含我到目前为止所获得的内容以及我希望使用 CSS 实现的内容: 代码如下: HTML: 1 2 3 4 5
当我问this question时,答案之一(现已删除)建议Either类型对应Curry-Howard correspondence中的XOR而不是OR,因为它不能同时是Left和Right。 真相
我有一个程序,如果用户按住向左或向右箭头键, Angular 色会逐渐朝那个方向加速,并最终达到最大速度。松开按键后, Angular 色逐渐减速,直至完全停止。 我的右方向键没问题,但左方向键坏了。
今天很简单的一个。我有一个专栏,我们称之为标题,有一堆项目标题。我需要从“:”的左侧拉出所有内容并进行左/右修剪(稍后我将在连接中使用它,但我现在只需要一个包含新数据的列) .下面是当前列的示例: 这
我正在尝试将图表中的列与左侧对齐。默认情况下,它们位于中间。 我在 API 文档中找不到任何关于此的信息。 Here是一个 jsFiddle 测试。 最佳答案 在 highcharts api 中,您
左旋转进位和右旋转进位指令有哪些实际用途? 在我的汇编课上,我们无法想出一个有用的好例子。 最佳答案 如果您想将位从一个操作数移出并移入另一个操作数: SHL EAX, 1 ; mov
我有一个查询,它使用 eqjoin 从两个不同的表返回以下数据。我想将 left 和 right 结合起来,而不是执行 zip() (重写 name > 和 joined_at),我想将右侧对象的属性
我使用 firebase API。发送和检索消息。但是,我在尝试为发送者/检索者设置布局时遇到麻烦,以便消息将左/右对齐。目前我只有发送者/检索者都使用的一种布局,但不确定如何设置不同的布局。 pub
我的菜单基本上是一个水平项目滑动条。所有菜单项都有特定的默认 CSS 属性。我希望这些项目在到达主容器的中心时更改其大小和左/右边距,并在离开主容器(或位于主容器之外)时重置为默认值。请参阅我的原理图
我有一个引用表,在这个表中有 3 个字段(Id、User1、User2)。 User2 字段可以为空,但我们在不使用时使用 0。 当我执行下面的 Linq 查询时,User2 == 0 的记录不是结果
不知道如何解决这个问题。 我有两个表结果和受访者 我需要查明受访者表中是否有任何行具有completion =“Complete”,但它们的respondent_id(在结果表和受访者表中)不在结果表
我正在尝试访问三个表以获得类似这样的内容: +------+------+------+ | ITEM | PCS | CSS | +------+------+------+ | 1099 |
left 和 right join 有区别吗,下面的sql 语句结果一样,但是两者的性能是一样的吗? SELECT count(*) FROM writers RIGHT JOIN blogs O
当我使用 LEFT() 使用以下代码从数据库中获取值时 $select="SELECT LEFT(description,500) FROM tbl_news where id='$id'"; $qu
当我将鼠标悬停在水平导航菜单上的页面名称上时,相关子页面会 float 在下方。 目前这些显示居中,我如何对齐它们以便它们向左对齐(与导航菜单标题名称一致)。 你可以去看到这个 http://79.1
在下面的引导网格示例中,它使用 col-sm 和 col-sm-push/pull。col-sm-push 指定了左/右值(偏移量)。 我不太清楚它是如何工作的。 第二个 float 元素来到第一个
我是一名优秀的程序员,十分优秀!