KeyBoardDlg.cpp
资源名称:KeyBoard.rar [点击查看]
上传用户:weimin735
上传日期:2008-06-11
资源大小:527k
文件大小:59k
源码类别:
输入法编程
开发平台:
Visual C++
- // KeyBoardDlg.cpp : implementation file
- //
- #include "stdafx.h"
- #include "KeyBoard.h"
- #include "KeyBoardDlg.h"
- #include "resource.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CAboutDlg dialog used for App About
- class CAboutDlg : public CDialog
- {
- public:
- CAboutDlg();
- // Dialog Data
- //{{AFX_DATA(CAboutDlg)
- enum { IDD = IDD_ABOUTBOX };
- //}}AFX_DATA
- // ClassWizard generated virtual function overrides
- //{{AFX_VIRTUAL(CAboutDlg)
- protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- //}}AFX_VIRTUAL
- // Implementation
- protected:
- CRgn m_rgn;
- CBrush m_brush;
- //{{AFX_MSG(CAboutDlg)
- afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
- virtual BOOL OnInitDialog();
- afx_msg BOOL OnEraseBkgnd(CDC* pDC);
- //}}AFX_MSG
- DECLARE_MESSAGE_MAP()
- };
- CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
- {
- //{{AFX_DATA_INIT(CAboutDlg)
- //}}AFX_DATA_INIT
- }
- void CAboutDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CAboutDlg)
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
- //{{AFX_MSG_MAP(CAboutDlg)
- ON_WM_LBUTTONDOWN()
- ON_WM_ERASEBKGND()//重绘窗口
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CKeyBoardDlg dialog
- CKeyBoardDlg::CKeyBoardDlg(CWnd* pParent /*=NULL*/)
- : CDialog(CKeyBoardDlg::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CKeyBoardDlg)
- // NOTE: the ClassWizard will add member initialization here
- //}}AFX_DATA_INIT
- // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
- m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
- m_bCaps = 0;
- }
- void CKeyBoardDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CKeyBoardDlg)
- DDX_Control(pDX, IDC_ESC, m_key_esc);
- DDX_Control(pDX, IDC_F1, m_key_f1);
- DDX_Control(pDX, IDC_F2, m_key_f2);
- DDX_Control(pDX, IDC_F3, m_key_f3);
- DDX_Control(pDX, IDC_F4, m_key_f4);
- DDX_Control(pDX, IDC_F5, m_key_f5);
- DDX_Control(pDX, IDC_F6, m_key_f6);
- DDX_Control(pDX, IDC_F7, m_key_f7);
- DDX_Control(pDX, IDC_F8, m_key_f8);
- DDX_Control(pDX, IDC_F9, m_key_f9);
- DDX_Control(pDX, IDC_F10, m_key_f10);
- DDX_Control(pDX, IDC_F11, m_key_f11);
- DDX_Control(pDX, IDC_F12, m_key_f12);
- DDX_Control(pDX, IDC_PAUSE, m_key_pause);
- DDX_Control(pDX, IDC_INS, m_key_ins);
- DDX_Control(pDX, IDC_DEL, m_key_del);
- DDX_Control(pDX, IDC_PGUP, m_key_pgup);
- DDX_Control(pDX, IDC_PGDN, m_key_pgdn);
- DDX_Control(pDX, IDC_HOME, m_key_home);
- DDX_Control(pDX, IDC_END, m_key_end);
- DDX_Control(pDX, IDC_ONCE, m_key_once);
- DDX_Control(pDX, IDC_1, m_key_1);
- DDX_Control(pDX, IDC_2, m_key_2);
- DDX_Control(pDX, IDC_3, m_key_3);
- DDX_Control(pDX, IDC_4, m_key_4);
- DDX_Control(pDX, IDC_5, m_key_5);
- DDX_Control(pDX, IDC_6, m_key_6);
- DDX_Control(pDX, IDC_7, m_key_7);
- DDX_Control(pDX, IDC_8, m_key_8);
- DDX_Control(pDX, IDC_9, m_key_9);
- DDX_Control(pDX, IDC_0, m_key_0);
- DDX_Control(pDX, IDC_10, m_key_10);
- DDX_Control(pDX, IDC_11, m_key_11);
- DDX_Control(pDX, IDC_12, m_key_12);
- DDX_Control(pDX, IDC_BSPC, m_key_bspc);
- DDX_Control(pDX, IDC_TAB, m_key_tab);
- DDX_Control(pDX, IDC_Q, m_key_q);
- DDX_Control(pDX, IDC_W, m_key_w);
- DDX_Control(pDX, IDC_E, m_key_e);
- DDX_Control(pDX, IDC_R, m_key_r);
- DDX_Control(pDX, IDC_T, m_key_t);
- DDX_Control(pDX, IDC_Y, m_key_y);
- DDX_Control(pDX, IDC_U, m_key_u);
- DDX_Control(pDX, IDC_I, m_key_i);
- DDX_Control(pDX, IDC_O, m_key_o);
- DDX_Control(pDX, IDC_P, m_key_p);
- DDX_Control(pDX, IDC_P1, m_key_p1);
- DDX_Control(pDX, IDC_P2, m_key_p2);
- DDX_Control(pDX, IDC_CAPS, m_key_caps);
- DDX_Control(pDX, IDC_A, m_key_a);
- DDX_Control(pDX, IDC_S, m_key_s);
- DDX_Control(pDX, IDC_D, m_key_d);
- DDX_Control(pDX, IDC_F, m_key_f);
- DDX_Control(pDX, IDC_G, m_key_g);
- DDX_Control(pDX, IDC_H, m_key_h);
- DDX_Control(pDX, IDC_J, m_key_j);
- DDX_Control(pDX, IDC_K, m_key_k);
- DDX_Control(pDX, IDC_L, m_key_l);
- DDX_Control(pDX, IDC_L1, m_key_l1);
- DDX_Control(pDX, IDC_L2, m_key_l2);
- DDX_Control(pDX, IDC_SHIF, m_key_shif);
- DDX_Control(pDX, IDC_Z, m_key_z);
- DDX_Control(pDX, IDC_X, m_key_x);
- DDX_Control(pDX, IDC_C, m_key_c);
- DDX_Control(pDX, IDC_V, m_key_v);
- DDX_Control(pDX, IDC_B, m_key_b);
- DDX_Control(pDX, IDC_N, m_key_n);
- DDX_Control(pDX, IDC_M, m_key_m);
- DDX_Control(pDX, IDC_M1, m_key_m1);
- DDX_Control(pDX, IDC_M2, m_key_m2);
- DDX_Control(pDX, IDC_M3, m_key_m3);
- DDX_Control(pDX, IDC_CTRL, m_key_ctrl);
- DDX_Control(pDX, IDC_WND, m_key_wnd);
- DDX_Control(pDX, IDC_ALT, m_key_alt);
- DDX_Control(pDX, IDC_MENU, m_key_menu);
- DDX_Control(pDX, IDC_TOP, m_key_top);
- DDX_Control(pDX, IDC_BOTTOM, m_key_bottom);
- DDX_Control(pDX, IDC_LEFT, m_key_left);
- DDX_Control(pDX, IDC_RIGHT, m_key_right);
- DDX_Control(pDX, IDC_SPACE, m_key_space);
- DDX_Control(pDX, IDC_ENTER, m_key_enter);
- DDX_Control(pDX, IDC_PS, m_key_ps);
- DDX_Control(pDX, IDC_EXIT, m_key_exit);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CKeyBoardDlg, CDialog)
- ON_WM_CONTEXTMENU()
- //{{AFX_MSG_MAP(CKeyBoardDlg)
- ON_WM_SYSCOMMAND()
- ON_WM_PAINT()
- ON_WM_QUERYDRAGICON()
- ON_WM_NCHITTEST()//点窗体任何部位移动窗体
- ON_WM_ERASEBKGND()//重绘窗口
- ON_WM_CREATE()
- //}}AFX_MSG_MAP
- ON_BN_CLICKED(IDC_ESC, OnKeyEsc)
- ON_BN_CLICKED(IDC_F1, OnKeyF1)
- ON_BN_CLICKED(IDC_F2, OnKeyF2)
- ON_BN_CLICKED(IDC_F3, OnKeyF3)
- ON_BN_CLICKED(IDC_F4, OnKeyF4)
- ON_BN_CLICKED(IDC_F5, OnKeyF5)
- ON_BN_CLICKED(IDC_F6, OnKeyF6)
- ON_BN_CLICKED(IDC_F7, OnKeyF7)
- ON_BN_CLICKED(IDC_F8, OnKeyF8)
- ON_BN_CLICKED(IDC_F9, OnKeyF9)
- ON_BN_CLICKED(IDC_F10, OnKeyF10)
- ON_BN_CLICKED(IDC_F11, OnKeyF11)
- ON_BN_CLICKED(IDC_F12, OnKeyF12)
- ON_BN_CLICKED(IDC_PAUSE, OnKeyPause)
- ON_BN_CLICKED(IDC_INS, OnKeyIns)
- ON_BN_CLICKED(IDC_DEL, OnKeyDel)
- ON_BN_CLICKED(IDC_PGUP, OnKeyPgup)
- ON_BN_CLICKED(IDC_PGDN, OnKeyPgdn)
- ON_BN_CLICKED(IDC_HOME, OnKeyHome)
- ON_BN_CLICKED(IDC_END, OnKeyEnd)
- ON_BN_CLICKED(IDC_ONCE, OnKeyOnce)
- ON_BN_CLICKED(IDC_1, OnKey1)
- ON_BN_CLICKED(IDC_2, OnKey2)
- ON_BN_CLICKED(IDC_3, OnKey3)
- ON_BN_CLICKED(IDC_4, OnKey4)
- ON_BN_CLICKED(IDC_5, OnKey5)
- ON_BN_CLICKED(IDC_6, OnKey6)
- ON_BN_CLICKED(IDC_7, OnKey7)
- ON_BN_CLICKED(IDC_8, OnKey8)
- ON_BN_CLICKED(IDC_9, OnKey9)
- ON_BN_CLICKED(IDC_0, OnKey0)
- ON_BN_CLICKED(IDC_10, OnKey10)
- ON_BN_CLICKED(IDC_11, OnKey11)
- ON_BN_CLICKED(IDC_12, OnKey12)
- ON_BN_CLICKED(IDC_BSPC, OnKeyBspc)
- ON_BN_CLICKED(IDC_TAB, OnKeyTab)
- ON_BN_CLICKED(IDC_Q, OnKeyQ)
- ON_BN_CLICKED(IDC_W, OnKeyW)
- ON_BN_CLICKED(IDC_E, OnKeyE)
- ON_BN_CLICKED(IDC_R, OnKeyR)
- ON_BN_CLICKED(IDC_T, OnKeyT)
- ON_BN_CLICKED(IDC_Y, OnKeyY)
- ON_BN_CLICKED(IDC_U, OnKeyU)
- ON_BN_CLICKED(IDC_I, OnKeyI)
- ON_BN_CLICKED(IDC_O, OnKeyO)
- ON_BN_CLICKED(IDC_P, OnKeyP)
- ON_BN_CLICKED(IDC_P1, OnKeyP1)
- ON_BN_CLICKED(IDC_P2, OnKeyP2)
- ON_BN_CLICKED(IDC_CAPS, OnKeyCaps)
- ON_BN_CLICKED(IDC_A, OnKeyA)
- ON_BN_CLICKED(IDC_S, OnKeyS)
- ON_BN_CLICKED(IDC_D, OnKeyD)
- ON_BN_CLICKED(IDC_F, OnKeyF)
- ON_BN_CLICKED(IDC_G, OnKeyG)
- ON_BN_CLICKED(IDC_H, OnKeyH)
- ON_BN_CLICKED(IDC_J, OnKeyJ)
- ON_BN_CLICKED(IDC_K, OnKeyK)
- ON_BN_CLICKED(IDC_L, OnKeyL)
- ON_BN_CLICKED(IDC_L1, OnKeyL1)
- ON_BN_CLICKED(IDC_L2, OnKeyL2)
- ON_BN_CLICKED(IDC_Z, OnKeyZ)
- ON_BN_CLICKED(IDC_X, OnKeyX)
- ON_BN_CLICKED(IDC_C, OnKeyC)
- ON_BN_CLICKED(IDC_V, OnKeyV)
- ON_BN_CLICKED(IDC_B, OnKeyB)
- ON_BN_CLICKED(IDC_N, OnKeyN)
- ON_BN_CLICKED(IDC_M, OnKeyM)
- ON_BN_CLICKED(IDC_M1, OnKeyM1)
- ON_BN_CLICKED(IDC_M2, OnKeyM2)
- ON_BN_CLICKED(IDC_M3, OnKeyM3)
- ON_BN_CLICKED(IDC_WND, OnKeyWnd)
- ON_BN_CLICKED(IDC_MENU, OnKeyMenu)
- ON_BN_CLICKED(IDC_TOP, OnKeyTop)
- ON_BN_CLICKED(IDC_BOTTOM, OnKeyBotton)
- ON_BN_CLICKED(IDC_LEFT, OnKeyLeft)
- ON_BN_CLICKED(IDC_RIGHT, OnKeyRight)
- ON_BN_CLICKED(IDC_SPACE, OnKeySpace)
- ON_BN_CLICKED(IDC_ENTER, OnKeyEnter)
- ON_BN_CLICKED(IDC_PS, OnKeyPs)
- ON_BN_CLICKED(IDC_ABOUT, OnAbout)
- ON_BN_CLICKED(IDC_SHIF, OnKeyShif)
- ON_BN_CLICKED(IDC_CTRL, OnKeyCtrl)
- ON_BN_CLICKED(IDC_ALT, OnKeyAlt)
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CKeyBoardDlg message handlers
- BOOL CKeyBoardDlg::OnInitDialog()
- {
- CDialog::OnInitDialog();
- // Add "About..." menu item to system menu.
- // IDM_ABOUTBOX must be in the system command range.
- ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
- ASSERT(IDM_ABOUTBOX < 0xF000);
- CMenu* pSysMenu = GetSystemMenu(FALSE);
- if (pSysMenu != NULL)
- {
- CString strAboutMenu;
- strAboutMenu.LoadString(IDS_ABOUTBOX);
- if (!strAboutMenu.IsEmpty())
- {
- pSysMenu->AppendMenu(MF_SEPARATOR);
- pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
- }
- }
- // Set the icon for this dialog. The framework does this automatically
- // when the application's main window is not a dialog
- SetIcon(m_hIcon, TRUE); // Set big icon
- SetIcon(m_hIcon, FALSE); // Set small icon
- // TODO: Add extra initialization here
- //设置矩形窗口(内部)
- CRect winrect;
- GetClientRect(&winrect);
- m_brush.CreateSolidBrush(RGB(255,255,255));
- m_rgn.CreateRectRgn(0,0,winrect.right,winrect.bottom);
- SetWindowRgn(m_rgn, 1);
- SetWindowText(_T("软键盘"));
- //////////////////////////////////////////////
- //加载按钮图片
- m_key_esc.SetBitmaps(IDB_ESC_UP, RGB(0, 255, 0),IDB_ESC_DOWN, RGB(0, 255, 0));
- m_key_esc.DrawTransparent(TRUE);
- m_key_esc.DrawBorder(FALSE);
- m_key_esc.SetBtnCursor(IDC_HAND);
- m_key_f1.SetBitmaps(IDB_F1_UP, RGB(0, 255, 0),IDB_F1_DOWN, RGB(0, 255, 0));
- m_key_f1.DrawTransparent(TRUE);
- m_key_f1.DrawBorder(FALSE);
- m_key_f1.SetBtnCursor(IDC_HAND);
- m_key_f2.SetBitmaps(IDB_F2_UP, RGB(0, 255, 0),IDB_F2_DOWN, RGB(0, 255, 0));
- m_key_f2.DrawTransparent(TRUE);
- m_key_f2.DrawBorder(FALSE);
- m_key_f2.SetBtnCursor(IDC_HAND);
- m_key_f3.SetBitmaps(IDB_F3_UP, RGB(0, 255, 0),IDB_F3_DOWN, RGB(0, 255, 0));
- m_key_f3.DrawTransparent(TRUE);
- m_key_f3.DrawBorder(FALSE);
- m_key_f3.SetBtnCursor(IDC_HAND);
- m_key_f4.SetBitmaps(IDB_F4_UP, RGB(0, 255, 0),IDB_F4_DOWN, RGB(0, 255, 0));
- m_key_f4.DrawTransparent(TRUE);
- m_key_f4.DrawBorder(FALSE);
- m_key_f4.SetBtnCursor(IDC_HAND);
- m_key_f5.SetBitmaps(IDB_F5_UP, RGB(0, 255, 0),IDB_F5_DOWN, RGB(0, 255, 0));
- m_key_f5.DrawTransparent(TRUE);
- m_key_f5.DrawBorder(FALSE);
- m_key_f5.SetBtnCursor(IDC_HAND);
- m_key_f6.SetBitmaps(IDB_F6_UP, RGB(0, 255, 0),IDB_F6_DOWN, RGB(0, 255, 0));
- m_key_f6.DrawTransparent(TRUE);
- m_key_f6.DrawBorder(FALSE);
- m_key_f6.SetBtnCursor(IDC_HAND);
- m_key_f7.SetBitmaps(IDB_F7_UP, RGB(0, 255, 0),IDB_F7_DOWN, RGB(0, 255, 0));
- m_key_f7.DrawTransparent(TRUE);
- m_key_f7.DrawBorder(FALSE);
- m_key_f7.SetBtnCursor(IDC_HAND);
- m_key_f8.SetBitmaps(IDB_F8_UP, RGB(0, 255, 0),IDB_F8_DOWN, RGB(0, 255, 0));
- m_key_f8.DrawTransparent(TRUE);
- m_key_f8.DrawBorder(FALSE);
- m_key_f8.SetBtnCursor(IDC_HAND);
- m_key_f9.SetBitmaps(IDB_F9_UP, RGB(0, 255, 0),IDB_F9_DOWN, RGB(0, 255, 0));
- m_key_f9.DrawTransparent(TRUE);
- m_key_f9.DrawBorder(FALSE);
- m_key_f9.SetBtnCursor(IDC_HAND);
- m_key_f10.SetBitmaps(IDB_F10_UP, RGB(0, 255, 0),IDB_F10_DOWN, RGB(0, 255, 0));
- m_key_f10.DrawTransparent(TRUE);
- m_key_f10.DrawBorder(FALSE);
- m_key_f10.SetBtnCursor(IDC_HAND);
- m_key_f11.SetBitmaps(IDB_F11_UP, RGB(0, 255, 0),IDB_F11_DOWN, RGB(0, 255, 0));
- m_key_f11.DrawTransparent(TRUE);
- m_key_f11.DrawBorder(FALSE);
- m_key_f11.SetBtnCursor(IDC_HAND);
- m_key_f12.SetBitmaps(IDB_F12_UP, RGB(0, 255, 0),IDB_F12_DOWN, RGB(0, 255, 0));
- m_key_f12.DrawTransparent(TRUE);
- m_key_f12.DrawBorder(FALSE);
- m_key_f12.SetBtnCursor(IDC_HAND);
- m_key_pause.SetBitmaps(IDB_PAUSE_UP, RGB(0, 255, 0),IDB_PAUSE_DOWN, RGB(0, 255, 0));
- m_key_pause.DrawTransparent(TRUE);
- m_key_pause.DrawBorder(FALSE);
- m_key_pause.SetBtnCursor(IDC_HAND);
- m_key_ins.SetBitmaps(IDB_INS_UP, RGB(0, 255, 0),IDB_INS_DOWN, RGB(0, 255, 0));
- m_key_ins.DrawTransparent(TRUE);
- m_key_ins.DrawBorder(FALSE);
- m_key_ins.SetBtnCursor(IDC_HAND);
- m_key_del.SetBitmaps(IDB_DEL_UP, RGB(0, 255, 0),IDB_DEL_DOWN, RGB(0, 255, 0));
- m_key_del.DrawTransparent(TRUE);
- m_key_del.DrawBorder(FALSE);
- m_key_del.SetBtnCursor(IDC_HAND);
- m_key_pgup.SetBitmaps(IDB_PGUP_UP, RGB(0, 255, 0),IDB_PGUP_DOWN, RGB(0, 255, 0));
- m_key_pgup.DrawTransparent(TRUE);
- m_key_pgup.DrawBorder(FALSE);
- m_key_pgup.SetBtnCursor(IDC_HAND);
- m_key_pgdn.SetBitmaps(IDB_PGDN_UP, RGB(0, 255, 0),IDB_PGDN_DOWN, RGB(0, 255, 0));
- m_key_pgdn.DrawTransparent(TRUE);
- m_key_pgdn.DrawBorder(FALSE);
- m_key_pgdn.SetBtnCursor(IDC_HAND);
- m_key_home.SetBitmaps(IDB_HOME_UP, RGB(0, 255, 0),IDB_HOME_DOWN, RGB(0, 255, 0));
- m_key_home.DrawTransparent(TRUE);
- m_key_home.DrawBorder(FALSE);
- m_key_home.SetBtnCursor(IDC_HAND);
- m_key_end.SetBitmaps(IDB_END_UP, RGB(0, 255, 0),IDB_END_DOWN, RGB(0, 255, 0));
- m_key_end.DrawTransparent(TRUE);
- m_key_end.DrawBorder(FALSE);
- m_key_end.SetBtnCursor(IDC_HAND);
- m_key_once.SetBitmaps(IDB_ONCE_UP, RGB(0, 255, 0),IDB_ONCE_DOWN, RGB(0, 255, 0));
- m_key_once.DrawTransparent(TRUE);
- m_key_once.DrawBorder(FALSE);
- m_key_once.SetBtnCursor(IDC_HAND);
- m_key_1.SetBitmaps(IDB_1_UP, RGB(0, 255, 0),IDB_1_DOWN, RGB(0, 255, 0));
- m_key_1.DrawTransparent(TRUE);
- m_key_1.DrawBorder(FALSE);
- m_key_1.SetBtnCursor(IDC_HAND);
- m_key_2.SetBitmaps(IDB_2_UP, RGB(0, 255, 0),IDB_2_DOWN, RGB(0, 255, 0));
- m_key_2.DrawTransparent(TRUE);
- m_key_2.DrawBorder(FALSE);
- m_key_2.SetBtnCursor(IDC_HAND);
- m_key_3.SetBitmaps(IDB_3_UP, RGB(0, 255, 0),IDB_3_DOWN, RGB(0, 255, 0));
- m_key_3.DrawTransparent(TRUE);
- m_key_3.DrawBorder(FALSE);
- m_key_3.SetBtnCursor(IDC_HAND);
- m_key_4.SetBitmaps(IDB_4_UP, RGB(0, 255, 0),IDB_4_DOWN, RGB(0, 255, 0));
- m_key_4.DrawTransparent(TRUE);
- m_key_4.DrawBorder(FALSE);
- m_key_4.SetBtnCursor(IDC_HAND);
- m_key_5.SetBitmaps(IDB_5_UP, RGB(0, 255, 0),IDB_5_DOWN, RGB(0, 255, 0));
- m_key_5.DrawTransparent(TRUE);
- m_key_5.DrawBorder(FALSE);
- m_key_5.SetBtnCursor(IDC_HAND);
- m_key_6.SetBitmaps(IDB_6_UP, RGB(0, 255, 0),IDB_6_DOWN, RGB(0, 255, 0));
- m_key_6.DrawTransparent(TRUE);
- m_key_6.DrawBorder(FALSE);
- m_key_6.SetBtnCursor(IDC_HAND);
- m_key_7.SetBitmaps(IDB_7_UP, RGB(0, 255, 0),IDB_7_DOWN, RGB(0, 255, 0));
- m_key_7.DrawTransparent(TRUE);
- m_key_7.DrawBorder(FALSE);
- m_key_7.SetBtnCursor(IDC_HAND);
- m_key_8.SetBitmaps(IDB_8_UP, RGB(0, 255, 0),IDB_8_DOWN, RGB(0, 255, 0));
- m_key_8.DrawTransparent(TRUE);
- m_key_8.DrawBorder(FALSE);
- m_key_8.SetBtnCursor(IDC_HAND);
- m_key_9.SetBitmaps(IDB_9_UP, RGB(0, 255, 0),IDB_9_DOWN, RGB(0, 255, 0));
- m_key_9.DrawTransparent(TRUE);
- m_key_9.DrawBorder(FALSE);
- m_key_9.SetBtnCursor(IDC_HAND);
- m_key_0.SetBitmaps(IDB_0_UP, RGB(0, 255, 0),IDB_0_DOWN, RGB(0, 255, 0));
- m_key_0.DrawTransparent(TRUE);
- m_key_0.DrawBorder(FALSE);
- m_key_0.SetBtnCursor(IDC_HAND);
- m_key_10.SetBitmaps(IDB_10_UP, RGB(0, 255, 0),IDB_10_DOWN, RGB(0, 255, 0));
- m_key_10.DrawTransparent(TRUE);
- m_key_10.DrawBorder(FALSE);
- m_key_10.SetBtnCursor(IDC_HAND);
- m_key_11.SetBitmaps(IDB_11_UP, RGB(0, 255, 0),IDB_11_DOWN, RGB(0, 255, 0));
- m_key_11.DrawTransparent(TRUE);
- m_key_11.DrawBorder(FALSE);
- m_key_11.SetBtnCursor(IDC_HAND);
- m_key_12.SetBitmaps(IDB_12_UP, RGB(0, 255, 0),IDB_12_DOWN, RGB(0, 255, 0));
- m_key_12.DrawTransparent(TRUE);
- m_key_12.DrawBorder(FALSE);
- m_key_12.SetBtnCursor(IDC_HAND);
- m_key_bspc.SetBitmaps(IDB_BSPC_UP, RGB(0, 255, 0),IDB_BSPC_DOWN, RGB(0, 255, 0));
- m_key_bspc.DrawTransparent(TRUE);
- m_key_bspc.DrawBorder(FALSE);
- m_key_bspc.SetBtnCursor(IDC_HAND);
- m_key_tab.SetBitmaps(IDB_TAB_UP, RGB(0, 255, 0),IDB_TAB_DOWN, RGB(0, 255, 0));
- m_key_tab.DrawTransparent(TRUE);
- m_key_tab.DrawBorder(FALSE);
- m_key_tab.SetBtnCursor(IDC_HAND);
- m_key_q.SetBitmaps(IDB_Q_UP, RGB(0, 255, 0),IDB_Q_DOWN, RGB(0, 255, 0));
- m_key_q.DrawTransparent(TRUE);
- m_key_q.DrawBorder(FALSE);
- m_key_q.SetBtnCursor(IDC_HAND);
- m_key_w.SetBitmaps(IDB_W_UP, RGB(0, 255, 0),IDB_W_DOWN, RGB(0, 255, 0));
- m_key_w.DrawTransparent(TRUE);
- m_key_w.DrawBorder(FALSE);
- m_key_w.SetBtnCursor(IDC_HAND);
- m_key_e.SetBitmaps(IDB_E_UP, RGB(0, 255, 0),IDB_E_DOWN, RGB(0, 255, 0));
- m_key_e.DrawTransparent(TRUE);
- m_key_e.DrawBorder(FALSE);
- m_key_e.SetBtnCursor(IDC_HAND);
- m_key_r.SetBitmaps(IDB_R_UP, RGB(0, 255, 0),IDB_R_DOWN, RGB(0, 255, 0));
- m_key_r.DrawTransparent(TRUE);
- m_key_r.DrawBorder(FALSE);
- m_key_r.SetBtnCursor(IDC_HAND);
- m_key_t.SetBitmaps(IDB_T_UP, RGB(0, 255, 0),IDB_T_DOWN, RGB(0, 255, 0));
- m_key_t.DrawTransparent(TRUE);
- m_key_t.DrawBorder(FALSE);
- m_key_t.SetBtnCursor(IDC_HAND);
- m_key_y.SetBitmaps(IDB_Y_UP, RGB(0, 255, 0),IDB_Y_DOWN, RGB(0, 255, 0));
- m_key_y.DrawTransparent(TRUE);
- m_key_y.DrawBorder(FALSE);
- m_key_y.SetBtnCursor(IDC_HAND);
- m_key_u.SetBitmaps(IDB_U_UP, RGB(0, 255, 0),IDB_U_DOWN, RGB(0, 255, 0));
- m_key_u.DrawTransparent(TRUE);
- m_key_u.DrawBorder(FALSE);
- m_key_u.SetBtnCursor(IDC_HAND);
- m_key_i.SetBitmaps(IDB_I_UP, RGB(0, 255, 0),IDB_I_DOWN, RGB(0, 255, 0));
- m_key_i.DrawTransparent(TRUE);
- m_key_i.DrawBorder(FALSE);
- m_key_i.SetBtnCursor(IDC_HAND);
- m_key_o.SetBitmaps(IDB_O_UP, RGB(0, 255, 0),IDB_O_DOWN, RGB(0, 255, 0));
- m_key_o.DrawTransparent(TRUE);
- m_key_o.DrawBorder(FALSE);
- m_key_o.SetBtnCursor(IDC_HAND);
- m_key_p.SetBitmaps(IDB_P_UP, RGB(0, 255, 0),IDB_P_DOWN, RGB(0, 255, 0));
- m_key_p.DrawTransparent(TRUE);
- m_key_p.DrawBorder(FALSE);
- m_key_p.SetBtnCursor(IDC_HAND);
- m_key_p1.SetBitmaps(IDB_P1_UP, RGB(0, 255, 0),IDB_P1_DOWN, RGB(0, 255, 0));
- m_key_p1.DrawTransparent(TRUE);
- m_key_p1.DrawBorder(FALSE);
- m_key_p1.SetBtnCursor(IDC_HAND);
- m_key_p2.SetBitmaps(IDB_P2_UP, RGB(0, 255, 0),IDB_P2_DOWN, RGB(0, 255, 0));
- m_key_p2.DrawTransparent(TRUE);
- m_key_p2.DrawBorder(FALSE);
- m_key_p2.SetBtnCursor(IDC_HAND);
- m_key_caps.SetBitmaps(IDB_CAPS_UP, RGB(0, 255, 0),IDB_CAPS_DOWN, RGB(0, 255, 0));
- m_key_caps.DrawTransparent(TRUE);
- m_key_caps.DrawBorder(FALSE);
- m_key_caps.SetBtnCursor(IDC_HAND);
- m_key_a.SetBitmaps(IDB_A_UP, RGB(0, 255, 0),IDB_A_DOWN, RGB(0, 255, 0));
- m_key_a.DrawTransparent(TRUE);
- m_key_a.DrawBorder(FALSE);
- m_key_a.SetBtnCursor(IDC_HAND);
- m_key_s.SetBitmaps(IDB_S_UP, RGB(0, 255, 0),IDB_S_DOWN, RGB(0, 255, 0));
- m_key_s.DrawTransparent(TRUE);
- m_key_s.DrawBorder(FALSE);
- m_key_s.SetBtnCursor(IDC_HAND);
- m_key_d.SetBitmaps(IDB_D_UP, RGB(0, 255, 0),IDB_D_DOWN, RGB(0, 255, 0));
- m_key_d.DrawTransparent(TRUE);
- m_key_d.DrawBorder(FALSE);
- m_key_d.SetBtnCursor(IDC_HAND);
- m_key_f.SetBitmaps(IDB_F_UP, RGB(0, 255, 0),IDB_F_DOWN, RGB(0, 255, 0));
- m_key_f.DrawTransparent(TRUE);
- m_key_f.DrawBorder(FALSE);
- m_key_f.SetBtnCursor(IDC_HAND);
- m_key_g.SetBitmaps(IDB_G_UP, RGB(0, 255, 0),IDB_G_DOWN, RGB(0, 255, 0));
- m_key_g.DrawTransparent(TRUE);
- m_key_g.DrawBorder(FALSE);
- m_key_g.SetBtnCursor(IDC_HAND);
- m_key_h.SetBitmaps(IDB_H_UP, RGB(0, 255, 0),IDB_H_DOWN, RGB(0, 255, 0));
- m_key_h.DrawTransparent(TRUE);
- m_key_h.DrawBorder(FALSE);
- m_key_h.SetBtnCursor(IDC_HAND);
- m_key_j.SetBitmaps(IDB_J_UP, RGB(0, 255, 0),IDB_J_DOWN, RGB(0, 255, 0));
- m_key_j.DrawTransparent(TRUE);
- m_key_j.DrawBorder(FALSE);
- m_key_j.SetBtnCursor(IDC_HAND);
- m_key_k.SetBitmaps(IDB_K_UP, RGB(0, 255, 0),IDB_K_DOWN, RGB(0, 255, 0));
- m_key_k.DrawTransparent(TRUE);
- m_key_k.DrawBorder(FALSE);
- m_key_k.SetBtnCursor(IDC_HAND);
- m_key_l.SetBitmaps(IDB_L_UP, RGB(0, 255, 0),IDB_L_DOWN, RGB(0, 255, 0));
- m_key_l.DrawTransparent(TRUE);
- m_key_l.DrawBorder(FALSE);
- m_key_l.SetBtnCursor(IDC_HAND);
- m_key_l1.SetBitmaps(IDB_L1_UP, RGB(0, 255, 0),IDB_L1_DOWN, RGB(0, 255, 0));
- m_key_l1.DrawTransparent(TRUE);
- m_key_l1.DrawBorder(FALSE);
- m_key_l1.SetBtnCursor(IDC_HAND);
- m_key_l2.SetBitmaps(IDB_L2_UP, RGB(0, 255, 0),IDB_L2_DOWN, RGB(0, 255, 0));
- m_key_l2.DrawTransparent(TRUE);
- m_key_l2.DrawBorder(FALSE);
- m_key_l2.SetBtnCursor(IDC_HAND);
- m_key_shif.SetBitmaps(IDB_SHIF_UP, RGB(0, 255, 0),IDB_SHIF_DOWN, RGB(0, 255, 0));
- m_key_shif.DrawTransparent(TRUE);
- m_key_shif.DrawBorder(FALSE);
- m_key_shif.SetBtnCursor(IDC_HAND);
- m_key_z.SetBitmaps(IDB_Z_UP, RGB(0, 255, 0),IDB_Z_DOWN, RGB(0, 255, 0));
- m_key_z.DrawTransparent(TRUE);
- m_key_z.DrawBorder(FALSE);
- m_key_z.SetBtnCursor(IDC_HAND);
- m_key_x.SetBitmaps(IDB_X_UP, RGB(0, 255, 0),IDB_X_DOWN, RGB(0, 255, 0));
- m_key_x.DrawTransparent(TRUE);
- m_key_x.DrawBorder(FALSE);
- m_key_x.SetBtnCursor(IDC_HAND);
- m_key_c.SetBitmaps(IDB_C_UP, RGB(0, 255, 0),IDB_C_DOWN, RGB(0, 255, 0));
- m_key_c.DrawTransparent(TRUE);
- m_key_c.DrawBorder(FALSE);
- m_key_c.SetBtnCursor(IDC_HAND);
- m_key_v.SetBitmaps(IDB_V_UP, RGB(0, 255, 0),IDB_V_DOWN, RGB(0, 255, 0));
- m_key_v.DrawTransparent(TRUE);
- m_key_v.DrawBorder(FALSE);
- m_key_v.SetBtnCursor(IDC_HAND);
- m_key_b.SetBitmaps(IDB_B_UP, RGB(0, 255, 0),IDB_B_DOWN, RGB(0, 255, 0));
- m_key_b.DrawTransparent(TRUE);
- m_key_b.DrawBorder(FALSE);
- m_key_b.SetBtnCursor(IDC_HAND);
- m_key_n.SetBitmaps(IDB_N_UP, RGB(0, 255, 0),IDB_N_DOWN, RGB(0, 255, 0));
- m_key_n.DrawTransparent(TRUE);
- m_key_n.DrawBorder(FALSE);
- m_key_n.SetBtnCursor(IDC_HAND);
- m_key_m.SetBitmaps(IDB_M_UP, RGB(0, 255, 0),IDB_M_DOWN, RGB(0, 255, 0));
- m_key_m.DrawTransparent(TRUE);
- m_key_m.DrawBorder(FALSE);
- m_key_m.SetBtnCursor(IDC_HAND);
- m_key_m1.SetBitmaps(IDB_M1_UP, RGB(0, 255, 0),IDB_M1_DOWN, RGB(0, 255, 0));
- m_key_m1.DrawTransparent(TRUE);
- m_key_m1.DrawBorder(FALSE);
- m_key_m1.SetBtnCursor(IDC_HAND);
- m_key_m2.SetBitmaps(IDB_M2_UP, RGB(0, 255, 0),IDB_M2_DOWN, RGB(0, 255, 0));
- m_key_m2.DrawTransparent(TRUE);
- m_key_m2.DrawBorder(FALSE);
- m_key_m2.SetBtnCursor(IDC_HAND);
- m_key_m3.SetBitmaps(IDB_M3_UP, RGB(0, 255, 0),IDB_M3_DOWN, RGB(0, 255, 0));
- m_key_m3.DrawTransparent(TRUE);
- m_key_m3.DrawBorder(FALSE);
- m_key_m3.SetBtnCursor(IDC_HAND);
- m_key_ctrl.SetBitmaps(IDB_CTRL_UP, RGB(0, 255, 0),IDB_CTRL_DOWN, RGB(0, 255, 0));
- m_key_ctrl.DrawTransparent(TRUE);
- m_key_ctrl.DrawBorder(FALSE);
- m_key_ctrl.SetBtnCursor(IDC_HAND);
- m_key_wnd.SetBitmaps(IDB_WND_UP, RGB(0, 255, 0),IDB_WND_DOWN, RGB(0, 255, 0));
- m_key_wnd.DrawTransparent(TRUE);
- m_key_wnd.DrawBorder(FALSE);
- m_key_wnd.SetBtnCursor(IDC_HAND);
- m_key_alt.SetBitmaps(IDB_ALT_UP, RGB(0, 255, 0),IDB_ALT_DOWN, RGB(0, 255, 0));
- m_key_alt.DrawTransparent(TRUE);
- m_key_alt.DrawBorder(FALSE);
- m_key_alt.SetBtnCursor(IDC_HAND);
- m_key_menu.SetBitmaps(IDB_MENU_UP, RGB(0, 255, 0),IDB_MENU_DOWN, RGB(0, 255, 0));
- m_key_menu.DrawTransparent(TRUE);
- m_key_menu.DrawBorder(FALSE);
- m_key_menu.SetBtnCursor(IDC_HAND);
- m_key_top.SetBitmaps(IDB_TOP_UP, RGB(0, 255, 0),IDB_TOP_DOWN, RGB(0, 255, 0));
- m_key_top.DrawTransparent(TRUE);
- m_key_top.DrawBorder(FALSE);
- m_key_top.SetBtnCursor(IDC_HAND);
- m_key_bottom.SetBitmaps(IDB_BOTTOM_UP, RGB(0, 255, 0),IDB_BOTTOM_DOWN, RGB(0, 255, 0));
- m_key_bottom.DrawTransparent(TRUE);
- m_key_bottom.DrawBorder(FALSE);
- m_key_bottom.SetBtnCursor(IDC_HAND);
- m_key_left.SetBitmaps(IDB_LEFT_UP, RGB(0, 255, 0),IDB_LEFT_DOWN, RGB(0, 255, 0));
- m_key_left.DrawTransparent(TRUE);
- m_key_left.DrawBorder(FALSE);
- m_key_left.SetBtnCursor(IDC_HAND);
- m_key_right.SetBitmaps(IDB_RIGHT_UP, RGB(0, 255, 0),IDB_RIGHT_DOWN, RGB(0, 255, 0));
- m_key_right.DrawTransparent(TRUE);
- m_key_right.DrawBorder(FALSE);
- m_key_right.SetBtnCursor(IDC_HAND);
- m_key_space.SetBitmaps(IDB_SPACE, RGB(0, 255, 0));
- m_key_space.DrawTransparent(TRUE);
- m_key_space.DrawBorder(FALSE);
- m_key_space.SetBtnCursor(IDC_HAND);
- m_key_enter.SetBitmaps(IDB_ENTER_UP, RGB(0, 255, 0),IDB_ENTER_DOWN, RGB(0, 255, 0));
- m_key_enter.DrawTransparent(TRUE);
- m_key_enter.DrawBorder(FALSE);
- m_key_enter.SetBtnCursor(IDC_HAND);
- m_key_ps.SetBitmaps(IDB_PS_UP, RGB(0, 255, 0),IDB_PS_DOWN, RGB(0, 255, 0));
- m_key_ps.DrawTransparent(TRUE);
- m_key_ps.DrawBorder(FALSE);
- m_key_ps.SetBtnCursor(IDC_HAND);
- m_key_exit.SetBitmaps(IDB_EXIT_UP, RGB(0, 255, 0),IDB_EXIT_DOWN, RGB(0, 255, 0));
- m_key_exit.DrawTransparent(TRUE);
- m_key_exit.DrawBorder(FALSE);
- m_key_exit.SetBtnCursor(IDC_HAND);
- //////////////////////////////////////////////
- return TRUE; // return TRUE unless you set the focus to a control
- }
- void CKeyBoardDlg::OnSysCommand(UINT nID, LPARAM lParam)
- {
- if ((nID & 0xFFF0) == IDM_ABOUTBOX)
- {
- CAboutDlg dlgAbout;
- dlgAbout.DoModal();
- }
- else
- {
- CDialog::OnSysCommand(nID, lParam);
- }
- }
- // If you add a minimize button to your dialog, you will need the code below
- // to draw the icon. For MFC applications using the document/view model,
- // this is automatically done for you by the framework.
- void CKeyBoardDlg::OnPaint()
- {
- if (IsIconic())
- {
- CPaintDC dc(this); // device context for painting
- SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
- // Center icon in client rectangle
- int cxIcon = GetSystemMetrics(SM_CXICON);
- int cyIcon = GetSystemMetrics(SM_CYICON);
- CRect rect;
- GetClientRect(&rect);
- int x = (rect.Width() - cxIcon + 1) / 2;
- int y = (rect.Height() - cyIcon + 1) / 2;
- // Draw the icon
- dc.DrawIcon(x, y, m_hIcon);
- }
- else
- {
- CDialog::OnPaint();
- }
- }
- // The system calls this to obtain the cursor to display while the user drags
- // the minimized window.
- HCURSOR CKeyBoardDlg::OnQueryDragIcon()
- {
- return (HCURSOR) m_hIcon;
- }
- void CKeyBoardDlg::OnContextMenu(CWnd*, CPoint point)
- {
- if (point.x == -1 && point.y == -1)
- {
- CRect rect;
- GetClientRect(rect);
- ClientToScreen(rect);
- point = rect.TopLeft();
- point.Offset(5, 5);
- }
- BCMenu popmenu;
- popmenu.LoadMenu(CG_IDR_POPUP_KEY_BOARD_DLG);
- BCMenu::SetMenuDrawMode(BCMENU_DRAWMODE_XP);
- //显示图片
- popmenu.ModifyODMenu(NULL, IDCANCEL,IDB_QUIT);
- popmenu.ModifyODMenu(NULL, IDC_ABOUT,IDB_ABOUT);
- BCMenu *psub = (BCMenu *)popmenu.GetSubMenu(0);
- psub->TrackPopupMenu(TPM_LEFTALIGN|TPM_RIGHTBUTTON,point.x,point.y,this);
- popmenu.DestroyMenu();
- }
- //重绘窗口
- BOOL CKeyBoardDlg::OnEraseBkgnd(CDC *pDC)
- {
- CRgn myrgn;
- CBrush frameBrush;
- CRect winrect;
- GetClientRect(&winrect);
- // myrgn.CreateRectRgn(0,0,winrect.right,winrect.bottom);//绘制直角矩形
- myrgn.CreateRoundRectRgn(0,0,winrect.right,winrect.bottom,5,5);//绘制圆角矩形圆角度5
- frameBrush.CreateSolidBrush(RGB(0,158,221)); //边框颜色
- pDC->FillRgn(&myrgn,&m_brush);
- pDC->FrameRgn(&myrgn,&frameBrush,1,1);
- pDC->SetBkMode(TRANSPARENT);
- return TRUE;
- }
- //点窗体任何部位移动窗体
- UINT CKeyBoardDlg::OnNcHitTest(CPoint point)
- {
- UINT nHitTest = CDialog :: OnNcHitTest (point);
- return (nHitTest == HTCLIENT) ? HTCAPTION :nHitTest;
- }
- void CKeyBoardDlg::OnAbout()
- {
- // TODO: Add your control notification handler code here
- CAboutDlg about;
- about.DoModal();
- }
- void CAboutDlg::OnLButtonDown(UINT nFlags, CPoint point)
- {
- // TODO: Add your message handler code here and/or call default
- PostMessage(WM_CLOSE);
- CDialog::OnLButtonDown(nFlags, point);
- }
- BOOL CAboutDlg::OnInitDialog()
- {
- CDialog::OnInitDialog();
- //设置矩形窗口(内部)
- CRect winrect;
- GetClientRect(&winrect);
- m_brush.CreateSolidBrush(RGB(255,255,255));
- m_rgn.CreateRectRgn(0,0,winrect.right,winrect.bottom);
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX PropertyPages should return FALSE
- }
- BOOL CAboutDlg::OnEraseBkgnd(CDC *pDC)
- {
- CRgn myrgn,rgn;
- CBrush frameBrush;
- CRect winrect;
- GetClientRect(&winrect);
- myrgn.CreateRoundRectRgn(0,0,winrect.right,winrect.bottom,5,5);//绘制圆角矩形圆角度5
- rgn.CreateRoundRectRgn(10,10,winrect.right - 10,winrect.bottom - 10,5,5);//绘制圆角矩形圆角度5
- frameBrush.CreateSolidBrush(RGB(0,158,221)); //边框颜色
- pDC->FillRgn(&myrgn,&m_brush);
- pDC->FrameRgn(&myrgn,&frameBrush,1,1);
- pDC->FrameRgn(&rgn,&frameBrush,1,1);
- //////////////////////////////////////////////
- // CBrush fillBrush;
- // CRgn fillRgn;
- // fillRgn.CreateRoundRectRgn(9,9,winrect.right - 10,winrect.bottom - 10,5,5);
- // fillBrush.CreateSolidBrush(RGB(107,210,250));
- // pDC->FillRgn(&fillRgn,&fillBrush);
- //////////////////////////////////////////////
- pDC->SetBkMode(TRANSPARENT);
- //文字
- CFont font;
- CRect tempRect;
- font.CreateFont(12,6,0,0,FW_NORMAL,0,0,0,GB2312_CHARSET,
- OUT_STROKE_PRECIS,CLIP_STROKE_PRECIS,DRAFT_QUALITY,
- VARIABLE_PITCH|FF_SWISS,"宋体");
- pDC->SelectObject(&font);
- tempRect.top=20;
- tempRect.left=55;
- tempRect.right=500;
- tempRect.bottom=200;
- pDC->DrawText(_T("KeyBoard 1.0 版"),&tempRect,DT_TOP|DT_WORDBREAK);
- tempRect.top+=25;
- pDC->DrawText(_T("STORM 版权所有(C)2005"),&tempRect,DT_TOP|DT_WORDBREAK);
- tempRect.top+=13;
- pDC->DrawText(_T("storm_jyd@163.com"),&tempRect,DT_TOP|DT_WORDBREAK);
- return TRUE;
- }
- int CKeyBoardDlg::OnCreate(LPCREATESTRUCT lpCreateStruct)
- {
- if (CDialog::OnCreate(lpCreateStruct) == -1)
- return -1;
- //置窗体为最顶层显示及其位置
- CRect rcW;
- GetWindowRect(&rcW);
- SetWindowPos(&wndTopMost,rcW.left,rcW.top,rcW.Width(),rcW.Height(),SWP_NOSIZE|SWP_NOMOVE);
- return 0;
- }
- //处理系统消息循环
- BOOL CKeyBoardDlg::PreTranslateMessage(MSG* pMsg)
- {
- HWND wnd = ::GetForegroundWindow();
- if(IsWindow(wnd))
- {
- //如果当前激活窗口不是本程序的窗口
- if(wnd != this->m_hWnd)
- {
- //激活窗口发生了改变
- if(m_Focus != wnd)
- {
- if(IsWindow(m_Focus))
- {
- //释放本进程和gFocus线程的联系
- AttachThreadInput(
- GetWindowThreadProcessId(m_hWnd,NULL),
- GetWindowThreadProcessId(m_Focus,NULL),
- FALSE);
- }
- m_Focus = wnd;
- //使本进程和激活窗口的进程联系起来,接收本进程的按键消息
- AttachThreadInput(
- GetWindowThreadProcessId(m_hWnd,NULL),
- GetWindowThreadProcessId(m_Focus,NULL),
- TRUE);
- }
- }
- }
- return CDialog::PreTranslateMessage(pMsg);
- }
- void CKeyBoardDlg::ReleaseFocus()
- {
- //释放焦点
- if(IsWindow(m_Focus))
- {
- HWND wnd = ::GetForegroundWindow();
- if(IsWindow(wnd))
- {
- if(wnd == m_Focus)
- {
- return;
- }
- }
- //设置保存的焦点窗口处于激活状态
- ::SetForegroundWindow(m_Focus);
- ::SetFocus(m_Focus);
- }
- }
- void CKeyBoardDlg::OnKeyEsc()
- {
- ReleaseFocus();
- keybd_event(VK_ESCAPE,0,0,0);
- keybd_event(VK_ESCAPE,0,KEYEVENTF_KEYUP,0);
- ReleaseFocus();
- }
- void CKeyBoardDlg::OnKeyF1()
- {
- ReleaseFocus();
- keybd_event(VK_F1,0,0,0);
- keybd_event(VK_F1,0,KEYEVENTF_KEYUP,0);
- ReleaseFocus();
- }
- void CKeyBoardDlg::OnKeyF2()
- {
- ReleaseFocus();
- keybd_event(VK_F2,0,0,0);
- keybd_event(VK_F2,0,KEYEVENTF_KEYUP,0);
- ReleaseFocus();
- }
- void CKeyBoardDlg::OnKeyF3()
- {
- ReleaseFocus();
- keybd_event(VK_F3,0,0,0);
- keybd_event(VK_F3,0,KEYEVENTF_KEYUP,0);
- ReleaseFocus();
- }
- void CKeyBoardDlg::OnKeyF4()
- {
- ReleaseFocus();
- keybd_event(VK_F4,0,0,0);
- keybd_event(VK_F4,0,KEYEVENTF_KEYUP,0);
- ReleaseFocus();
- }
- void CKeyBoardDlg::OnKeyF5()
- {
- ReleaseFocus();
- keybd_event(VK_F5,0,0,0);
- keybd_event(VK_F5,0,KEYEVENTF_KEYUP,0);
- ReleaseFocus();
- }
- void CKeyBoardDlg::OnKeyF6()
- {
- ReleaseFocus();
- keybd_event(VK_F6,0,0,0);
- keybd_event(VK_F6,0,KEYEVENTF_KEYUP,0);
- ReleaseFocus();
- }
- void CKeyBoardDlg::OnKeyF7()
- {
- ReleaseFocus();
- keybd_event(VK_F7,0,0,0);
- keybd_event(VK_F7,0,KEYEVENTF_KEYUP,0);
- ReleaseFocus();
- }
- void CKeyBoardDlg::OnKeyF8()
- {
- ReleaseFocus();
- keybd_event(VK_F8,0,0,0);
- keybd_event(VK_F8,0,KEYEVENTF_KEYUP,0);
- ReleaseFocus();
- }
- void CKeyBoardDlg::OnKeyF9()
- {
- ReleaseFocus();
- keybd_event(VK_F9,0,0,0);
- keybd_event(VK_F9,0,KEYEVENTF_KEYUP,0);
- ReleaseFocus();
- }
- void CKeyBoardDlg::OnKeyF10()
- {
- ReleaseFocus();
- keybd_event(VK_F10,0,0,0);
- keybd_event(VK_F10,0,KEYEVENTF_KEYUP,0);
- ReleaseFocus();
- }
- void CKeyBoardDlg::OnKeyF11()
- {
- ReleaseFocus();
- keybd_event(VK_F11,0,0,0);
- keybd_event(VK_F11,0,KEYEVENTF_KEYUP,0);
- ReleaseFocus();
- }
- void CKeyBoardDlg::OnKeyF12()
- {
- ReleaseFocus();
- keybd_event(VK_F12,0,0,0);
- keybd_event(VK_F12,0,KEYEVENTF_KEYUP,0);
- ReleaseFocus();
- }
- void CKeyBoardDlg::OnKeyPause()
- {
- ReleaseFocus();
- keybd_event(VK_PAUSE,0,0,0);
- keybd_event(VK_PAUSE,0,KEYEVENTF_KEYUP,0);
- ReleaseFocus();
- }
- void CKeyBoardDlg::OnKeyIns()
- {
- ReleaseFocus();
- keybd_event(VK_INSERT,0,0,0);
- keybd_event(VK_INSERT,0,KEYEVENTF_KEYUP,0);
- ReleaseFocus();
- }
- void CKeyBoardDlg::OnKeyDel()
- {
- ReleaseFocus();
- keybd_event(VK_DELETE,0,0,0);
- keybd_event(VK_DELETE,0,KEYEVENTF_KEYUP,0);
- ReleaseFocus();
- }
- void CKeyBoardDlg::OnKeyPgup()
- {
- ReleaseFocus();
- keybd_event(VK_PRIOR,0,0,0);
- keybd_event(VK_PRIOR,0,KEYEVENTF_KEYUP,0);
- ReleaseFocus();
- }
- void CKeyBoardDlg::OnKeyPgdn()
- {
- ReleaseFocus();
- keybd_event(VK_NEXT,0,0,0);
- keybd_event(VK_NEXT,0,KEYEVENTF_KEYUP,0);
- ReleaseFocus();
- }
- void CKeyBoardDlg::OnKeyHome()
- {
- ReleaseFocus();
- keybd_event(VK_HOME,0,0,0);
- keybd_event(VK_HOME,0,KEYEVENTF_KEYUP,0);
- ReleaseFocus();
- }
- void CKeyBoardDlg::OnKeyEnd()
- {
- ReleaseFocus();
- keybd_event(VK_END,0,0,0);
- keybd_event(VK_END,0,KEYEVENTF_KEYUP,0);
- ReleaseFocus();
- }
- void CKeyBoardDlg::OnKeyOnce()
- {
- ReleaseFocus();
- char pChar;
- pChar = '`';
- SHORT ks = VkKeyScan(pChar);
- BYTE key = ks & 0xFF;
- keybd_event(key,0,0,0);
- keybd_event(key,0,KEYEVENTF_KEYUP,0);
- if(m_key_shif.GetCheck())//"shift"键是被按下
- {
- keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
- m_key_shif.SetCheck(FALSE);
- }
- ReleaseFocus();
- }
- void CKeyBoardDlg::OnKey1()
- {
- ReleaseFocus();
- char pChar;
- pChar = '1';
- SHORT ks = VkKeyScan(pChar);
- BYTE key = ks & 0xFF;
- keybd_event(key,0,0,0);
- keybd_event(key,0,KEYEVENTF_KEYUP,0);
- if(m_key_shif.GetCheck())//"shift"键是被按下
- {
- keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
- m_key_shif.SetCheck(FALSE);
- }
- ReleaseFocus();
- }
- void CKeyBoardDlg::OnKey2()
- {
- ReleaseFocus();
- char pChar;
- pChar = '2';
- SHORT ks = VkKeyScan(pChar);
- BYTE key = ks & 0xFF;
- keybd_event(key,0,0,0);
- keybd_event(key,0,KEYEVENTF_KEYUP,0);
- if(m_key_shif.GetCheck())//"shift"键是被按下
- {
- keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
- m_key_shif.SetCheck(FALSE);
- }
- ReleaseFocus();
- }
- void CKeyBoardDlg::OnKey3()
- {
- ReleaseFocus();
- char pChar;
- pChar = '3';
- SHORT ks = VkKeyScan(pChar);
- BYTE key = ks & 0xFF;
- keybd_event(key,0,0,0);
- keybd_event(key,0,KEYEVENTF_KEYUP,0);
- if(m_key_shif.GetCheck())//"shift"键是被按下
- {
- keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
- m_key_shif.SetCheck(FALSE);
- }
- ReleaseFocus();
- }
- void CKeyBoardDlg::OnKey4()
- {
- ReleaseFocus();
- char pChar;
- pChar = '4';
- SHORT ks = VkKeyScan(pChar);
- BYTE key = ks & 0xFF;
- keybd_event(key,0,0,0);
- keybd_event(key,0,KEYEVENTF_KEYUP,0);
- if(m_key_shif.GetCheck())//"shift"键是被按下
- {
- keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
- m_key_shif.SetCheck(FALSE);
- }
- ReleaseFocus();
- }
- void CKeyBoardDlg::OnKey5()
- {
- ReleaseFocus();
- char pChar;
- pChar = '5';
- SHORT ks = VkKeyScan(pChar);
- BYTE key = ks & 0xFF;
- keybd_event(key,0,0,0);
- keybd_event(key,0,KEYEVENTF_KEYUP,0);
- if(m_key_shif.GetCheck())//"shift"键是被按下
- {
- keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
- m_key_shif.SetCheck(FALSE);
- }
- ReleaseFocus();
- }
- void CKeyBoardDlg::OnKey6()
- {
- ReleaseFocus();
- char pChar;
- pChar = '6';
- SHORT ks = VkKeyScan(pChar);
- BYTE key = ks & 0xFF;
- keybd_event(key,0,0,0);
- keybd_event(key,0,KEYEVENTF_KEYUP,0);
- if(m_key_shif.GetCheck())//"shift"键是被按下
- {
- keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
- m_key_shif.SetCheck(FALSE);
- }
- ReleaseFocus();
- }
- void CKeyBoardDlg::OnKey7()
- {
- ReleaseFocus();
- char pChar;
- pChar = '7';
- SHORT ks = VkKeyScan(pChar);
- BYTE key = ks & 0xFF;
- keybd_event(key,0,0,0);
- keybd_event(key,0,KEYEVENTF_KEYUP,0);
- if(m_key_shif.GetCheck())//"shift"键是被按下
- {
- keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
- m_key_shif.SetCheck(FALSE);
- }
- ReleaseFocus();
- }
- void CKeyBoardDlg::OnKey8()
- {
- ReleaseFocus();
- char pChar;
- pChar = '8';
- SHORT ks = VkKeyScan(pChar);
- BYTE key = ks & 0xFF;
- keybd_event(key,0,0,0);
- keybd_event(key,0,KEYEVENTF_KEYUP,0);
- if(m_key_shif.GetCheck())//"shift"键是被按下
- {
- keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
- m_key_shif.SetCheck(FALSE);
- }
- ReleaseFocus();
- }
- void CKeyBoardDlg::OnKey9()
- {
- ReleaseFocus();
- char pChar;
- pChar = '9';
- SHORT ks = VkKeyScan(pChar);
- BYTE key = ks & 0xFF;
- keybd_event(key,0,0,0);
- keybd_event(key,0,KEYEVENTF_KEYUP,0);
- if(m_key_shif.GetCheck())//"shift"键是被按下
- {
- keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
- m_key_shif.SetCheck(FALSE);
- }
- ReleaseFocus();
- }
- void CKeyBoardDlg::OnKey0()
- {
- ReleaseFocus();
- char pChar;
- pChar = '0';
- SHORT ks = VkKeyScan(pChar);
- BYTE key = ks & 0xFF;
- keybd_event(key,0,0,0);
- keybd_event(key,0,KEYEVENTF_KEYUP,0);
- if(m_key_shif.GetCheck())//"shift"键是被按下
- {
- keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
- m_key_shif.SetCheck(FALSE);
- }
- ReleaseFocus();
- }
- void CKeyBoardDlg::OnKey10()
- {
- ReleaseFocus();
- char pChar;
- pChar = '-';
- SHORT ks = VkKeyScan(pChar);
- BYTE key = ks & 0xFF;
- keybd_event(key,0,0,0);
- keybd_event(key,0,KEYEVENTF_KEYUP,0);
- if(m_key_shif.GetCheck())//"shift"键是被按下
- {
- keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
- m_key_shif.SetCheck(FALSE);
- }
- ReleaseFocus();
- }
- void CKeyBoardDlg::OnKey11()
- {
- ReleaseFocus();
- char pChar;
- pChar = '=';
- SHORT ks = VkKeyScan(pChar);
- BYTE key = ks & 0xFF;
- keybd_event(key,0,0,0);
- keybd_event(key,0,KEYEVENTF_KEYUP,0);
- if(m_key_shif.GetCheck())//"shift"键是被按下
- {
- keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
- m_key_shif.SetCheck(FALSE);
- }
- ReleaseFocus();
- }
- void CKeyBoardDlg::OnKey12()
- {
- ReleaseFocus();
- char pChar;
- pChar = '\';
- SHORT ks = VkKeyScan(pChar);
- BYTE key = ks & 0xFF;
- keybd_event(key,0,0,0);
- keybd_event(key,0,KEYEVENTF_KEYUP,0);
- if(m_key_shif.GetCheck())//"shift"键是被按下
- {
- keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
- m_key_shif.SetCheck(FALSE);
- }
- ReleaseFocus();
- }
- void CKeyBoardDlg::OnKeyBspc()
- {
- ReleaseFocus();
- keybd_event(VK_BACK,0,0,0);
- keybd_event(VK_BACK,0,KEYEVENTF_KEYUP,0);
- ReleaseFocus();
- }
- void CKeyBoardDlg::OnKeyTab()
- {
- ReleaseFocus();
- keybd_event(VkKeyScan(0x09) & 0xFF,0,0,0);
- keybd_event(VkKeyScan(0x09) & 0xFF,0,KEYEVENTF_KEYUP,0);
- ReleaseFocus();
- }
- void CKeyBoardDlg::OnKeyQ()
- {
- ReleaseFocus();
- char pChar;
- pChar = 'q';
- SHORT ks = VkKeyScan(pChar);
- BYTE key = ks & 0xFF;
- keybd_event(key,0,0,0);
- keybd_event(key,0,KEYEVENTF_KEYUP,0);
- if(m_key_shif.GetCheck())//"shift"键是被按下
- {
- keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
- m_key_shif.SetCheck(FALSE);
- }
- if(m_key_ctrl.GetCheck())//"ctrl"键是被按下
- {
- keybd_event(VK_CONTROL,0,KEYEVENTF_KEYUP,0);
- m_key_ctrl.SetCheck(FALSE);
- }
- if(m_key_alt.GetCheck())//"alt"键是被按下
- {
- keybd_event(VK_MENU,0,KEYEVENTF_KEYUP,0);
- m_key_alt.SetCheck(FALSE);
- }
- ReleaseFocus();
- }
- void CKeyBoardDlg::OnKeyW()
- {
- ReleaseFocus();
- char pChar;
- pChar = 'w';
- SHORT ks = VkKeyScan(pChar);
- BYTE key = ks & 0xFF;
- keybd_event(key,0,0,0);
- keybd_event(key,0,KEYEVENTF_KEYUP,0);
- if(m_key_shif.GetCheck())//"shift"键是被按下
- {
- keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
- m_key_shif.SetCheck(FALSE);
- }
- if(m_key_ctrl.GetCheck())//"ctrl"键是被按下
- {
- keybd_event(VK_CONTROL,0,KEYEVENTF_KEYUP,0);
- m_key_ctrl.SetCheck(FALSE);
- }
- if(m_key_alt.GetCheck())//"alt"键是被按下
- {
- keybd_event(VK_MENU,0,KEYEVENTF_KEYUP,0);
- m_key_alt.SetCheck(FALSE);
- }
- ReleaseFocus();
- }
- void CKeyBoardDlg::OnKeyE()
- {
- ReleaseFocus();
- char pChar;
- pChar = 'e';
- SHORT ks = VkKeyScan(pChar);
- BYTE key = ks & 0xFF;
- keybd_event(key,0,0,0);
- keybd_event(key,0,KEYEVENTF_KEYUP,0);
- if(m_key_shif.GetCheck())//"shift"键是被按下
- {
- keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
- m_key_shif.SetCheck(FALSE);
- }
- if(m_key_ctrl.GetCheck())//"ctrl"键是被按下
- {
- keybd_event(VK_CONTROL,0,KEYEVENTF_KEYUP,0);
- m_key_ctrl.SetCheck(FALSE);
- }
- if(m_key_alt.GetCheck())//"alt"键是被按下
- {
- keybd_event(VK_MENU,0,KEYEVENTF_KEYUP,0);
- m_key_alt.SetCheck(FALSE);
- }
- ReleaseFocus();
- }
- void CKeyBoardDlg::OnKeyR()
- {
- ReleaseFocus();
- char pChar;
- pChar = 'r';
- SHORT ks = VkKeyScan(pChar);
- BYTE key = ks & 0xFF;
- keybd_event(key,0,0,0);
- keybd_event(key,0,KEYEVENTF_KEYUP,0);
- if(m_key_shif.GetCheck())//"shift"键是被按下
- {
- keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
- m_key_shif.SetCheck(FALSE);
- }
- if(m_key_ctrl.GetCheck())//"ctrl"键是被按下
- {
- keybd_event(VK_CONTROL,0,KEYEVENTF_KEYUP,0);
- m_key_ctrl.SetCheck(FALSE);
- }
- if(m_key_alt.GetCheck())//"alt"键是被按下
- {
- keybd_event(VK_MENU,0,KEYEVENTF_KEYUP,0);
- m_key_alt.SetCheck(FALSE);
- }
- ReleaseFocus();
- }
- void CKeyBoardDlg::OnKeyT()
- {
- ReleaseFocus();
- char pChar;
- pChar = 't';
- SHORT ks = VkKeyScan(pChar);
- BYTE key = ks & 0xFF;
- keybd_event(key,0,0,0);
- keybd_event(key,0,KEYEVENTF_KEYUP,0);
- if(m_key_shif.GetCheck())//"shift"键是被按下
- {
- keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
- m_key_shif.SetCheck(FALSE);
- }
- if(m_key_ctrl.GetCheck())//"ctrl"键是被按下
- {
- keybd_event(VK_CONTROL,0,KEYEVENTF_KEYUP,0);
- m_key_ctrl.SetCheck(FALSE);
- }
- if(m_key_alt.GetCheck())//"alt"键是被按下
- {
- keybd_event(VK_MENU,0,KEYEVENTF_KEYUP,0);
- m_key_alt.SetCheck(FALSE);
- }
- ReleaseFocus();
- }
- void CKeyBoardDlg::OnKeyY()
- {
- ReleaseFocus();
- char pChar;
- pChar = 'y';
- SHORT ks = VkKeyScan(pChar);
- BYTE key = ks & 0xFF;
- keybd_event(key,0,0,0);
- keybd_event(key,0,KEYEVENTF_KEYUP,0);
- if(m_key_shif.GetCheck())//"shift"键是被按下
- {
- keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
- m_key_shif.SetCheck(FALSE);
- }
- if(m_key_ctrl.GetCheck())//"ctrl"键是被按下
- {
- keybd_event(VK_CONTROL,0,KEYEVENTF_KEYUP,0);
- m_key_ctrl.SetCheck(FALSE);
- }
- if(m_key_alt.GetCheck())//"alt"键是被按下
- {
- keybd_event(VK_MENU,0,KEYEVENTF_KEYUP,0);
- m_key_alt.SetCheck(FALSE);
- }
- ReleaseFocus();
- }
- void CKeyBoardDlg::OnKeyU()
- {
- ReleaseFocus();
- char pChar;
- pChar = 'u';
- SHORT ks = VkKeyScan(pChar);
- BYTE key = ks & 0xFF;
- keybd_event(key,0,0,0);
- keybd_event(key,0,KEYEVENTF_KEYUP,0);
- if(m_key_shif.GetCheck())//"shift"键是被按下
- {
- keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
- m_key_shif.SetCheck(FALSE);
- }
- if(m_key_ctrl.GetCheck())//"ctrl"键是被按下
- {
- keybd_event(VK_CONTROL,0,KEYEVENTF_KEYUP,0);
- m_key_ctrl.SetCheck(FALSE);
- }
- if(m_key_alt.GetCheck())//"alt"键是被按下
- {
- keybd_event(VK_MENU,0,KEYEVENTF_KEYUP,0);
- m_key_alt.SetCheck(FALSE);
- }
- ReleaseFocus();
- }
- void CKeyBoardDlg::OnKeyI()
- {
- ReleaseFocus();
- char pChar;
- pChar = 'i';
- SHORT ks = VkKeyScan(pChar);
- BYTE key = ks & 0xFF;
- keybd_event(key,0,0,0);
- keybd_event(key,0,KEYEVENTF_KEYUP,0);
- if(m_key_shif.GetCheck())//"shift"键是被按下
- {
- keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
- m_key_shif.SetCheck(FALSE);
- }
- if(m_key_ctrl.GetCheck())//"ctrl"键是被按下
- {
- keybd_event(VK_CONTROL,0,KEYEVENTF_KEYUP,0);
- m_key_ctrl.SetCheck(FALSE);
- }
- if(m_key_alt.GetCheck())//"alt"键是被按下
- {
- keybd_event(VK_MENU,0,KEYEVENTF_KEYUP,0);
- m_key_alt.SetCheck(FALSE);
- }
- ReleaseFocus();
- }
- void CKeyBoardDlg::OnKeyO()
- {
- ReleaseFocus();
- char pChar;
- pChar = 'o';
- SHORT ks = VkKeyScan(pChar);
- BYTE key = ks & 0xFF;
- keybd_event(key,0,0,0);
- keybd_event(key,0,KEYEVENTF_KEYUP,0);
- if(m_key_shif.GetCheck())//"shift"键是被按下
- {
- keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
- m_key_shif.SetCheck(FALSE);
- }
- if(m_key_ctrl.GetCheck())//"ctrl"键是被按下
- {
- keybd_event(VK_CONTROL,0,KEYEVENTF_KEYUP,0);
- m_key_ctrl.SetCheck(FALSE);
- }
- if(m_key_alt.GetCheck())//"alt"键是被按下
- {
- keybd_event(VK_MENU,0,KEYEVENTF_KEYUP,0);
- m_key_alt.SetCheck(FALSE);
- }
- ReleaseFocus();
- }
- void CKeyBoardDlg::OnKeyP()
- {
- ReleaseFocus();
- char pChar;
- pChar = 'p';
- SHORT ks = VkKeyScan(pChar);
- BYTE key = ks & 0xFF;
- keybd_event(key,0,0,0);
- keybd_event(key,0,KEYEVENTF_KEYUP,0);
- if(m_key_shif.GetCheck())//"shift"键是被按下
- {
- keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
- m_key_shif.SetCheck(FALSE);
- }
- if(m_key_ctrl.GetCheck())//"ctrl"键是被按下
- {
- keybd_event(VK_CONTROL,0,KEYEVENTF_KEYUP,0);
- m_key_ctrl.SetCheck(FALSE);
- }
- if(m_key_alt.GetCheck())//"alt"键是被按下
- {
- keybd_event(VK_MENU,0,KEYEVENTF_KEYUP,0);
- m_key_alt.SetCheck(FALSE);
- }
- ReleaseFocus();
- }
- void CKeyBoardDlg::OnKeyP1()
- {
- ReleaseFocus();
- char pChar;
- pChar = '[';
- SHORT ks = VkKeyScan(pChar);
- BYTE key = ks & 0xFF;
- keybd_event(key,0,0,0);
- keybd_event(key,0,KEYEVENTF_KEYUP,0);
- if(m_key_shif.GetCheck())//"shift"键是被按下
- {
- keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
- m_key_shif.SetCheck(FALSE);
- }
- ReleaseFocus();
- }
- void CKeyBoardDlg::OnKeyP2()
- {
- ReleaseFocus();
- char pChar;
- pChar = ']';
- SHORT ks = VkKeyScan(pChar);
- BYTE key = ks & 0xFF;
- keybd_event(key,0,0,0);
- keybd_event(key,0,KEYEVENTF_KEYUP,0);
- if(m_key_shif.GetCheck())//"shift"键是被按下
- {
- keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
- m_key_shif.SetCheck(FALSE);
- }
- ReleaseFocus();
- }
- void CKeyBoardDlg::OnKeyCaps()
- {
- ReleaseFocus();
- keybd_event(VK_CAPITAL,0,0,0);
- keybd_event(VK_CAPITAL,0,KEYEVENTF_KEYUP,0);
- ReleaseFocus();
- }
- void CKeyBoardDlg::OnKeyA()
- {
- ReleaseFocus();
- char pChar;
- pChar = 'a';
- SHORT ks = VkKeyScan(pChar);
- BYTE key = ks & 0xFF;
- keybd_event(key,0,0,0);
- keybd_event(key,0,KEYEVENTF_KEYUP,0);
- if(m_key_shif.GetCheck())//"shift"键是被按下
- {
- keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
- m_key_shif.SetCheck(FALSE);
- }
- if(m_key_ctrl.GetCheck())//"ctrl"键是被按下
- {
- keybd_event(VK_CONTROL,0,KEYEVENTF_KEYUP,0);
- m_key_ctrl.SetCheck(FALSE);
- }
- if(m_key_alt.GetCheck())//"alt"键是被按下
- {
- keybd_event(VK_MENU,0,KEYEVENTF_KEYUP,0);
- m_key_alt.SetCheck(FALSE);
- }
- ReleaseFocus();
- }
- void CKeyBoardDlg::OnKeyS()
- {
- ReleaseFocus();
- char pChar;
- pChar = 's';
- SHORT ks = VkKeyScan(pChar);
- BYTE key = ks & 0xFF;
- keybd_event(key,0,0,0);
- keybd_event(key,0,KEYEVENTF_KEYUP,0);
- if(m_key_shif.GetCheck())//"shift"键是被按下
- {
- keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
- m_key_shif.SetCheck(FALSE);
- }
- if(m_key_ctrl.GetCheck())//"ctrl"键是被按下
- {
- keybd_event(VK_CONTROL,0,KEYEVENTF_KEYUP,0);
- m_key_ctrl.SetCheck(FALSE);
- }
- if(m_key_alt.GetCheck())//"alt"键是被按下
- {
- keybd_event(VK_MENU,0,KEYEVENTF_KEYUP,0);
- m_key_alt.SetCheck(FALSE);
- }
- ReleaseFocus();
- }
- void CKeyBoardDlg::OnKeyD()
- {
- ReleaseFocus();
- char pChar;
- pChar = 'd';
- SHORT ks = VkKeyScan(pChar);
- BYTE key = ks & 0xFF;
- keybd_event(key,0,0,0);
- keybd_event(key,0,KEYEVENTF_KEYUP,0);
- if(m_key_shif.GetCheck())//"shift"键是被按下
- {
- keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
- m_key_shif.SetCheck(FALSE);
- }
- if(m_key_ctrl.GetCheck())//"ctrl"键是被按下
- {
- keybd_event(VK_CONTROL,0,KEYEVENTF_KEYUP,0);
- m_key_ctrl.SetCheck(FALSE);
- }
- if(m_key_alt.GetCheck())//"alt"键是被按下
- {
- keybd_event(VK_MENU,0,KEYEVENTF_KEYUP,0);
- m_key_alt.SetCheck(FALSE);
- }
- ReleaseFocus();
- }
- void CKeyBoardDlg::OnKeyF()
- {
- ReleaseFocus();
- char pChar;
- pChar = 'f';
- SHORT ks = VkKeyScan(pChar);
- BYTE key = ks & 0xFF;
- keybd_event(key,0,0,0);
- keybd_event(key,0,KEYEVENTF_KEYUP,0);
- if(m_key_shif.GetCheck())//"shift"键是被按下
- {
- keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
- m_key_shif.SetCheck(FALSE);
- }
- if(m_key_ctrl.GetCheck())//"ctrl"键是被按下
- {
- keybd_event(VK_CONTROL,0,KEYEVENTF_KEYUP,0);
- m_key_ctrl.SetCheck(FALSE);
- }
- if(m_key_alt.GetCheck())//"alt"键是被按下
- {
- keybd_event(VK_MENU,0,KEYEVENTF_KEYUP,0);
- m_key_alt.SetCheck(FALSE);
- }
- ReleaseFocus();
- }
- void CKeyBoardDlg::OnKeyG()
- {
- ReleaseFocus();
- char pChar;
- pChar = 'g';
- SHORT ks = VkKeyScan(pChar);
- BYTE key = ks & 0xFF;
- keybd_event(key,0,0,0);
- keybd_event(key,0,KEYEVENTF_KEYUP,0);
- if(m_key_shif.GetCheck())//"shift"键是被按下
- {
- keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
- m_key_shif.SetCheck(FALSE);
- }
- if(m_key_ctrl.GetCheck())//"ctrl"键是被按下
- {
- keybd_event(VK_CONTROL,0,KEYEVENTF_KEYUP,0);
- m_key_ctrl.SetCheck(FALSE);
- }
- if(m_key_alt.GetCheck())//"alt"键是被按下
- {
- keybd_event(VK_MENU,0,KEYEVENTF_KEYUP,0);
- m_key_alt.SetCheck(FALSE);
- }
- ReleaseFocus();
- }
- void CKeyBoardDlg::OnKeyH()
- {
- ReleaseFocus();
- char pChar;
- pChar = 'h';
- SHORT ks = VkKeyScan(pChar);
- BYTE key = ks & 0xFF;
- keybd_event(key,0,0,0);
- keybd_event(key,0,KEYEVENTF_KEYUP,0);
- if(m_key_shif.GetCheck())//"shift"键是被按下
- {
- keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
- m_key_shif.SetCheck(FALSE);
- }
- if(m_key_ctrl.GetCheck())//"ctrl"键是被按下
- {
- keybd_event(VK_CONTROL,0,KEYEVENTF_KEYUP,0);
- m_key_ctrl.SetCheck(FALSE);
- }
- if(m_key_alt.GetCheck())//"alt"键是被按下
- {
- keybd_event(VK_MENU,0,KEYEVENTF_KEYUP,0);
- m_key_alt.SetCheck(FALSE);
- }
- ReleaseFocus();
- }
- void CKeyBoardDlg::OnKeyJ()
- {
- ReleaseFocus();
- char pChar;
- pChar = 'j';
- SHORT ks = VkKeyScan(pChar);
- BYTE key = ks & 0xFF;
- keybd_event(key,0,0,0);
- keybd_event(key,0,KEYEVENTF_KEYUP,0);
- if(m_key_shif.GetCheck())//"shift"键是被按下
- {
- keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
- m_key_shif.SetCheck(FALSE);
- }
- if(m_key_ctrl.GetCheck())//"ctrl"键是被按下
- {
- keybd_event(VK_CONTROL,0,KEYEVENTF_KEYUP,0);
- m_key_ctrl.SetCheck(FALSE);
- }
- if(m_key_alt.GetCheck())//"alt"键是被按下
- {
- keybd_event(VK_MENU,0,KEYEVENTF_KEYUP,0);
- m_key_alt.SetCheck(FALSE);
- }
- ReleaseFocus();
- }
- void CKeyBoardDlg::OnKeyK()
- {
- ReleaseFocus();
- char pChar;
- pChar = 'k';
- SHORT ks = VkKeyScan(pChar);
- BYTE key = ks & 0xFF;
- keybd_event(key,0,0,0);
- keybd_event(key,0,KEYEVENTF_KEYUP,0);
- if(m_key_shif.GetCheck())//"shift"键是被按下
- {
- keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
- m_key_shif.SetCheck(FALSE);
- }
- if(m_key_ctrl.GetCheck())//"ctrl"键是被按下
- {
- keybd_event(VK_CONTROL,0,KEYEVENTF_KEYUP,0);
- m_key_ctrl.SetCheck(FALSE);
- }
- if(m_key_alt.GetCheck())//"alt"键是被按下
- {
- keybd_event(VK_MENU,0,KEYEVENTF_KEYUP,0);
- m_key_alt.SetCheck(FALSE);
- }
- ReleaseFocus();
- }
- void CKeyBoardDlg::OnKeyL()
- {
- ReleaseFocus();
- char pChar;
- pChar = 'l';
- SHORT ks = VkKeyScan(pChar);
- BYTE key = ks & 0xFF;
- keybd_event(key,0,0,0);
- keybd_event(key,0,KEYEVENTF_KEYUP,0);
- if(m_key_shif.GetCheck())//"shift"键是被按下
- {
- keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
- m_key_shif.SetCheck(FALSE);
- }
- if(m_key_ctrl.GetCheck())//"ctrl"键是被按下
- {
- keybd_event(VK_CONTROL,0,KEYEVENTF_KEYUP,0);
- m_key_ctrl.SetCheck(FALSE);
- }
- if(m_key_alt.GetCheck())//"alt"键是被按下
- {
- keybd_event(VK_MENU,0,KEYEVENTF_KEYUP,0);
- m_key_alt.SetCheck(FALSE);
- }
- ReleaseFocus();
- }
- void CKeyBoardDlg::OnKeyL1()
- {
- ReleaseFocus();
- char pChar;
- pChar = ';';
- SHORT ks = VkKeyScan(pChar);
- BYTE key = ks & 0xFF;
- keybd_event(key,0,0,0);
- keybd_event(key,0,KEYEVENTF_KEYUP,0);
- if(m_key_shif.GetCheck())//"shift"键是被按下
- {
- keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
- m_key_shif.SetCheck(FALSE);
- }
- ReleaseFocus();
- }
- void CKeyBoardDlg::OnKeyL2()
- {
- ReleaseFocus();
- char pChar;
- pChar = ''';
- SHORT ks = VkKeyScan(pChar);
- BYTE key = ks & 0xFF;
- keybd_event(key,0,0,0);
- keybd_event(key,0,KEYEVENTF_KEYUP,0);
- if(m_key_shif.GetCheck())//"shift"键是被按下
- {
- keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
- m_key_shif.SetCheck(FALSE);
- }
- ReleaseFocus();
- }
- void CKeyBoardDlg::OnKeyZ()
- {
- ReleaseFocus();
- char pChar;
- pChar = 'z';
- SHORT ks = VkKeyScan(pChar);
- BYTE key = ks & 0xFF;
- keybd_event(key,0,0,0);
- keybd_event(key,0,KEYEVENTF_KEYUP,0);
- if(m_key_shif.GetCheck())//"shift"键是被按下
- {
- keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
- m_key_shif.SetCheck(FALSE);
- }
- if(m_key_ctrl.GetCheck())//"ctrl"键是被按下
- {
- keybd_event(VK_CONTROL,0,KEYEVENTF_KEYUP,0);
- m_key_ctrl.SetCheck(FALSE);
- }
- if(m_key_alt.GetCheck())//"alt"键是被按下
- {
- keybd_event(VK_MENU,0,KEYEVENTF_KEYUP,0);
- m_key_alt.SetCheck(FALSE);
- }
- ReleaseFocus();
- }
- void CKeyBoardDlg::OnKeyX()
- {
- ReleaseFocus();
- char pChar;
- pChar = 'x';
- SHORT ks = VkKeyScan(pChar);
- BYTE key = ks & 0xFF;
- keybd_event(key,0,0,0);
- keybd_event(key,0,KEYEVENTF_KEYUP,0);
- if(m_key_shif.GetCheck())//"shift"键是被按下
- {
- keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
- m_key_shif.SetCheck(FALSE);
- }
- if(m_key_ctrl.GetCheck())//"ctrl"键是被按下
- {
- keybd_event(VK_CONTROL,0,KEYEVENTF_KEYUP,0);
- m_key_ctrl.SetCheck(FALSE);
- }
- if(m_key_alt.GetCheck())//"alt"键是被按下
- {
- keybd_event(VK_MENU,0,KEYEVENTF_KEYUP,0);
- m_key_alt.SetCheck(FALSE);
- }
- ReleaseFocus();
- }
- void CKeyBoardDlg::OnKeyC()
- {
- ReleaseFocus();
- char pChar;
- pChar = 'c';
- SHORT ks = VkKeyScan(pChar);
- BYTE key = ks & 0xFF;
- keybd_event(key,0,0,0);
- keybd_event(key,0,KEYEVENTF_KEYUP,0);
- if(m_key_shif.GetCheck())//"shift"键是被按下
- {
- keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
- m_key_shif.SetCheck(FALSE);
- }
- if(m_key_ctrl.GetCheck())//"ctrl"键是被按下
- {
- keybd_event(VK_CONTROL,0,KEYEVENTF_KEYUP,0);
- m_key_ctrl.SetCheck(FALSE);
- }
- if(m_key_alt.GetCheck())//"alt"键是被按下
- {
- keybd_event(VK_MENU,0,KEYEVENTF_KEYUP,0);
- m_key_alt.SetCheck(FALSE);
- }
- ReleaseFocus();
- }
- void CKeyBoardDlg::OnKeyV()
- {
- ReleaseFocus();
- char pChar;
- pChar = 'v';
- SHORT ks = VkKeyScan(pChar);
- BYTE key = ks & 0xFF;
- keybd_event(key,0,0,0);
- keybd_event(key,0,KEYEVENTF_KEYUP,0);
- if(m_key_shif.GetCheck())//"shift"键是被按下
- {
- keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
- m_key_shif.SetCheck(FALSE);
- }
- if(m_key_ctrl.GetCheck())//"ctrl"键是被按下
- {
- keybd_event(VK_CONTROL,0,KEYEVENTF_KEYUP,0);
- m_key_ctrl.SetCheck(FALSE);
- }
- if(m_key_alt.GetCheck())//"alt"键是被按下
- {
- keybd_event(VK_MENU,0,KEYEVENTF_KEYUP,0);
- m_key_alt.SetCheck(FALSE);
- }
- ReleaseFocus();
- }
- void CKeyBoardDlg::OnKeyB()
- {
- ReleaseFocus();
- char pChar;
- pChar = 'b';
- SHORT ks = VkKeyScan(pChar);
- BYTE key = ks & 0xFF;
- keybd_event(key,0,0,0);
- keybd_event(key,0,KEYEVENTF_KEYUP,0);
- if(m_key_shif.GetCheck())//"shift"键是被按下
- {
- keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
- m_key_shif.SetCheck(FALSE);
- }
- if(m_key_ctrl.GetCheck())//"ctrl"键是被按下
- {
- keybd_event(VK_CONTROL,0,KEYEVENTF_KEYUP,0);
- m_key_ctrl.SetCheck(FALSE);
- }
- if(m_key_alt.GetCheck())//"alt"键是被按下
- {
- keybd_event(VK_MENU,0,KEYEVENTF_KEYUP,0);
- m_key_alt.SetCheck(FALSE);
- }
- ReleaseFocus();
- }
- void CKeyBoardDlg::OnKeyN()
- {
- ReleaseFocus();
- char pChar;
- pChar = 'n';
- SHORT ks = VkKeyScan(pChar);
- BYTE key = ks & 0xFF;
- keybd_event(key,0,0,0);
- keybd_event(key,0,KEYEVENTF_KEYUP,0);
- if(m_key_shif.GetCheck())//"shift"键是被按下
- {
- keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
- m_key_shif.SetCheck(FALSE);
- }
- if(m_key_ctrl.GetCheck())//"ctrl"键是被按下
- {
- keybd_event(VK_CONTROL,0,KEYEVENTF_KEYUP,0);
- m_key_ctrl.SetCheck(FALSE);
- }
- if(m_key_alt.GetCheck())//"alt"键是被按下
- {
- keybd_event(VK_MENU,0,KEYEVENTF_KEYUP,0);
- m_key_alt.SetCheck(FALSE);
- }
- ReleaseFocus();
- }
- void CKeyBoardDlg::OnKeyM()
- {
- ReleaseFocus();
- char pChar;
- pChar = 'm';
- SHORT ks = VkKeyScan(pChar);
- BYTE key = ks & 0xFF;
- keybd_event(key,0,0,0);
- keybd_event(key,0,KEYEVENTF_KEYUP,0);
- if(m_key_shif.GetCheck())//"shift"键是被按下
- {
- keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
- m_key_shif.SetCheck(FALSE);
- }
- if(m_key_ctrl.GetCheck())//"ctrl"键是被按下
- {
- keybd_event(VK_CONTROL,0,KEYEVENTF_KEYUP,0);
- m_key_ctrl.SetCheck(FALSE);
- }
- if(m_key_alt.GetCheck())//"alt"键是被按下
- {
- keybd_event(VK_MENU,0,KEYEVENTF_KEYUP,0);
- m_key_alt.SetCheck(FALSE);
- }
- ReleaseFocus();
- }
- void CKeyBoardDlg::OnKeyM1()
- {
- ReleaseFocus();
- char pChar;
- pChar = ',';
- SHORT ks = VkKeyScan(pChar);
- BYTE key = ks & 0xFF;
- keybd_event(key,0,0,0);
- keybd_event(key,0,KEYEVENTF_KEYUP,0);
- if(m_key_shif.GetCheck())//"shift"键是被按下
- {
- keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
- m_key_shif.SetCheck(FALSE);
- }
- ReleaseFocus();
- }
- void CKeyBoardDlg::OnKeyM2()
- {
- ReleaseFocus();
- char pChar;
- pChar = '.';
- SHORT ks = VkKeyScan(pChar);
- BYTE key = ks & 0xFF;
- keybd_event(key,0,0,0);
- keybd_event(key,0,KEYEVENTF_KEYUP,0);
- if(m_key_shif.GetCheck())//"shift"键是被按下
- {
- keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
- m_key_shif.SetCheck(FALSE);
- }
- ReleaseFocus();
- }
- void CKeyBoardDlg::OnKeyM3()
- {
- ReleaseFocus();
- char pChar;
- pChar = '/';
- SHORT ks = VkKeyScan(pChar);
- BYTE key = ks & 0xFF;
- keybd_event(key,0,0,0);
- keybd_event(key,0,KEYEVENTF_KEYUP,0);
- if(m_key_shif.GetCheck())//"shift"键是被按下
- {
- keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
- m_key_shif.SetCheck(FALSE);
- }
- ReleaseFocus();
- }
- void CKeyBoardDlg::OnKeyWnd()
- {
- ReleaseFocus();
- keybd_event(VK_LWIN,0,0,0);
- keybd_event(VK_LWIN,0,KEYEVENTF_KEYUP,0);
- ReleaseFocus();
- }
- void CKeyBoardDlg::OnKeyMenu()
- {
- ReleaseFocus();
- keybd_event(VK_APPS,0,0,0);
- keybd_event(VK_APPS,0,KEYEVENTF_KEYUP,0);
- ReleaseFocus();
- }
- void CKeyBoardDlg::OnKeyTop()
- {
- ReleaseFocus();
- keybd_event(VK_UP,0,0,0);
- keybd_event(VK_UP,0,KEYEVENTF_KEYUP,0);
- ReleaseFocus();
- }
- void CKeyBoardDlg::OnKeyBotton()
- {
- ReleaseFocus();
- keybd_event(VK_DOWN,0,0,0);
- keybd_event(VK_DOWN,0,KEYEVENTF_KEYUP,0);
- ReleaseFocus();
- }
- void CKeyBoardDlg::OnKeyLeft()
- {
- ReleaseFocus();
- keybd_event(VK_LEFT,0,0,0);
- keybd_event(VK_LEFT,0,KEYEVENTF_KEYUP,0);
- ReleaseFocus();
- }
- void CKeyBoardDlg::OnKeyRight()
- {
- ReleaseFocus();
- keybd_event(VK_RIGHT,0,0,0);
- keybd_event(VK_RIGHT,0,KEYEVENTF_KEYUP,0);
- ReleaseFocus();
- }
- void CKeyBoardDlg::OnKeySpace()
- {
- ReleaseFocus();
- keybd_event(VK_SPACE,0,0,0);
- keybd_event(VK_SPACE,0,KEYEVENTF_KEYUP,0);
- ReleaseFocus();
- }
- void CKeyBoardDlg::OnKeyEnter()
- {
- ReleaseFocus();
- keybd_event(VkKeyScan(0x0D) & 0xFF,0,0,0);
- keybd_event(VkKeyScan(0x0D) & 0xFF,0,KEYEVENTF_KEYUP,0);
- ReleaseFocus();
- }
- void CKeyBoardDlg::OnKeyPs()
- {
- ReleaseFocus();
- keybd_event(VK_SNAPSHOT,0,0,0);
- keybd_event(VK_SNAPSHOT,0,KEYEVENTF_KEYUP,0);
- ReleaseFocus();
- }
- void CKeyBoardDlg::OnKeyShif()
- {
- ReleaseFocus();
- if (m_key_shif.GetCheck())
- {
- keybd_event(VK_SHIFT,0,0,0);
- }
- else
- {
- keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
- }
- ReleaseFocus();
- }
- void CKeyBoardDlg::OnKeyCtrl()
- {
- ReleaseFocus();
- if (m_key_ctrl.GetCheck())
- {
- keybd_event(VK_CONTROL,0,0,0);
- }
- else
- {
- keybd_event(VK_CONTROL,0,KEYEVENTF_KEYUP,0);
- }
- ReleaseFocus();
- }
- void CKeyBoardDlg::OnKeyAlt()
- {
- ReleaseFocus();
- if (m_key_alt.GetCheck())
- {
- keybd_event(VK_MENU,0,0,0);
- }
- else
- {
- keybd_event(VK_MENU,0,KEYEVENTF_KEYUP,0);
- }
- ReleaseFocus();
- }