|
まぁこれはいいとして…。
backキーのイベントが取れないねー。
さっぱりわからん。
public class MsgWindow : MessageWindow
{
const int MOD_ALT = 0x0001;
const int MOD_CONTROL = 0x0002;
const int MOD_SHIFT = 0x0004;
const int MOD_KEYUP = 0x1000;
const int WM_HOTKEY = 0x0312;
const int WM_USER = 0x400;
const int SHCMBM_OVERRIDEKEY = WM_USER + 403;
const int SHCMBM_SETBKCOLOR = WM_USER + 406;
const int SHMBOF_NODEFAULT = 0x00000001;
const int SHMBOF_NOTIFY = 0x00000002;
const int VK_F3 = 0x72;
const int VK_TTALK = VK_F3;
const int VK_TBACK = 0x1B;
const int HOTKEY_ID = 0x0001;
[DllImport("coredll.dll")]
extern static int RegisterHotKey(IntPtr HWnd, int ID, int MOD_KEY, int KEY);
[DllImport("coredll.dll")]
extern static int UnregisterHotKey(IntPtr HWnd, int ID);
[DllImport("coredll.dll", SetLastError = true)]
public static extern int SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
[DllImport("aygshell.dll")]
private extern static IntPtr SHFindMenuBar(IntPtr hwnd);
private MainWindow msgform;
private static int HiWord(int number)
{
if ((number & 0x80000000) == 0x80000000)
return (number >> 16);
else
return (number >> 16) & 0xffff;
}
private static int LoWord(int number)
{
return number & 0xffff;
}
private static int MakeLong(int LoWord, int HiWord)
{
return (HiWord << 16) | (LoWord & 0xffff);
}
private static IntPtr MakeLParam(int LoWord, int HiWord)
{
return (IntPtr)((HiWord << 16) | (LoWord & 0xffff));
}
public MsgWindow(MainWindow msgform)
{
this.msgform = msgform;
IntPtr hnwdMB = SHFindMenuBar(msgform.Handle);
int r;
// これも駄目
RegisterHotKey(msgform.Handle, HOTKEY_ID, 0, VK_TBACK);
// これも駄目
SendMessage(SHFindMenuBar(msgform.Handle), SHCMBM_OVERRIDEKEY, (IntPtr)VK_TBACK,
MakeLParam(SHMBOF_NODEFAULT | SHMBOF_NOTIFY,SHMBOF_NODEFAULT | SHMBOF_NOTIFY));
}
protected override void WndProc(ref Message msg)
{
if(msg.Msg== WM_HOTKEY)
{
if ((int)msg.WParam == HOTKEY_ID)
{
}
}
base.WndProc(ref msg);
}
}
X02HTの場合、HardwareButtonは使えないみたいだし、
どうやってフックすりゃいいのでしゃう。
同じ開発をやってるサイトでも判ってないっぽいし、
海外サイト見に行っても上記コードに似たようなものばっか…。
今日はもう諦め。
1 件のコメント:
貴重な情報をありがとうございます。
モバイルのボタン操作が困難な方のためのアプリを開発しております。
外部ヘッドセットの通話ボタンをイベントに使いたいと思っております。
TALKがそれでしょうか?
Backキーの取得に関して、下記のサイトがありました。
http://wontfix.blogspot.com/2008/01/back.html
コメントを投稿