KeyBoardDlg.cpp
上传用户:weimin735
上传日期:2008-06-11
资源大小:527k
文件大小:59k
源码类别:

输入法编程

开发平台:

Visual C++

  1. // KeyBoardDlg.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "KeyBoard.h"
  5. #include "KeyBoardDlg.h"
  6. #include "resource.h"
  7. #ifdef _DEBUG
  8. #define new DEBUG_NEW
  9. #undef THIS_FILE
  10. static char THIS_FILE[] = __FILE__;
  11. #endif
  12. /////////////////////////////////////////////////////////////////////////////
  13. // CAboutDlg dialog used for App About
  14. class CAboutDlg : public CDialog
  15. {
  16. public:
  17. CAboutDlg();
  18. // Dialog Data
  19. //{{AFX_DATA(CAboutDlg)
  20. enum { IDD = IDD_ABOUTBOX };
  21. //}}AFX_DATA
  22. // ClassWizard generated virtual function overrides
  23. //{{AFX_VIRTUAL(CAboutDlg)
  24. protected:
  25. virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  26. //}}AFX_VIRTUAL
  27. // Implementation
  28. protected:
  29. CRgn m_rgn;
  30. CBrush m_brush;
  31. //{{AFX_MSG(CAboutDlg)
  32. afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
  33. virtual BOOL OnInitDialog();
  34. afx_msg BOOL OnEraseBkgnd(CDC* pDC);
  35. //}}AFX_MSG
  36. DECLARE_MESSAGE_MAP()
  37. };
  38. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  39. {
  40. //{{AFX_DATA_INIT(CAboutDlg)
  41. //}}AFX_DATA_INIT
  42. }
  43. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  44. {
  45. CDialog::DoDataExchange(pDX);
  46. //{{AFX_DATA_MAP(CAboutDlg)
  47. //}}AFX_DATA_MAP
  48. }
  49. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  50. //{{AFX_MSG_MAP(CAboutDlg)
  51. ON_WM_LBUTTONDOWN()
  52. ON_WM_ERASEBKGND()//重绘窗口
  53. //}}AFX_MSG_MAP
  54. END_MESSAGE_MAP()
  55. /////////////////////////////////////////////////////////////////////////////
  56. // CKeyBoardDlg dialog
  57. CKeyBoardDlg::CKeyBoardDlg(CWnd* pParent /*=NULL*/)
  58. : CDialog(CKeyBoardDlg::IDD, pParent)
  59. {
  60. //{{AFX_DATA_INIT(CKeyBoardDlg)
  61. // NOTE: the ClassWizard will add member initialization here
  62. //}}AFX_DATA_INIT
  63. // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
  64. m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
  65. m_bCaps = 0;
  66. }
  67. void CKeyBoardDlg::DoDataExchange(CDataExchange* pDX)
  68. {
  69. CDialog::DoDataExchange(pDX);
  70. //{{AFX_DATA_MAP(CKeyBoardDlg)
  71. DDX_Control(pDX, IDC_ESC, m_key_esc);
  72. DDX_Control(pDX, IDC_F1, m_key_f1);
  73. DDX_Control(pDX, IDC_F2, m_key_f2);
  74. DDX_Control(pDX, IDC_F3, m_key_f3);
  75. DDX_Control(pDX, IDC_F4, m_key_f4);
  76. DDX_Control(pDX, IDC_F5, m_key_f5);
  77. DDX_Control(pDX, IDC_F6, m_key_f6);
  78. DDX_Control(pDX, IDC_F7, m_key_f7);
  79. DDX_Control(pDX, IDC_F8, m_key_f8);
  80. DDX_Control(pDX, IDC_F9, m_key_f9);
  81. DDX_Control(pDX, IDC_F10, m_key_f10);
  82. DDX_Control(pDX, IDC_F11, m_key_f11);
  83. DDX_Control(pDX, IDC_F12, m_key_f12);
  84. DDX_Control(pDX, IDC_PAUSE, m_key_pause);
  85. DDX_Control(pDX, IDC_INS, m_key_ins);
  86. DDX_Control(pDX, IDC_DEL, m_key_del);
  87. DDX_Control(pDX, IDC_PGUP, m_key_pgup);
  88. DDX_Control(pDX, IDC_PGDN, m_key_pgdn);
  89. DDX_Control(pDX, IDC_HOME, m_key_home);
  90. DDX_Control(pDX, IDC_END, m_key_end);
  91. DDX_Control(pDX, IDC_ONCE, m_key_once);
  92. DDX_Control(pDX, IDC_1, m_key_1);
  93. DDX_Control(pDX, IDC_2, m_key_2);
  94. DDX_Control(pDX, IDC_3, m_key_3);
  95. DDX_Control(pDX, IDC_4, m_key_4);
  96. DDX_Control(pDX, IDC_5, m_key_5);
  97. DDX_Control(pDX, IDC_6, m_key_6);
  98. DDX_Control(pDX, IDC_7, m_key_7);
  99. DDX_Control(pDX, IDC_8, m_key_8);
  100. DDX_Control(pDX, IDC_9, m_key_9);
  101. DDX_Control(pDX, IDC_0, m_key_0);
  102. DDX_Control(pDX, IDC_10, m_key_10);
  103. DDX_Control(pDX, IDC_11, m_key_11);
  104. DDX_Control(pDX, IDC_12, m_key_12);
  105. DDX_Control(pDX, IDC_BSPC, m_key_bspc);
  106. DDX_Control(pDX, IDC_TAB, m_key_tab);
  107. DDX_Control(pDX, IDC_Q, m_key_q);
  108. DDX_Control(pDX, IDC_W, m_key_w);
  109. DDX_Control(pDX, IDC_E, m_key_e);
  110. DDX_Control(pDX, IDC_R, m_key_r);
  111. DDX_Control(pDX, IDC_T, m_key_t);
  112. DDX_Control(pDX, IDC_Y, m_key_y);
  113. DDX_Control(pDX, IDC_U, m_key_u);
  114. DDX_Control(pDX, IDC_I, m_key_i);
  115. DDX_Control(pDX, IDC_O, m_key_o);
  116. DDX_Control(pDX, IDC_P, m_key_p);
  117. DDX_Control(pDX, IDC_P1, m_key_p1);
  118. DDX_Control(pDX, IDC_P2, m_key_p2);
  119. DDX_Control(pDX, IDC_CAPS, m_key_caps);
  120. DDX_Control(pDX, IDC_A, m_key_a);
  121. DDX_Control(pDX, IDC_S, m_key_s);
  122. DDX_Control(pDX, IDC_D, m_key_d);
  123. DDX_Control(pDX, IDC_F, m_key_f);
  124. DDX_Control(pDX, IDC_G, m_key_g);
  125. DDX_Control(pDX, IDC_H, m_key_h);
  126. DDX_Control(pDX, IDC_J, m_key_j);
  127. DDX_Control(pDX, IDC_K, m_key_k);
  128. DDX_Control(pDX, IDC_L, m_key_l);
  129. DDX_Control(pDX, IDC_L1, m_key_l1);
  130. DDX_Control(pDX, IDC_L2, m_key_l2);
  131. DDX_Control(pDX, IDC_SHIF, m_key_shif);
  132. DDX_Control(pDX, IDC_Z, m_key_z);
  133. DDX_Control(pDX, IDC_X, m_key_x);
  134. DDX_Control(pDX, IDC_C, m_key_c);
  135. DDX_Control(pDX, IDC_V, m_key_v);
  136. DDX_Control(pDX, IDC_B, m_key_b);
  137. DDX_Control(pDX, IDC_N, m_key_n);
  138. DDX_Control(pDX, IDC_M, m_key_m);
  139. DDX_Control(pDX, IDC_M1, m_key_m1);
  140. DDX_Control(pDX, IDC_M2, m_key_m2);
  141. DDX_Control(pDX, IDC_M3, m_key_m3);
  142. DDX_Control(pDX, IDC_CTRL, m_key_ctrl);
  143. DDX_Control(pDX, IDC_WND, m_key_wnd);
  144. DDX_Control(pDX, IDC_ALT, m_key_alt);
  145. DDX_Control(pDX, IDC_MENU, m_key_menu);
  146. DDX_Control(pDX, IDC_TOP, m_key_top);
  147. DDX_Control(pDX, IDC_BOTTOM, m_key_bottom);
  148. DDX_Control(pDX, IDC_LEFT, m_key_left);
  149. DDX_Control(pDX, IDC_RIGHT, m_key_right);
  150. DDX_Control(pDX, IDC_SPACE, m_key_space);
  151. DDX_Control(pDX, IDC_ENTER, m_key_enter);
  152. DDX_Control(pDX, IDC_PS, m_key_ps);
  153. DDX_Control(pDX, IDC_EXIT, m_key_exit);
  154. //}}AFX_DATA_MAP
  155. }
  156. BEGIN_MESSAGE_MAP(CKeyBoardDlg, CDialog)
  157. ON_WM_CONTEXTMENU()
  158. //{{AFX_MSG_MAP(CKeyBoardDlg)
  159. ON_WM_SYSCOMMAND()
  160. ON_WM_PAINT()
  161. ON_WM_QUERYDRAGICON()
  162. ON_WM_NCHITTEST()//点窗体任何部位移动窗体
  163. ON_WM_ERASEBKGND()//重绘窗口
  164. ON_WM_CREATE()
  165. //}}AFX_MSG_MAP
  166.   ON_BN_CLICKED(IDC_ESC, OnKeyEsc)
  167. ON_BN_CLICKED(IDC_F1, OnKeyF1)
  168. ON_BN_CLICKED(IDC_F2, OnKeyF2)
  169. ON_BN_CLICKED(IDC_F3, OnKeyF3)
  170. ON_BN_CLICKED(IDC_F4, OnKeyF4)
  171. ON_BN_CLICKED(IDC_F5, OnKeyF5)
  172. ON_BN_CLICKED(IDC_F6, OnKeyF6)
  173. ON_BN_CLICKED(IDC_F7, OnKeyF7)
  174. ON_BN_CLICKED(IDC_F8, OnKeyF8)
  175. ON_BN_CLICKED(IDC_F9, OnKeyF9)
  176. ON_BN_CLICKED(IDC_F10, OnKeyF10)
  177. ON_BN_CLICKED(IDC_F11, OnKeyF11)
  178. ON_BN_CLICKED(IDC_F12, OnKeyF12)
  179. ON_BN_CLICKED(IDC_PAUSE, OnKeyPause)
  180. ON_BN_CLICKED(IDC_INS, OnKeyIns)
  181. ON_BN_CLICKED(IDC_DEL, OnKeyDel)
  182. ON_BN_CLICKED(IDC_PGUP, OnKeyPgup)
  183. ON_BN_CLICKED(IDC_PGDN, OnKeyPgdn)
  184. ON_BN_CLICKED(IDC_HOME, OnKeyHome)
  185. ON_BN_CLICKED(IDC_END, OnKeyEnd)
  186. ON_BN_CLICKED(IDC_ONCE, OnKeyOnce)
  187. ON_BN_CLICKED(IDC_1, OnKey1)
  188. ON_BN_CLICKED(IDC_2, OnKey2)
  189. ON_BN_CLICKED(IDC_3, OnKey3)
  190. ON_BN_CLICKED(IDC_4, OnKey4)
  191. ON_BN_CLICKED(IDC_5, OnKey5)
  192. ON_BN_CLICKED(IDC_6, OnKey6)
  193. ON_BN_CLICKED(IDC_7, OnKey7)
  194. ON_BN_CLICKED(IDC_8, OnKey8)
  195. ON_BN_CLICKED(IDC_9, OnKey9)
  196. ON_BN_CLICKED(IDC_0, OnKey0)
  197. ON_BN_CLICKED(IDC_10, OnKey10)
  198. ON_BN_CLICKED(IDC_11, OnKey11)
  199. ON_BN_CLICKED(IDC_12, OnKey12)
  200. ON_BN_CLICKED(IDC_BSPC, OnKeyBspc)
  201. ON_BN_CLICKED(IDC_TAB, OnKeyTab)
  202. ON_BN_CLICKED(IDC_Q, OnKeyQ)
  203. ON_BN_CLICKED(IDC_W, OnKeyW)
  204. ON_BN_CLICKED(IDC_E, OnKeyE)
  205. ON_BN_CLICKED(IDC_R, OnKeyR)
  206. ON_BN_CLICKED(IDC_T, OnKeyT)
  207. ON_BN_CLICKED(IDC_Y, OnKeyY)
  208. ON_BN_CLICKED(IDC_U, OnKeyU)
  209. ON_BN_CLICKED(IDC_I, OnKeyI)
  210. ON_BN_CLICKED(IDC_O, OnKeyO)
  211. ON_BN_CLICKED(IDC_P, OnKeyP)
  212. ON_BN_CLICKED(IDC_P1, OnKeyP1)
  213. ON_BN_CLICKED(IDC_P2, OnKeyP2)
  214. ON_BN_CLICKED(IDC_CAPS, OnKeyCaps)
  215. ON_BN_CLICKED(IDC_A, OnKeyA)
  216. ON_BN_CLICKED(IDC_S, OnKeyS)
  217. ON_BN_CLICKED(IDC_D, OnKeyD)
  218. ON_BN_CLICKED(IDC_F, OnKeyF)
  219. ON_BN_CLICKED(IDC_G, OnKeyG)
  220. ON_BN_CLICKED(IDC_H, OnKeyH)
  221. ON_BN_CLICKED(IDC_J, OnKeyJ)
  222. ON_BN_CLICKED(IDC_K, OnKeyK)
  223. ON_BN_CLICKED(IDC_L, OnKeyL)
  224. ON_BN_CLICKED(IDC_L1, OnKeyL1)
  225. ON_BN_CLICKED(IDC_L2, OnKeyL2)
  226. ON_BN_CLICKED(IDC_Z, OnKeyZ)
  227. ON_BN_CLICKED(IDC_X, OnKeyX)
  228. ON_BN_CLICKED(IDC_C, OnKeyC)
  229. ON_BN_CLICKED(IDC_V, OnKeyV)
  230. ON_BN_CLICKED(IDC_B, OnKeyB)
  231. ON_BN_CLICKED(IDC_N, OnKeyN)
  232. ON_BN_CLICKED(IDC_M, OnKeyM)
  233. ON_BN_CLICKED(IDC_M1, OnKeyM1)
  234. ON_BN_CLICKED(IDC_M2, OnKeyM2)
  235. ON_BN_CLICKED(IDC_M3, OnKeyM3)
  236. ON_BN_CLICKED(IDC_WND, OnKeyWnd)
  237. ON_BN_CLICKED(IDC_MENU, OnKeyMenu)
  238. ON_BN_CLICKED(IDC_TOP, OnKeyTop)
  239. ON_BN_CLICKED(IDC_BOTTOM, OnKeyBotton)
  240. ON_BN_CLICKED(IDC_LEFT, OnKeyLeft)
  241. ON_BN_CLICKED(IDC_RIGHT, OnKeyRight)
  242. ON_BN_CLICKED(IDC_SPACE, OnKeySpace)
  243. ON_BN_CLICKED(IDC_ENTER, OnKeyEnter)
  244. ON_BN_CLICKED(IDC_PS, OnKeyPs)
  245. ON_BN_CLICKED(IDC_ABOUT, OnAbout)
  246. ON_BN_CLICKED(IDC_SHIF, OnKeyShif)
  247. ON_BN_CLICKED(IDC_CTRL, OnKeyCtrl)
  248. ON_BN_CLICKED(IDC_ALT, OnKeyAlt)
  249. END_MESSAGE_MAP()
  250. /////////////////////////////////////////////////////////////////////////////
  251. // CKeyBoardDlg message handlers
  252. BOOL CKeyBoardDlg::OnInitDialog()
  253. {
  254. CDialog::OnInitDialog();
  255. // Add "About..." menu item to system menu.
  256. // IDM_ABOUTBOX must be in the system command range.
  257. ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
  258. ASSERT(IDM_ABOUTBOX < 0xF000);
  259. CMenu* pSysMenu = GetSystemMenu(FALSE);
  260. if (pSysMenu != NULL)
  261. {
  262. CString strAboutMenu;
  263. strAboutMenu.LoadString(IDS_ABOUTBOX);
  264. if (!strAboutMenu.IsEmpty())
  265. {
  266. pSysMenu->AppendMenu(MF_SEPARATOR);
  267. pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
  268. }
  269. }
  270. // Set the icon for this dialog.  The framework does this automatically
  271. //  when the application's main window is not a dialog
  272. SetIcon(m_hIcon, TRUE); // Set big icon
  273. SetIcon(m_hIcon, FALSE); // Set small icon
  274. // TODO: Add extra initialization here
  275. //设置矩形窗口(内部)
  276. CRect winrect;
  277. GetClientRect(&winrect);
  278. m_brush.CreateSolidBrush(RGB(255,255,255));
  279. m_rgn.CreateRectRgn(0,0,winrect.right,winrect.bottom);
  280.     SetWindowRgn(m_rgn, 1);
  281. SetWindowText(_T("软键盘"));
  282. //////////////////////////////////////////////
  283. //加载按钮图片
  284. m_key_esc.SetBitmaps(IDB_ESC_UP, RGB(0, 255, 0),IDB_ESC_DOWN, RGB(0, 255, 0));
  285. m_key_esc.DrawTransparent(TRUE);
  286. m_key_esc.DrawBorder(FALSE);
  287. m_key_esc.SetBtnCursor(IDC_HAND);
  288. m_key_f1.SetBitmaps(IDB_F1_UP, RGB(0, 255, 0),IDB_F1_DOWN, RGB(0, 255, 0));
  289. m_key_f1.DrawTransparent(TRUE);
  290. m_key_f1.DrawBorder(FALSE);
  291. m_key_f1.SetBtnCursor(IDC_HAND);
  292. m_key_f2.SetBitmaps(IDB_F2_UP, RGB(0, 255, 0),IDB_F2_DOWN, RGB(0, 255, 0));
  293. m_key_f2.DrawTransparent(TRUE);
  294. m_key_f2.DrawBorder(FALSE);
  295. m_key_f2.SetBtnCursor(IDC_HAND);
  296. m_key_f3.SetBitmaps(IDB_F3_UP, RGB(0, 255, 0),IDB_F3_DOWN, RGB(0, 255, 0));
  297. m_key_f3.DrawTransparent(TRUE);
  298. m_key_f3.DrawBorder(FALSE);
  299. m_key_f3.SetBtnCursor(IDC_HAND);
  300. m_key_f4.SetBitmaps(IDB_F4_UP, RGB(0, 255, 0),IDB_F4_DOWN, RGB(0, 255, 0));
  301. m_key_f4.DrawTransparent(TRUE);
  302. m_key_f4.DrawBorder(FALSE);
  303. m_key_f4.SetBtnCursor(IDC_HAND);
  304. m_key_f5.SetBitmaps(IDB_F5_UP, RGB(0, 255, 0),IDB_F5_DOWN, RGB(0, 255, 0));
  305. m_key_f5.DrawTransparent(TRUE);
  306. m_key_f5.DrawBorder(FALSE);
  307. m_key_f5.SetBtnCursor(IDC_HAND);
  308. m_key_f6.SetBitmaps(IDB_F6_UP, RGB(0, 255, 0),IDB_F6_DOWN, RGB(0, 255, 0));
  309. m_key_f6.DrawTransparent(TRUE);
  310. m_key_f6.DrawBorder(FALSE);
  311. m_key_f6.SetBtnCursor(IDC_HAND);
  312. m_key_f7.SetBitmaps(IDB_F7_UP, RGB(0, 255, 0),IDB_F7_DOWN, RGB(0, 255, 0));
  313. m_key_f7.DrawTransparent(TRUE);
  314. m_key_f7.DrawBorder(FALSE);
  315. m_key_f7.SetBtnCursor(IDC_HAND);
  316. m_key_f8.SetBitmaps(IDB_F8_UP, RGB(0, 255, 0),IDB_F8_DOWN, RGB(0, 255, 0));
  317. m_key_f8.DrawTransparent(TRUE);
  318. m_key_f8.DrawBorder(FALSE);
  319. m_key_f8.SetBtnCursor(IDC_HAND);
  320. m_key_f9.SetBitmaps(IDB_F9_UP, RGB(0, 255, 0),IDB_F9_DOWN, RGB(0, 255, 0));
  321. m_key_f9.DrawTransparent(TRUE);
  322. m_key_f9.DrawBorder(FALSE);
  323. m_key_f9.SetBtnCursor(IDC_HAND);
  324. m_key_f10.SetBitmaps(IDB_F10_UP, RGB(0, 255, 0),IDB_F10_DOWN, RGB(0, 255, 0));
  325. m_key_f10.DrawTransparent(TRUE);
  326. m_key_f10.DrawBorder(FALSE);
  327. m_key_f10.SetBtnCursor(IDC_HAND);
  328. m_key_f11.SetBitmaps(IDB_F11_UP, RGB(0, 255, 0),IDB_F11_DOWN, RGB(0, 255, 0));
  329. m_key_f11.DrawTransparent(TRUE);
  330. m_key_f11.DrawBorder(FALSE);
  331. m_key_f11.SetBtnCursor(IDC_HAND);
  332. m_key_f12.SetBitmaps(IDB_F12_UP, RGB(0, 255, 0),IDB_F12_DOWN, RGB(0, 255, 0));
  333. m_key_f12.DrawTransparent(TRUE);
  334. m_key_f12.DrawBorder(FALSE);
  335. m_key_f12.SetBtnCursor(IDC_HAND);
  336. m_key_pause.SetBitmaps(IDB_PAUSE_UP, RGB(0, 255, 0),IDB_PAUSE_DOWN, RGB(0, 255, 0));
  337. m_key_pause.DrawTransparent(TRUE);
  338. m_key_pause.DrawBorder(FALSE);
  339. m_key_pause.SetBtnCursor(IDC_HAND);
  340. m_key_ins.SetBitmaps(IDB_INS_UP, RGB(0, 255, 0),IDB_INS_DOWN, RGB(0, 255, 0));
  341. m_key_ins.DrawTransparent(TRUE);
  342. m_key_ins.DrawBorder(FALSE);
  343. m_key_ins.SetBtnCursor(IDC_HAND);
  344. m_key_del.SetBitmaps(IDB_DEL_UP, RGB(0, 255, 0),IDB_DEL_DOWN, RGB(0, 255, 0));
  345. m_key_del.DrawTransparent(TRUE);
  346. m_key_del.DrawBorder(FALSE);
  347. m_key_del.SetBtnCursor(IDC_HAND);
  348. m_key_pgup.SetBitmaps(IDB_PGUP_UP, RGB(0, 255, 0),IDB_PGUP_DOWN, RGB(0, 255, 0));
  349. m_key_pgup.DrawTransparent(TRUE);
  350. m_key_pgup.DrawBorder(FALSE);
  351. m_key_pgup.SetBtnCursor(IDC_HAND);
  352. m_key_pgdn.SetBitmaps(IDB_PGDN_UP, RGB(0, 255, 0),IDB_PGDN_DOWN, RGB(0, 255, 0));
  353. m_key_pgdn.DrawTransparent(TRUE);
  354. m_key_pgdn.DrawBorder(FALSE);
  355. m_key_pgdn.SetBtnCursor(IDC_HAND);
  356. m_key_home.SetBitmaps(IDB_HOME_UP, RGB(0, 255, 0),IDB_HOME_DOWN, RGB(0, 255, 0));
  357. m_key_home.DrawTransparent(TRUE);
  358. m_key_home.DrawBorder(FALSE);
  359. m_key_home.SetBtnCursor(IDC_HAND);
  360. m_key_end.SetBitmaps(IDB_END_UP, RGB(0, 255, 0),IDB_END_DOWN, RGB(0, 255, 0));
  361. m_key_end.DrawTransparent(TRUE);
  362. m_key_end.DrawBorder(FALSE);
  363. m_key_end.SetBtnCursor(IDC_HAND);
  364. m_key_once.SetBitmaps(IDB_ONCE_UP, RGB(0, 255, 0),IDB_ONCE_DOWN, RGB(0, 255, 0));
  365. m_key_once.DrawTransparent(TRUE);
  366. m_key_once.DrawBorder(FALSE);
  367. m_key_once.SetBtnCursor(IDC_HAND);
  368. m_key_1.SetBitmaps(IDB_1_UP, RGB(0, 255, 0),IDB_1_DOWN, RGB(0, 255, 0));
  369. m_key_1.DrawTransparent(TRUE);
  370. m_key_1.DrawBorder(FALSE);
  371. m_key_1.SetBtnCursor(IDC_HAND);
  372. m_key_2.SetBitmaps(IDB_2_UP, RGB(0, 255, 0),IDB_2_DOWN, RGB(0, 255, 0));
  373. m_key_2.DrawTransparent(TRUE);
  374. m_key_2.DrawBorder(FALSE);
  375. m_key_2.SetBtnCursor(IDC_HAND);
  376. m_key_3.SetBitmaps(IDB_3_UP, RGB(0, 255, 0),IDB_3_DOWN, RGB(0, 255, 0));
  377. m_key_3.DrawTransparent(TRUE);
  378. m_key_3.DrawBorder(FALSE);
  379. m_key_3.SetBtnCursor(IDC_HAND);
  380. m_key_4.SetBitmaps(IDB_4_UP, RGB(0, 255, 0),IDB_4_DOWN, RGB(0, 255, 0));
  381. m_key_4.DrawTransparent(TRUE);
  382. m_key_4.DrawBorder(FALSE);
  383. m_key_4.SetBtnCursor(IDC_HAND);
  384. m_key_5.SetBitmaps(IDB_5_UP, RGB(0, 255, 0),IDB_5_DOWN, RGB(0, 255, 0));
  385. m_key_5.DrawTransparent(TRUE);
  386. m_key_5.DrawBorder(FALSE);
  387. m_key_5.SetBtnCursor(IDC_HAND);
  388. m_key_6.SetBitmaps(IDB_6_UP, RGB(0, 255, 0),IDB_6_DOWN, RGB(0, 255, 0));
  389. m_key_6.DrawTransparent(TRUE);
  390. m_key_6.DrawBorder(FALSE);
  391. m_key_6.SetBtnCursor(IDC_HAND);
  392. m_key_7.SetBitmaps(IDB_7_UP, RGB(0, 255, 0),IDB_7_DOWN, RGB(0, 255, 0));
  393. m_key_7.DrawTransparent(TRUE);
  394. m_key_7.DrawBorder(FALSE);
  395. m_key_7.SetBtnCursor(IDC_HAND);
  396. m_key_8.SetBitmaps(IDB_8_UP, RGB(0, 255, 0),IDB_8_DOWN, RGB(0, 255, 0));
  397. m_key_8.DrawTransparent(TRUE);
  398. m_key_8.DrawBorder(FALSE);
  399. m_key_8.SetBtnCursor(IDC_HAND);
  400. m_key_9.SetBitmaps(IDB_9_UP, RGB(0, 255, 0),IDB_9_DOWN, RGB(0, 255, 0));
  401. m_key_9.DrawTransparent(TRUE);
  402. m_key_9.DrawBorder(FALSE);
  403. m_key_9.SetBtnCursor(IDC_HAND);
  404. m_key_0.SetBitmaps(IDB_0_UP, RGB(0, 255, 0),IDB_0_DOWN, RGB(0, 255, 0));
  405. m_key_0.DrawTransparent(TRUE);
  406. m_key_0.DrawBorder(FALSE);
  407. m_key_0.SetBtnCursor(IDC_HAND);
  408. m_key_10.SetBitmaps(IDB_10_UP, RGB(0, 255, 0),IDB_10_DOWN, RGB(0, 255, 0));
  409. m_key_10.DrawTransparent(TRUE);
  410. m_key_10.DrawBorder(FALSE);
  411. m_key_10.SetBtnCursor(IDC_HAND);
  412. m_key_11.SetBitmaps(IDB_11_UP, RGB(0, 255, 0),IDB_11_DOWN, RGB(0, 255, 0));
  413. m_key_11.DrawTransparent(TRUE);
  414. m_key_11.DrawBorder(FALSE);
  415. m_key_11.SetBtnCursor(IDC_HAND);
  416. m_key_12.SetBitmaps(IDB_12_UP, RGB(0, 255, 0),IDB_12_DOWN, RGB(0, 255, 0));
  417. m_key_12.DrawTransparent(TRUE);
  418. m_key_12.DrawBorder(FALSE);
  419. m_key_12.SetBtnCursor(IDC_HAND);
  420. m_key_bspc.SetBitmaps(IDB_BSPC_UP, RGB(0, 255, 0),IDB_BSPC_DOWN, RGB(0, 255, 0));
  421. m_key_bspc.DrawTransparent(TRUE);
  422. m_key_bspc.DrawBorder(FALSE);
  423. m_key_bspc.SetBtnCursor(IDC_HAND);
  424. m_key_tab.SetBitmaps(IDB_TAB_UP, RGB(0, 255, 0),IDB_TAB_DOWN, RGB(0, 255, 0));
  425. m_key_tab.DrawTransparent(TRUE);
  426. m_key_tab.DrawBorder(FALSE);
  427. m_key_tab.SetBtnCursor(IDC_HAND);
  428. m_key_q.SetBitmaps(IDB_Q_UP, RGB(0, 255, 0),IDB_Q_DOWN, RGB(0, 255, 0));
  429. m_key_q.DrawTransparent(TRUE);
  430. m_key_q.DrawBorder(FALSE);
  431. m_key_q.SetBtnCursor(IDC_HAND);
  432. m_key_w.SetBitmaps(IDB_W_UP, RGB(0, 255, 0),IDB_W_DOWN, RGB(0, 255, 0));
  433. m_key_w.DrawTransparent(TRUE);
  434. m_key_w.DrawBorder(FALSE);
  435. m_key_w.SetBtnCursor(IDC_HAND);
  436. m_key_e.SetBitmaps(IDB_E_UP, RGB(0, 255, 0),IDB_E_DOWN, RGB(0, 255, 0));
  437. m_key_e.DrawTransparent(TRUE);
  438. m_key_e.DrawBorder(FALSE);
  439. m_key_e.SetBtnCursor(IDC_HAND);
  440. m_key_r.SetBitmaps(IDB_R_UP, RGB(0, 255, 0),IDB_R_DOWN, RGB(0, 255, 0));
  441. m_key_r.DrawTransparent(TRUE);
  442. m_key_r.DrawBorder(FALSE);
  443. m_key_r.SetBtnCursor(IDC_HAND);
  444. m_key_t.SetBitmaps(IDB_T_UP, RGB(0, 255, 0),IDB_T_DOWN, RGB(0, 255, 0));
  445. m_key_t.DrawTransparent(TRUE);
  446. m_key_t.DrawBorder(FALSE);
  447. m_key_t.SetBtnCursor(IDC_HAND);
  448. m_key_y.SetBitmaps(IDB_Y_UP, RGB(0, 255, 0),IDB_Y_DOWN, RGB(0, 255, 0));
  449. m_key_y.DrawTransparent(TRUE);
  450. m_key_y.DrawBorder(FALSE);
  451. m_key_y.SetBtnCursor(IDC_HAND);
  452. m_key_u.SetBitmaps(IDB_U_UP, RGB(0, 255, 0),IDB_U_DOWN, RGB(0, 255, 0));
  453. m_key_u.DrawTransparent(TRUE);
  454. m_key_u.DrawBorder(FALSE);
  455. m_key_u.SetBtnCursor(IDC_HAND);
  456. m_key_i.SetBitmaps(IDB_I_UP, RGB(0, 255, 0),IDB_I_DOWN, RGB(0, 255, 0));
  457. m_key_i.DrawTransparent(TRUE);
  458. m_key_i.DrawBorder(FALSE);
  459. m_key_i.SetBtnCursor(IDC_HAND);
  460. m_key_o.SetBitmaps(IDB_O_UP, RGB(0, 255, 0),IDB_O_DOWN, RGB(0, 255, 0));
  461. m_key_o.DrawTransparent(TRUE);
  462. m_key_o.DrawBorder(FALSE);
  463. m_key_o.SetBtnCursor(IDC_HAND);
  464. m_key_p.SetBitmaps(IDB_P_UP, RGB(0, 255, 0),IDB_P_DOWN, RGB(0, 255, 0));
  465. m_key_p.DrawTransparent(TRUE);
  466. m_key_p.DrawBorder(FALSE);
  467. m_key_p.SetBtnCursor(IDC_HAND);
  468. m_key_p1.SetBitmaps(IDB_P1_UP, RGB(0, 255, 0),IDB_P1_DOWN, RGB(0, 255, 0));
  469. m_key_p1.DrawTransparent(TRUE);
  470. m_key_p1.DrawBorder(FALSE);
  471. m_key_p1.SetBtnCursor(IDC_HAND);
  472. m_key_p2.SetBitmaps(IDB_P2_UP, RGB(0, 255, 0),IDB_P2_DOWN, RGB(0, 255, 0));
  473. m_key_p2.DrawTransparent(TRUE);
  474. m_key_p2.DrawBorder(FALSE);
  475. m_key_p2.SetBtnCursor(IDC_HAND);
  476. m_key_caps.SetBitmaps(IDB_CAPS_UP, RGB(0, 255, 0),IDB_CAPS_DOWN, RGB(0, 255, 0));
  477. m_key_caps.DrawTransparent(TRUE);
  478. m_key_caps.DrawBorder(FALSE);
  479. m_key_caps.SetBtnCursor(IDC_HAND);
  480. m_key_a.SetBitmaps(IDB_A_UP, RGB(0, 255, 0),IDB_A_DOWN, RGB(0, 255, 0));
  481. m_key_a.DrawTransparent(TRUE);
  482. m_key_a.DrawBorder(FALSE);
  483. m_key_a.SetBtnCursor(IDC_HAND);
  484. m_key_s.SetBitmaps(IDB_S_UP, RGB(0, 255, 0),IDB_S_DOWN, RGB(0, 255, 0));
  485. m_key_s.DrawTransparent(TRUE);
  486. m_key_s.DrawBorder(FALSE);
  487. m_key_s.SetBtnCursor(IDC_HAND);
  488. m_key_d.SetBitmaps(IDB_D_UP, RGB(0, 255, 0),IDB_D_DOWN, RGB(0, 255, 0));
  489. m_key_d.DrawTransparent(TRUE);
  490. m_key_d.DrawBorder(FALSE);
  491. m_key_d.SetBtnCursor(IDC_HAND);
  492. m_key_f.SetBitmaps(IDB_F_UP, RGB(0, 255, 0),IDB_F_DOWN, RGB(0, 255, 0));
  493. m_key_f.DrawTransparent(TRUE);
  494. m_key_f.DrawBorder(FALSE);
  495. m_key_f.SetBtnCursor(IDC_HAND);
  496. m_key_g.SetBitmaps(IDB_G_UP, RGB(0, 255, 0),IDB_G_DOWN, RGB(0, 255, 0));
  497. m_key_g.DrawTransparent(TRUE);
  498. m_key_g.DrawBorder(FALSE);
  499. m_key_g.SetBtnCursor(IDC_HAND);
  500. m_key_h.SetBitmaps(IDB_H_UP, RGB(0, 255, 0),IDB_H_DOWN, RGB(0, 255, 0));
  501. m_key_h.DrawTransparent(TRUE);
  502. m_key_h.DrawBorder(FALSE);
  503. m_key_h.SetBtnCursor(IDC_HAND);
  504. m_key_j.SetBitmaps(IDB_J_UP, RGB(0, 255, 0),IDB_J_DOWN, RGB(0, 255, 0));
  505. m_key_j.DrawTransparent(TRUE);
  506. m_key_j.DrawBorder(FALSE);
  507. m_key_j.SetBtnCursor(IDC_HAND);
  508. m_key_k.SetBitmaps(IDB_K_UP, RGB(0, 255, 0),IDB_K_DOWN, RGB(0, 255, 0));
  509. m_key_k.DrawTransparent(TRUE);
  510. m_key_k.DrawBorder(FALSE);
  511. m_key_k.SetBtnCursor(IDC_HAND);
  512. m_key_l.SetBitmaps(IDB_L_UP, RGB(0, 255, 0),IDB_L_DOWN, RGB(0, 255, 0));
  513. m_key_l.DrawTransparent(TRUE);
  514. m_key_l.DrawBorder(FALSE);
  515. m_key_l.SetBtnCursor(IDC_HAND);
  516. m_key_l1.SetBitmaps(IDB_L1_UP, RGB(0, 255, 0),IDB_L1_DOWN, RGB(0, 255, 0));
  517. m_key_l1.DrawTransparent(TRUE);
  518. m_key_l1.DrawBorder(FALSE);
  519. m_key_l1.SetBtnCursor(IDC_HAND);
  520. m_key_l2.SetBitmaps(IDB_L2_UP, RGB(0, 255, 0),IDB_L2_DOWN, RGB(0, 255, 0));
  521. m_key_l2.DrawTransparent(TRUE);
  522. m_key_l2.DrawBorder(FALSE);
  523. m_key_l2.SetBtnCursor(IDC_HAND);
  524. m_key_shif.SetBitmaps(IDB_SHIF_UP, RGB(0, 255, 0),IDB_SHIF_DOWN, RGB(0, 255, 0));
  525. m_key_shif.DrawTransparent(TRUE);
  526. m_key_shif.DrawBorder(FALSE);
  527. m_key_shif.SetBtnCursor(IDC_HAND);
  528. m_key_z.SetBitmaps(IDB_Z_UP, RGB(0, 255, 0),IDB_Z_DOWN, RGB(0, 255, 0));
  529. m_key_z.DrawTransparent(TRUE);
  530. m_key_z.DrawBorder(FALSE);
  531. m_key_z.SetBtnCursor(IDC_HAND);
  532. m_key_x.SetBitmaps(IDB_X_UP, RGB(0, 255, 0),IDB_X_DOWN, RGB(0, 255, 0));
  533. m_key_x.DrawTransparent(TRUE);
  534. m_key_x.DrawBorder(FALSE);
  535. m_key_x.SetBtnCursor(IDC_HAND);
  536. m_key_c.SetBitmaps(IDB_C_UP, RGB(0, 255, 0),IDB_C_DOWN, RGB(0, 255, 0));
  537. m_key_c.DrawTransparent(TRUE);
  538. m_key_c.DrawBorder(FALSE);
  539. m_key_c.SetBtnCursor(IDC_HAND);
  540. m_key_v.SetBitmaps(IDB_V_UP, RGB(0, 255, 0),IDB_V_DOWN, RGB(0, 255, 0));
  541. m_key_v.DrawTransparent(TRUE);
  542. m_key_v.DrawBorder(FALSE);
  543. m_key_v.SetBtnCursor(IDC_HAND);
  544. m_key_b.SetBitmaps(IDB_B_UP, RGB(0, 255, 0),IDB_B_DOWN, RGB(0, 255, 0));
  545. m_key_b.DrawTransparent(TRUE);
  546. m_key_b.DrawBorder(FALSE);
  547. m_key_b.SetBtnCursor(IDC_HAND);
  548. m_key_n.SetBitmaps(IDB_N_UP, RGB(0, 255, 0),IDB_N_DOWN, RGB(0, 255, 0));
  549. m_key_n.DrawTransparent(TRUE);
  550. m_key_n.DrawBorder(FALSE);
  551. m_key_n.SetBtnCursor(IDC_HAND);
  552. m_key_m.SetBitmaps(IDB_M_UP, RGB(0, 255, 0),IDB_M_DOWN, RGB(0, 255, 0));
  553. m_key_m.DrawTransparent(TRUE);
  554. m_key_m.DrawBorder(FALSE);
  555. m_key_m.SetBtnCursor(IDC_HAND);
  556. m_key_m1.SetBitmaps(IDB_M1_UP, RGB(0, 255, 0),IDB_M1_DOWN, RGB(0, 255, 0));
  557. m_key_m1.DrawTransparent(TRUE);
  558. m_key_m1.DrawBorder(FALSE);
  559. m_key_m1.SetBtnCursor(IDC_HAND);
  560. m_key_m2.SetBitmaps(IDB_M2_UP, RGB(0, 255, 0),IDB_M2_DOWN, RGB(0, 255, 0));
  561. m_key_m2.DrawTransparent(TRUE);
  562. m_key_m2.DrawBorder(FALSE);
  563. m_key_m2.SetBtnCursor(IDC_HAND);
  564. m_key_m3.SetBitmaps(IDB_M3_UP, RGB(0, 255, 0),IDB_M3_DOWN, RGB(0, 255, 0));
  565. m_key_m3.DrawTransparent(TRUE);
  566. m_key_m3.DrawBorder(FALSE);
  567. m_key_m3.SetBtnCursor(IDC_HAND);
  568. m_key_ctrl.SetBitmaps(IDB_CTRL_UP, RGB(0, 255, 0),IDB_CTRL_DOWN, RGB(0, 255, 0));
  569. m_key_ctrl.DrawTransparent(TRUE);
  570. m_key_ctrl.DrawBorder(FALSE);
  571. m_key_ctrl.SetBtnCursor(IDC_HAND);
  572. m_key_wnd.SetBitmaps(IDB_WND_UP, RGB(0, 255, 0),IDB_WND_DOWN, RGB(0, 255, 0));
  573. m_key_wnd.DrawTransparent(TRUE);
  574. m_key_wnd.DrawBorder(FALSE);
  575. m_key_wnd.SetBtnCursor(IDC_HAND);
  576. m_key_alt.SetBitmaps(IDB_ALT_UP, RGB(0, 255, 0),IDB_ALT_DOWN, RGB(0, 255, 0));
  577. m_key_alt.DrawTransparent(TRUE);
  578. m_key_alt.DrawBorder(FALSE);
  579. m_key_alt.SetBtnCursor(IDC_HAND);
  580. m_key_menu.SetBitmaps(IDB_MENU_UP, RGB(0, 255, 0),IDB_MENU_DOWN, RGB(0, 255, 0));
  581. m_key_menu.DrawTransparent(TRUE);
  582. m_key_menu.DrawBorder(FALSE);
  583. m_key_menu.SetBtnCursor(IDC_HAND);
  584. m_key_top.SetBitmaps(IDB_TOP_UP, RGB(0, 255, 0),IDB_TOP_DOWN, RGB(0, 255, 0));
  585. m_key_top.DrawTransparent(TRUE);
  586. m_key_top.DrawBorder(FALSE);
  587. m_key_top.SetBtnCursor(IDC_HAND);
  588. m_key_bottom.SetBitmaps(IDB_BOTTOM_UP, RGB(0, 255, 0),IDB_BOTTOM_DOWN, RGB(0, 255, 0));
  589. m_key_bottom.DrawTransparent(TRUE);
  590. m_key_bottom.DrawBorder(FALSE);
  591. m_key_bottom.SetBtnCursor(IDC_HAND);
  592. m_key_left.SetBitmaps(IDB_LEFT_UP, RGB(0, 255, 0),IDB_LEFT_DOWN, RGB(0, 255, 0));
  593. m_key_left.DrawTransparent(TRUE);
  594. m_key_left.DrawBorder(FALSE);
  595. m_key_left.SetBtnCursor(IDC_HAND);
  596. m_key_right.SetBitmaps(IDB_RIGHT_UP, RGB(0, 255, 0),IDB_RIGHT_DOWN, RGB(0, 255, 0));
  597. m_key_right.DrawTransparent(TRUE);
  598. m_key_right.DrawBorder(FALSE);
  599. m_key_right.SetBtnCursor(IDC_HAND);
  600. m_key_space.SetBitmaps(IDB_SPACE, RGB(0, 255, 0));
  601. m_key_space.DrawTransparent(TRUE);
  602. m_key_space.DrawBorder(FALSE);
  603. m_key_space.SetBtnCursor(IDC_HAND);
  604. m_key_enter.SetBitmaps(IDB_ENTER_UP, RGB(0, 255, 0),IDB_ENTER_DOWN, RGB(0, 255, 0));
  605. m_key_enter.DrawTransparent(TRUE);
  606. m_key_enter.DrawBorder(FALSE);
  607. m_key_enter.SetBtnCursor(IDC_HAND);
  608. m_key_ps.SetBitmaps(IDB_PS_UP, RGB(0, 255, 0),IDB_PS_DOWN, RGB(0, 255, 0));
  609. m_key_ps.DrawTransparent(TRUE);
  610. m_key_ps.DrawBorder(FALSE);
  611. m_key_ps.SetBtnCursor(IDC_HAND);
  612. m_key_exit.SetBitmaps(IDB_EXIT_UP, RGB(0, 255, 0),IDB_EXIT_DOWN, RGB(0, 255, 0));
  613. m_key_exit.DrawTransparent(TRUE);
  614. m_key_exit.DrawBorder(FALSE);
  615. m_key_exit.SetBtnCursor(IDC_HAND);
  616. //////////////////////////////////////////////
  617. return TRUE;  // return TRUE  unless you set the focus to a control
  618. }
  619. void CKeyBoardDlg::OnSysCommand(UINT nID, LPARAM lParam)
  620. {
  621. if ((nID & 0xFFF0) == IDM_ABOUTBOX)
  622. {
  623. CAboutDlg dlgAbout;
  624. dlgAbout.DoModal();
  625. }
  626. else
  627. {
  628. CDialog::OnSysCommand(nID, lParam);
  629. }
  630. }
  631. // If you add a minimize button to your dialog, you will need the code below
  632. //  to draw the icon.  For MFC applications using the document/view model,
  633. //  this is automatically done for you by the framework.
  634. void CKeyBoardDlg::OnPaint() 
  635. {
  636. if (IsIconic())
  637. {
  638. CPaintDC dc(this); // device context for painting
  639. SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
  640. // Center icon in client rectangle
  641. int cxIcon = GetSystemMetrics(SM_CXICON);
  642. int cyIcon = GetSystemMetrics(SM_CYICON);
  643. CRect rect;
  644. GetClientRect(&rect);
  645. int x = (rect.Width() - cxIcon + 1) / 2;
  646. int y = (rect.Height() - cyIcon + 1) / 2;
  647. // Draw the icon
  648. dc.DrawIcon(x, y, m_hIcon);
  649. }
  650. else
  651. {
  652. CDialog::OnPaint();
  653. }
  654. }
  655. // The system calls this to obtain the cursor to display while the user drags
  656. //  the minimized window.
  657. HCURSOR CKeyBoardDlg::OnQueryDragIcon()
  658. {
  659. return (HCURSOR) m_hIcon;
  660. }
  661. void CKeyBoardDlg::OnContextMenu(CWnd*, CPoint point)
  662. {
  663. if (point.x == -1 && point.y == -1)
  664. {
  665. CRect rect;
  666. GetClientRect(rect);
  667. ClientToScreen(rect);
  668. point = rect.TopLeft();
  669. point.Offset(5, 5);
  670. }
  671. BCMenu popmenu;
  672. popmenu.LoadMenu(CG_IDR_POPUP_KEY_BOARD_DLG);
  673. BCMenu::SetMenuDrawMode(BCMENU_DRAWMODE_XP);
  674. //显示图片
  675. popmenu.ModifyODMenu(NULL, IDCANCEL,IDB_QUIT);
  676. popmenu.ModifyODMenu(NULL, IDC_ABOUT,IDB_ABOUT);
  677. BCMenu *psub = (BCMenu *)popmenu.GetSubMenu(0); 
  678. psub->TrackPopupMenu(TPM_LEFTALIGN|TPM_RIGHTBUTTON,point.x,point.y,this);
  679. popmenu.DestroyMenu();
  680. }
  681. //重绘窗口
  682. BOOL CKeyBoardDlg::OnEraseBkgnd(CDC *pDC)
  683. {
  684. CRgn myrgn;
  685. CBrush frameBrush;
  686. CRect winrect;
  687. GetClientRect(&winrect);
  688. // myrgn.CreateRectRgn(0,0,winrect.right,winrect.bottom);//绘制直角矩形
  689. myrgn.CreateRoundRectRgn(0,0,winrect.right,winrect.bottom,5,5);//绘制圆角矩形圆角度5
  690. frameBrush.CreateSolidBrush(RGB(0,158,221)); //边框颜色
  691. pDC->FillRgn(&myrgn,&m_brush);
  692. pDC->FrameRgn(&myrgn,&frameBrush,1,1);
  693. pDC->SetBkMode(TRANSPARENT);
  694. return TRUE;
  695. }
  696. //点窗体任何部位移动窗体
  697. UINT CKeyBoardDlg::OnNcHitTest(CPoint point) 
  698. {
  699. UINT nHitTest = CDialog :: OnNcHitTest (point);
  700. return (nHitTest == HTCLIENT) ? HTCAPTION :nHitTest; 
  701. }
  702. void CKeyBoardDlg::OnAbout() 
  703. {
  704. // TODO: Add your control notification handler code here
  705. CAboutDlg about;
  706. about.DoModal();
  707. }
  708. void CAboutDlg::OnLButtonDown(UINT nFlags, CPoint point) 
  709. {
  710. // TODO: Add your message handler code here and/or call default
  711. PostMessage(WM_CLOSE);
  712. CDialog::OnLButtonDown(nFlags, point);
  713. }
  714. BOOL CAboutDlg::OnInitDialog() 
  715. {
  716. CDialog::OnInitDialog();
  717. //设置矩形窗口(内部)
  718. CRect winrect;
  719. GetClientRect(&winrect);
  720. m_brush.CreateSolidBrush(RGB(255,255,255));
  721. m_rgn.CreateRectRgn(0,0,winrect.right,winrect.bottom);
  722. return TRUE;  // return TRUE unless you set the focus to a control
  723.               // EXCEPTION: OCX PropertyPages should return FALSE
  724. }
  725. BOOL CAboutDlg::OnEraseBkgnd(CDC *pDC)
  726. {
  727. CRgn myrgn,rgn;
  728. CBrush frameBrush;
  729. CRect winrect;
  730. GetClientRect(&winrect);
  731. myrgn.CreateRoundRectRgn(0,0,winrect.right,winrect.bottom,5,5);//绘制圆角矩形圆角度5
  732. rgn.CreateRoundRectRgn(10,10,winrect.right - 10,winrect.bottom - 10,5,5);//绘制圆角矩形圆角度5
  733. frameBrush.CreateSolidBrush(RGB(0,158,221)); //边框颜色
  734. pDC->FillRgn(&myrgn,&m_brush);
  735. pDC->FrameRgn(&myrgn,&frameBrush,1,1);
  736. pDC->FrameRgn(&rgn,&frameBrush,1,1);
  737. //////////////////////////////////////////////
  738. // CBrush fillBrush;
  739. // CRgn fillRgn;
  740. // fillRgn.CreateRoundRectRgn(9,9,winrect.right - 10,winrect.bottom - 10,5,5);
  741. // fillBrush.CreateSolidBrush(RGB(107,210,250));
  742. // pDC->FillRgn(&fillRgn,&fillBrush);
  743. //////////////////////////////////////////////
  744. pDC->SetBkMode(TRANSPARENT);
  745. //文字
  746. CFont font;
  747. CRect tempRect;
  748. font.CreateFont(12,6,0,0,FW_NORMAL,0,0,0,GB2312_CHARSET,
  749. OUT_STROKE_PRECIS,CLIP_STROKE_PRECIS,DRAFT_QUALITY,
  750. VARIABLE_PITCH|FF_SWISS,"宋体");
  751. pDC->SelectObject(&font);
  752. tempRect.top=20;
  753. tempRect.left=55;
  754. tempRect.right=500;
  755. tempRect.bottom=200;
  756. pDC->DrawText(_T("KeyBoard 1.0 版"),&tempRect,DT_TOP|DT_WORDBREAK);
  757. tempRect.top+=25;
  758. pDC->DrawText(_T("STORM 版权所有(C)2005"),&tempRect,DT_TOP|DT_WORDBREAK);
  759. tempRect.top+=13;
  760. pDC->DrawText(_T("storm_jyd@163.com"),&tempRect,DT_TOP|DT_WORDBREAK);
  761. return TRUE;
  762. }
  763. int CKeyBoardDlg::OnCreate(LPCREATESTRUCT lpCreateStruct) 
  764. {
  765. if (CDialog::OnCreate(lpCreateStruct) == -1)
  766. return -1;
  767. //置窗体为最顶层显示及其位置
  768. CRect rcW;
  769. GetWindowRect(&rcW);
  770. SetWindowPos(&wndTopMost,rcW.left,rcW.top,rcW.Width(),rcW.Height(),SWP_NOSIZE|SWP_NOMOVE);
  771. return 0;
  772. }
  773. //处理系统消息循环
  774. BOOL CKeyBoardDlg::PreTranslateMessage(MSG* pMsg) 
  775. {
  776. HWND wnd = ::GetForegroundWindow();
  777. if(IsWindow(wnd))
  778. {
  779. //如果当前激活窗口不是本程序的窗口
  780. if(wnd != this->m_hWnd)
  781. {
  782. //激活窗口发生了改变
  783. if(m_Focus != wnd)
  784. {
  785. if(IsWindow(m_Focus))
  786. {
  787. //释放本进程和gFocus线程的联系
  788. AttachThreadInput(
  789. GetWindowThreadProcessId(m_hWnd,NULL),
  790. GetWindowThreadProcessId(m_Focus,NULL),
  791. FALSE);
  792. }
  793. m_Focus = wnd;
  794. //使本进程和激活窗口的进程联系起来,接收本进程的按键消息
  795. AttachThreadInput(
  796. GetWindowThreadProcessId(m_hWnd,NULL),
  797. GetWindowThreadProcessId(m_Focus,NULL),
  798. TRUE);
  799. }
  800. }
  801. }
  802. return CDialog::PreTranslateMessage(pMsg);
  803. }
  804. void CKeyBoardDlg::ReleaseFocus()
  805. {
  806. //释放焦点
  807. if(IsWindow(m_Focus))
  808. {
  809. HWND wnd = ::GetForegroundWindow();
  810. if(IsWindow(wnd))
  811. {
  812. if(wnd == m_Focus)
  813. {
  814. return;
  815. }
  816. }
  817. //设置保存的焦点窗口处于激活状态
  818. ::SetForegroundWindow(m_Focus);
  819. ::SetFocus(m_Focus);
  820. }
  821. }
  822. void CKeyBoardDlg::OnKeyEsc() 
  823. {
  824. ReleaseFocus();
  825. keybd_event(VK_ESCAPE,0,0,0);
  826. keybd_event(VK_ESCAPE,0,KEYEVENTF_KEYUP,0);
  827. ReleaseFocus();
  828. }
  829. void CKeyBoardDlg::OnKeyF1() 
  830. {
  831. ReleaseFocus();
  832. keybd_event(VK_F1,0,0,0);
  833. keybd_event(VK_F1,0,KEYEVENTF_KEYUP,0);
  834. ReleaseFocus();
  835. }
  836. void CKeyBoardDlg::OnKeyF2() 
  837. {
  838. ReleaseFocus();
  839. keybd_event(VK_F2,0,0,0);
  840. keybd_event(VK_F2,0,KEYEVENTF_KEYUP,0);
  841. ReleaseFocus();
  842. }
  843. void CKeyBoardDlg::OnKeyF3() 
  844. {
  845. ReleaseFocus();
  846. keybd_event(VK_F3,0,0,0);
  847. keybd_event(VK_F3,0,KEYEVENTF_KEYUP,0);
  848. ReleaseFocus();
  849. }
  850. void CKeyBoardDlg::OnKeyF4() 
  851. {
  852. ReleaseFocus();
  853. keybd_event(VK_F4,0,0,0);
  854. keybd_event(VK_F4,0,KEYEVENTF_KEYUP,0);
  855. ReleaseFocus();
  856. }
  857. void CKeyBoardDlg::OnKeyF5() 
  858. {
  859. ReleaseFocus();
  860. keybd_event(VK_F5,0,0,0);
  861. keybd_event(VK_F5,0,KEYEVENTF_KEYUP,0);
  862. ReleaseFocus();
  863. }
  864. void CKeyBoardDlg::OnKeyF6() 
  865. {
  866. ReleaseFocus();
  867. keybd_event(VK_F6,0,0,0);
  868. keybd_event(VK_F6,0,KEYEVENTF_KEYUP,0);
  869. ReleaseFocus();
  870. }
  871. void CKeyBoardDlg::OnKeyF7() 
  872. {
  873. ReleaseFocus();
  874. keybd_event(VK_F7,0,0,0);
  875. keybd_event(VK_F7,0,KEYEVENTF_KEYUP,0);
  876. ReleaseFocus();
  877. }
  878. void CKeyBoardDlg::OnKeyF8() 
  879. {
  880. ReleaseFocus();
  881. keybd_event(VK_F8,0,0,0);
  882. keybd_event(VK_F8,0,KEYEVENTF_KEYUP,0);
  883. ReleaseFocus();
  884. }
  885. void CKeyBoardDlg::OnKeyF9() 
  886. {
  887. ReleaseFocus();
  888. keybd_event(VK_F9,0,0,0);
  889. keybd_event(VK_F9,0,KEYEVENTF_KEYUP,0);
  890. ReleaseFocus();
  891. }
  892. void CKeyBoardDlg::OnKeyF10() 
  893. {
  894. ReleaseFocus();
  895. keybd_event(VK_F10,0,0,0);
  896. keybd_event(VK_F10,0,KEYEVENTF_KEYUP,0);
  897. ReleaseFocus();
  898. }
  899. void CKeyBoardDlg::OnKeyF11() 
  900. {
  901. ReleaseFocus();
  902. keybd_event(VK_F11,0,0,0);
  903. keybd_event(VK_F11,0,KEYEVENTF_KEYUP,0);
  904. ReleaseFocus();
  905. }
  906. void CKeyBoardDlg::OnKeyF12() 
  907. {
  908. ReleaseFocus();
  909. keybd_event(VK_F12,0,0,0);
  910. keybd_event(VK_F12,0,KEYEVENTF_KEYUP,0);
  911. ReleaseFocus();
  912. }
  913. void CKeyBoardDlg::OnKeyPause() 
  914. {
  915. ReleaseFocus();
  916. keybd_event(VK_PAUSE,0,0,0);
  917. keybd_event(VK_PAUSE,0,KEYEVENTF_KEYUP,0);
  918. ReleaseFocus();
  919. }
  920. void CKeyBoardDlg::OnKeyIns() 
  921. {
  922. ReleaseFocus();
  923. keybd_event(VK_INSERT,0,0,0);
  924. keybd_event(VK_INSERT,0,KEYEVENTF_KEYUP,0);
  925. ReleaseFocus();
  926. }
  927. void CKeyBoardDlg::OnKeyDel() 
  928. {
  929. ReleaseFocus();
  930. keybd_event(VK_DELETE,0,0,0);
  931. keybd_event(VK_DELETE,0,KEYEVENTF_KEYUP,0);
  932. ReleaseFocus();
  933. }
  934. void CKeyBoardDlg::OnKeyPgup() 
  935. {
  936. ReleaseFocus();
  937. keybd_event(VK_PRIOR,0,0,0);
  938. keybd_event(VK_PRIOR,0,KEYEVENTF_KEYUP,0);
  939. ReleaseFocus();
  940. }
  941. void CKeyBoardDlg::OnKeyPgdn() 
  942. {
  943. ReleaseFocus();
  944. keybd_event(VK_NEXT,0,0,0);
  945. keybd_event(VK_NEXT,0,KEYEVENTF_KEYUP,0);
  946. ReleaseFocus();
  947. }
  948. void CKeyBoardDlg::OnKeyHome() 
  949. {
  950. ReleaseFocus();
  951. keybd_event(VK_HOME,0,0,0);
  952. keybd_event(VK_HOME,0,KEYEVENTF_KEYUP,0);
  953. ReleaseFocus();
  954. }
  955. void CKeyBoardDlg::OnKeyEnd() 
  956. {
  957. ReleaseFocus();
  958. keybd_event(VK_END,0,0,0);
  959. keybd_event(VK_END,0,KEYEVENTF_KEYUP,0);
  960. ReleaseFocus();
  961. }
  962. void CKeyBoardDlg::OnKeyOnce() 
  963. {
  964. ReleaseFocus();
  965. char pChar;
  966. pChar = '`';
  967. SHORT ks = VkKeyScan(pChar);
  968. BYTE key = ks & 0xFF;
  969. keybd_event(key,0,0,0);
  970. keybd_event(key,0,KEYEVENTF_KEYUP,0);
  971. if(m_key_shif.GetCheck())//"shift"键是被按下
  972. {
  973. keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
  974. m_key_shif.SetCheck(FALSE);
  975. }
  976. ReleaseFocus();
  977. }
  978. void CKeyBoardDlg::OnKey1() 
  979. {
  980. ReleaseFocus();
  981. char pChar;
  982. pChar = '1';
  983. SHORT ks = VkKeyScan(pChar);
  984. BYTE key = ks & 0xFF;
  985. keybd_event(key,0,0,0);
  986. keybd_event(key,0,KEYEVENTF_KEYUP,0);
  987. if(m_key_shif.GetCheck())//"shift"键是被按下
  988. {
  989. keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
  990. m_key_shif.SetCheck(FALSE);
  991. }
  992. ReleaseFocus();
  993. }
  994. void CKeyBoardDlg::OnKey2() 
  995. {
  996. ReleaseFocus();
  997. char pChar;
  998. pChar = '2';
  999. SHORT ks = VkKeyScan(pChar);
  1000. BYTE key = ks & 0xFF;
  1001. keybd_event(key,0,0,0);
  1002. keybd_event(key,0,KEYEVENTF_KEYUP,0);
  1003. if(m_key_shif.GetCheck())//"shift"键是被按下
  1004. {
  1005. keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
  1006. m_key_shif.SetCheck(FALSE);
  1007. }
  1008. ReleaseFocus();
  1009. }
  1010. void CKeyBoardDlg::OnKey3() 
  1011. {
  1012. ReleaseFocus();
  1013. char pChar;
  1014. pChar = '3';
  1015. SHORT ks = VkKeyScan(pChar);
  1016. BYTE key = ks & 0xFF;
  1017. keybd_event(key,0,0,0);
  1018. keybd_event(key,0,KEYEVENTF_KEYUP,0);
  1019. if(m_key_shif.GetCheck())//"shift"键是被按下
  1020. {
  1021. keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
  1022. m_key_shif.SetCheck(FALSE);
  1023. }
  1024. ReleaseFocus();
  1025. }
  1026. void CKeyBoardDlg::OnKey4() 
  1027. {
  1028. ReleaseFocus();
  1029. char pChar;
  1030. pChar = '4';
  1031. SHORT ks = VkKeyScan(pChar);
  1032. BYTE key = ks & 0xFF;
  1033. keybd_event(key,0,0,0);
  1034. keybd_event(key,0,KEYEVENTF_KEYUP,0);
  1035. if(m_key_shif.GetCheck())//"shift"键是被按下
  1036. {
  1037. keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
  1038. m_key_shif.SetCheck(FALSE);
  1039. }
  1040. ReleaseFocus();
  1041. }
  1042. void CKeyBoardDlg::OnKey5() 
  1043. {
  1044. ReleaseFocus();
  1045. char pChar;
  1046. pChar = '5';
  1047. SHORT ks = VkKeyScan(pChar);
  1048. BYTE key = ks & 0xFF;
  1049. keybd_event(key,0,0,0);
  1050. keybd_event(key,0,KEYEVENTF_KEYUP,0);
  1051. if(m_key_shif.GetCheck())//"shift"键是被按下
  1052. {
  1053. keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
  1054. m_key_shif.SetCheck(FALSE);
  1055. }
  1056. ReleaseFocus();
  1057. }
  1058. void CKeyBoardDlg::OnKey6() 
  1059. {
  1060. ReleaseFocus();
  1061. char pChar;
  1062. pChar = '6';
  1063. SHORT ks = VkKeyScan(pChar);
  1064. BYTE key = ks & 0xFF;
  1065. keybd_event(key,0,0,0);
  1066. keybd_event(key,0,KEYEVENTF_KEYUP,0);
  1067. if(m_key_shif.GetCheck())//"shift"键是被按下
  1068. {
  1069. keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
  1070. m_key_shif.SetCheck(FALSE);
  1071. }
  1072. ReleaseFocus();
  1073. }
  1074. void CKeyBoardDlg::OnKey7() 
  1075. {
  1076. ReleaseFocus();
  1077. char pChar;
  1078. pChar = '7';
  1079. SHORT ks = VkKeyScan(pChar);
  1080. BYTE key = ks & 0xFF;
  1081. keybd_event(key,0,0,0);
  1082. keybd_event(key,0,KEYEVENTF_KEYUP,0);
  1083. if(m_key_shif.GetCheck())//"shift"键是被按下
  1084. {
  1085. keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
  1086. m_key_shif.SetCheck(FALSE);
  1087. }
  1088. ReleaseFocus();
  1089. }
  1090. void CKeyBoardDlg::OnKey8() 
  1091. {
  1092. ReleaseFocus();
  1093. char pChar;
  1094. pChar = '8';
  1095. SHORT ks = VkKeyScan(pChar);
  1096. BYTE key = ks & 0xFF;
  1097. keybd_event(key,0,0,0);
  1098. keybd_event(key,0,KEYEVENTF_KEYUP,0);
  1099. if(m_key_shif.GetCheck())//"shift"键是被按下
  1100. {
  1101. keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
  1102. m_key_shif.SetCheck(FALSE);
  1103. }
  1104. ReleaseFocus();
  1105. }
  1106. void CKeyBoardDlg::OnKey9() 
  1107. {
  1108. ReleaseFocus();
  1109. char pChar;
  1110. pChar = '9';
  1111. SHORT ks = VkKeyScan(pChar);
  1112. BYTE key = ks & 0xFF;
  1113. keybd_event(key,0,0,0);
  1114. keybd_event(key,0,KEYEVENTF_KEYUP,0);
  1115. if(m_key_shif.GetCheck())//"shift"键是被按下
  1116. {
  1117. keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
  1118. m_key_shif.SetCheck(FALSE);
  1119. }
  1120. ReleaseFocus();
  1121. }
  1122. void CKeyBoardDlg::OnKey0() 
  1123. {
  1124. ReleaseFocus();
  1125. char pChar;
  1126. pChar = '0';
  1127. SHORT ks = VkKeyScan(pChar);
  1128. BYTE key = ks & 0xFF;
  1129. keybd_event(key,0,0,0);
  1130. keybd_event(key,0,KEYEVENTF_KEYUP,0);
  1131. if(m_key_shif.GetCheck())//"shift"键是被按下
  1132. {
  1133. keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
  1134. m_key_shif.SetCheck(FALSE);
  1135. }
  1136. ReleaseFocus();
  1137. }
  1138. void CKeyBoardDlg::OnKey10() 
  1139. {
  1140. ReleaseFocus();
  1141. char pChar;
  1142. pChar = '-';
  1143. SHORT ks = VkKeyScan(pChar);
  1144. BYTE key = ks & 0xFF;
  1145. keybd_event(key,0,0,0);
  1146. keybd_event(key,0,KEYEVENTF_KEYUP,0);
  1147. if(m_key_shif.GetCheck())//"shift"键是被按下
  1148. {
  1149. keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
  1150. m_key_shif.SetCheck(FALSE);
  1151. }
  1152. ReleaseFocus();
  1153. }
  1154. void CKeyBoardDlg::OnKey11() 
  1155. {
  1156. ReleaseFocus();
  1157. char pChar;
  1158. pChar = '=';
  1159. SHORT ks = VkKeyScan(pChar);
  1160. BYTE key = ks & 0xFF;
  1161. keybd_event(key,0,0,0);
  1162. keybd_event(key,0,KEYEVENTF_KEYUP,0);
  1163. if(m_key_shif.GetCheck())//"shift"键是被按下
  1164. {
  1165. keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
  1166. m_key_shif.SetCheck(FALSE);
  1167. }
  1168. ReleaseFocus();
  1169. }
  1170. void CKeyBoardDlg::OnKey12() 
  1171. {
  1172. ReleaseFocus();
  1173. char pChar;
  1174. pChar = '\';
  1175. SHORT ks = VkKeyScan(pChar);
  1176. BYTE key = ks & 0xFF;
  1177. keybd_event(key,0,0,0);
  1178. keybd_event(key,0,KEYEVENTF_KEYUP,0);
  1179. if(m_key_shif.GetCheck())//"shift"键是被按下
  1180. {
  1181. keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
  1182. m_key_shif.SetCheck(FALSE);
  1183. }
  1184. ReleaseFocus();
  1185. }
  1186. void CKeyBoardDlg::OnKeyBspc() 
  1187. {
  1188. ReleaseFocus();
  1189. keybd_event(VK_BACK,0,0,0);
  1190. keybd_event(VK_BACK,0,KEYEVENTF_KEYUP,0);
  1191. ReleaseFocus();
  1192. }
  1193. void CKeyBoardDlg::OnKeyTab() 
  1194. {
  1195. ReleaseFocus();
  1196. keybd_event(VkKeyScan(0x09) & 0xFF,0,0,0);
  1197. keybd_event(VkKeyScan(0x09) & 0xFF,0,KEYEVENTF_KEYUP,0);
  1198. ReleaseFocus();
  1199. }
  1200. void CKeyBoardDlg::OnKeyQ() 
  1201. {
  1202. ReleaseFocus();
  1203. char pChar;
  1204. pChar = 'q';
  1205. SHORT ks = VkKeyScan(pChar);
  1206. BYTE key = ks & 0xFF;
  1207. keybd_event(key,0,0,0);
  1208. keybd_event(key,0,KEYEVENTF_KEYUP,0);
  1209. if(m_key_shif.GetCheck())//"shift"键是被按下
  1210. {
  1211. keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
  1212. m_key_shif.SetCheck(FALSE);
  1213. }
  1214. if(m_key_ctrl.GetCheck())//"ctrl"键是被按下
  1215. {
  1216. keybd_event(VK_CONTROL,0,KEYEVENTF_KEYUP,0);
  1217. m_key_ctrl.SetCheck(FALSE);
  1218. }
  1219. if(m_key_alt.GetCheck())//"alt"键是被按下
  1220. {
  1221. keybd_event(VK_MENU,0,KEYEVENTF_KEYUP,0);
  1222. m_key_alt.SetCheck(FALSE);
  1223. }
  1224. ReleaseFocus();
  1225. }
  1226. void CKeyBoardDlg::OnKeyW() 
  1227. {
  1228. ReleaseFocus();
  1229. char pChar;
  1230. pChar = 'w';
  1231. SHORT ks = VkKeyScan(pChar);
  1232. BYTE key = ks & 0xFF;
  1233. keybd_event(key,0,0,0);
  1234. keybd_event(key,0,KEYEVENTF_KEYUP,0);
  1235. if(m_key_shif.GetCheck())//"shift"键是被按下
  1236. {
  1237. keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
  1238. m_key_shif.SetCheck(FALSE);
  1239. }
  1240. if(m_key_ctrl.GetCheck())//"ctrl"键是被按下
  1241. {
  1242. keybd_event(VK_CONTROL,0,KEYEVENTF_KEYUP,0);
  1243. m_key_ctrl.SetCheck(FALSE);
  1244. }
  1245. if(m_key_alt.GetCheck())//"alt"键是被按下
  1246. {
  1247. keybd_event(VK_MENU,0,KEYEVENTF_KEYUP,0);
  1248. m_key_alt.SetCheck(FALSE);
  1249. }
  1250. ReleaseFocus();
  1251. }
  1252. void CKeyBoardDlg::OnKeyE() 
  1253. {
  1254. ReleaseFocus();
  1255. char pChar;
  1256. pChar = 'e';
  1257. SHORT ks = VkKeyScan(pChar);
  1258. BYTE key = ks & 0xFF;
  1259. keybd_event(key,0,0,0);
  1260. keybd_event(key,0,KEYEVENTF_KEYUP,0);
  1261. if(m_key_shif.GetCheck())//"shift"键是被按下
  1262. {
  1263. keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
  1264. m_key_shif.SetCheck(FALSE);
  1265. }
  1266. if(m_key_ctrl.GetCheck())//"ctrl"键是被按下
  1267. {
  1268. keybd_event(VK_CONTROL,0,KEYEVENTF_KEYUP,0);
  1269. m_key_ctrl.SetCheck(FALSE);
  1270. }
  1271. if(m_key_alt.GetCheck())//"alt"键是被按下
  1272. {
  1273. keybd_event(VK_MENU,0,KEYEVENTF_KEYUP,0);
  1274. m_key_alt.SetCheck(FALSE);
  1275. }
  1276. ReleaseFocus();
  1277. }
  1278. void CKeyBoardDlg::OnKeyR() 
  1279. {
  1280. ReleaseFocus();
  1281. char pChar;
  1282. pChar = 'r';
  1283. SHORT ks = VkKeyScan(pChar);
  1284. BYTE key = ks & 0xFF;
  1285. keybd_event(key,0,0,0);
  1286. keybd_event(key,0,KEYEVENTF_KEYUP,0);
  1287. if(m_key_shif.GetCheck())//"shift"键是被按下
  1288. {
  1289. keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
  1290. m_key_shif.SetCheck(FALSE);
  1291. }
  1292. if(m_key_ctrl.GetCheck())//"ctrl"键是被按下
  1293. {
  1294. keybd_event(VK_CONTROL,0,KEYEVENTF_KEYUP,0);
  1295. m_key_ctrl.SetCheck(FALSE);
  1296. }
  1297. if(m_key_alt.GetCheck())//"alt"键是被按下
  1298. {
  1299. keybd_event(VK_MENU,0,KEYEVENTF_KEYUP,0);
  1300. m_key_alt.SetCheck(FALSE);
  1301. }
  1302. ReleaseFocus();
  1303. }
  1304. void CKeyBoardDlg::OnKeyT() 
  1305. {
  1306. ReleaseFocus();
  1307. char pChar;
  1308. pChar = 't';
  1309. SHORT ks = VkKeyScan(pChar);
  1310. BYTE key = ks & 0xFF;
  1311. keybd_event(key,0,0,0);
  1312. keybd_event(key,0,KEYEVENTF_KEYUP,0);
  1313. if(m_key_shif.GetCheck())//"shift"键是被按下
  1314. {
  1315. keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
  1316. m_key_shif.SetCheck(FALSE);
  1317. }
  1318. if(m_key_ctrl.GetCheck())//"ctrl"键是被按下
  1319. {
  1320. keybd_event(VK_CONTROL,0,KEYEVENTF_KEYUP,0);
  1321. m_key_ctrl.SetCheck(FALSE);
  1322. }
  1323. if(m_key_alt.GetCheck())//"alt"键是被按下
  1324. {
  1325. keybd_event(VK_MENU,0,KEYEVENTF_KEYUP,0);
  1326. m_key_alt.SetCheck(FALSE);
  1327. }
  1328. ReleaseFocus();
  1329. }
  1330. void CKeyBoardDlg::OnKeyY() 
  1331. {
  1332. ReleaseFocus();
  1333. char pChar;
  1334. pChar = 'y';
  1335. SHORT ks = VkKeyScan(pChar);
  1336. BYTE key = ks & 0xFF;
  1337. keybd_event(key,0,0,0);
  1338. keybd_event(key,0,KEYEVENTF_KEYUP,0);
  1339. if(m_key_shif.GetCheck())//"shift"键是被按下
  1340. {
  1341. keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
  1342. m_key_shif.SetCheck(FALSE);
  1343. }
  1344. if(m_key_ctrl.GetCheck())//"ctrl"键是被按下
  1345. {
  1346. keybd_event(VK_CONTROL,0,KEYEVENTF_KEYUP,0);
  1347. m_key_ctrl.SetCheck(FALSE);
  1348. }
  1349. if(m_key_alt.GetCheck())//"alt"键是被按下
  1350. {
  1351. keybd_event(VK_MENU,0,KEYEVENTF_KEYUP,0);
  1352. m_key_alt.SetCheck(FALSE);
  1353. }
  1354. ReleaseFocus();
  1355. }
  1356. void CKeyBoardDlg::OnKeyU() 
  1357. {
  1358. ReleaseFocus();
  1359. char pChar;
  1360. pChar = 'u';
  1361. SHORT ks = VkKeyScan(pChar);
  1362. BYTE key = ks & 0xFF;
  1363. keybd_event(key,0,0,0);
  1364. keybd_event(key,0,KEYEVENTF_KEYUP,0);
  1365. if(m_key_shif.GetCheck())//"shift"键是被按下
  1366. {
  1367. keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
  1368. m_key_shif.SetCheck(FALSE);
  1369. }
  1370. if(m_key_ctrl.GetCheck())//"ctrl"键是被按下
  1371. {
  1372. keybd_event(VK_CONTROL,0,KEYEVENTF_KEYUP,0);
  1373. m_key_ctrl.SetCheck(FALSE);
  1374. }
  1375. if(m_key_alt.GetCheck())//"alt"键是被按下
  1376. {
  1377. keybd_event(VK_MENU,0,KEYEVENTF_KEYUP,0);
  1378. m_key_alt.SetCheck(FALSE);
  1379. }
  1380. ReleaseFocus();
  1381. }
  1382. void CKeyBoardDlg::OnKeyI() 
  1383. {
  1384. ReleaseFocus();
  1385. char pChar;
  1386. pChar = 'i';
  1387. SHORT ks = VkKeyScan(pChar);
  1388. BYTE key = ks & 0xFF;
  1389. keybd_event(key,0,0,0);
  1390. keybd_event(key,0,KEYEVENTF_KEYUP,0);
  1391. if(m_key_shif.GetCheck())//"shift"键是被按下
  1392. {
  1393. keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
  1394. m_key_shif.SetCheck(FALSE);
  1395. }
  1396. if(m_key_ctrl.GetCheck())//"ctrl"键是被按下
  1397. {
  1398. keybd_event(VK_CONTROL,0,KEYEVENTF_KEYUP,0);
  1399. m_key_ctrl.SetCheck(FALSE);
  1400. }
  1401. if(m_key_alt.GetCheck())//"alt"键是被按下
  1402. {
  1403. keybd_event(VK_MENU,0,KEYEVENTF_KEYUP,0);
  1404. m_key_alt.SetCheck(FALSE);
  1405. }
  1406. ReleaseFocus();
  1407. }
  1408. void CKeyBoardDlg::OnKeyO() 
  1409. {
  1410. ReleaseFocus();
  1411. char pChar;
  1412. pChar = 'o';
  1413. SHORT ks = VkKeyScan(pChar);
  1414. BYTE key = ks & 0xFF;
  1415. keybd_event(key,0,0,0);
  1416. keybd_event(key,0,KEYEVENTF_KEYUP,0);
  1417. if(m_key_shif.GetCheck())//"shift"键是被按下
  1418. {
  1419. keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
  1420. m_key_shif.SetCheck(FALSE);
  1421. }
  1422. if(m_key_ctrl.GetCheck())//"ctrl"键是被按下
  1423. {
  1424. keybd_event(VK_CONTROL,0,KEYEVENTF_KEYUP,0);
  1425. m_key_ctrl.SetCheck(FALSE);
  1426. }
  1427. if(m_key_alt.GetCheck())//"alt"键是被按下
  1428. {
  1429. keybd_event(VK_MENU,0,KEYEVENTF_KEYUP,0);
  1430. m_key_alt.SetCheck(FALSE);
  1431. }
  1432. ReleaseFocus();
  1433. }
  1434. void CKeyBoardDlg::OnKeyP() 
  1435. {
  1436. ReleaseFocus();
  1437. char pChar;
  1438. pChar = 'p';
  1439. SHORT ks = VkKeyScan(pChar);
  1440. BYTE key = ks & 0xFF;
  1441. keybd_event(key,0,0,0);
  1442. keybd_event(key,0,KEYEVENTF_KEYUP,0);
  1443. if(m_key_shif.GetCheck())//"shift"键是被按下
  1444. {
  1445. keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
  1446. m_key_shif.SetCheck(FALSE);
  1447. }
  1448. if(m_key_ctrl.GetCheck())//"ctrl"键是被按下
  1449. {
  1450. keybd_event(VK_CONTROL,0,KEYEVENTF_KEYUP,0);
  1451. m_key_ctrl.SetCheck(FALSE);
  1452. }
  1453. if(m_key_alt.GetCheck())//"alt"键是被按下
  1454. {
  1455. keybd_event(VK_MENU,0,KEYEVENTF_KEYUP,0);
  1456. m_key_alt.SetCheck(FALSE);
  1457. }
  1458. ReleaseFocus();
  1459. }
  1460. void CKeyBoardDlg::OnKeyP1() 
  1461. {
  1462. ReleaseFocus();
  1463. char pChar;
  1464. pChar = '[';
  1465. SHORT ks = VkKeyScan(pChar);
  1466. BYTE key = ks & 0xFF;
  1467. keybd_event(key,0,0,0);
  1468. keybd_event(key,0,KEYEVENTF_KEYUP,0);
  1469. if(m_key_shif.GetCheck())//"shift"键是被按下
  1470. {
  1471. keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
  1472. m_key_shif.SetCheck(FALSE);
  1473. }
  1474. ReleaseFocus();
  1475. }
  1476. void CKeyBoardDlg::OnKeyP2() 
  1477. {
  1478. ReleaseFocus();
  1479. char pChar;
  1480. pChar = ']';
  1481. SHORT ks = VkKeyScan(pChar);
  1482. BYTE key = ks & 0xFF;
  1483. keybd_event(key,0,0,0);
  1484. keybd_event(key,0,KEYEVENTF_KEYUP,0);
  1485. if(m_key_shif.GetCheck())//"shift"键是被按下
  1486. {
  1487. keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
  1488. m_key_shif.SetCheck(FALSE);
  1489. }
  1490. ReleaseFocus();
  1491. }
  1492. void CKeyBoardDlg::OnKeyCaps() 
  1493. {
  1494. ReleaseFocus();
  1495. keybd_event(VK_CAPITAL,0,0,0);
  1496. keybd_event(VK_CAPITAL,0,KEYEVENTF_KEYUP,0);
  1497. ReleaseFocus();
  1498. }
  1499. void CKeyBoardDlg::OnKeyA() 
  1500. {
  1501. ReleaseFocus();
  1502. char pChar;
  1503. pChar = 'a';
  1504. SHORT ks = VkKeyScan(pChar);
  1505. BYTE key = ks & 0xFF;
  1506. keybd_event(key,0,0,0);
  1507. keybd_event(key,0,KEYEVENTF_KEYUP,0);
  1508. if(m_key_shif.GetCheck())//"shift"键是被按下
  1509. {
  1510. keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
  1511. m_key_shif.SetCheck(FALSE);
  1512. }
  1513. if(m_key_ctrl.GetCheck())//"ctrl"键是被按下
  1514. {
  1515. keybd_event(VK_CONTROL,0,KEYEVENTF_KEYUP,0);
  1516. m_key_ctrl.SetCheck(FALSE);
  1517. }
  1518. if(m_key_alt.GetCheck())//"alt"键是被按下
  1519. {
  1520. keybd_event(VK_MENU,0,KEYEVENTF_KEYUP,0);
  1521. m_key_alt.SetCheck(FALSE);
  1522. }
  1523. ReleaseFocus();
  1524. }
  1525. void CKeyBoardDlg::OnKeyS() 
  1526. {
  1527. ReleaseFocus();
  1528. char pChar;
  1529. pChar = 's';
  1530. SHORT ks = VkKeyScan(pChar);
  1531. BYTE key = ks & 0xFF;
  1532. keybd_event(key,0,0,0);
  1533. keybd_event(key,0,KEYEVENTF_KEYUP,0);
  1534. if(m_key_shif.GetCheck())//"shift"键是被按下
  1535. {
  1536. keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
  1537. m_key_shif.SetCheck(FALSE);
  1538. }
  1539. if(m_key_ctrl.GetCheck())//"ctrl"键是被按下
  1540. {
  1541. keybd_event(VK_CONTROL,0,KEYEVENTF_KEYUP,0);
  1542. m_key_ctrl.SetCheck(FALSE);
  1543. }
  1544. if(m_key_alt.GetCheck())//"alt"键是被按下
  1545. {
  1546. keybd_event(VK_MENU,0,KEYEVENTF_KEYUP,0);
  1547. m_key_alt.SetCheck(FALSE);
  1548. }
  1549. ReleaseFocus();
  1550. }
  1551. void CKeyBoardDlg::OnKeyD() 
  1552. {
  1553. ReleaseFocus();
  1554. char pChar;
  1555. pChar = 'd';
  1556. SHORT ks = VkKeyScan(pChar);
  1557. BYTE key = ks & 0xFF;
  1558. keybd_event(key,0,0,0);
  1559. keybd_event(key,0,KEYEVENTF_KEYUP,0);
  1560. if(m_key_shif.GetCheck())//"shift"键是被按下
  1561. {
  1562. keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
  1563. m_key_shif.SetCheck(FALSE);
  1564. }
  1565. if(m_key_ctrl.GetCheck())//"ctrl"键是被按下
  1566. {
  1567. keybd_event(VK_CONTROL,0,KEYEVENTF_KEYUP,0);
  1568. m_key_ctrl.SetCheck(FALSE);
  1569. }
  1570. if(m_key_alt.GetCheck())//"alt"键是被按下
  1571. {
  1572. keybd_event(VK_MENU,0,KEYEVENTF_KEYUP,0);
  1573. m_key_alt.SetCheck(FALSE);
  1574. }
  1575. ReleaseFocus();
  1576. }
  1577. void CKeyBoardDlg::OnKeyF() 
  1578. {
  1579. ReleaseFocus();
  1580. char pChar;
  1581. pChar = 'f';
  1582. SHORT ks = VkKeyScan(pChar);
  1583. BYTE key = ks & 0xFF;
  1584. keybd_event(key,0,0,0);
  1585. keybd_event(key,0,KEYEVENTF_KEYUP,0);
  1586. if(m_key_shif.GetCheck())//"shift"键是被按下
  1587. {
  1588. keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
  1589. m_key_shif.SetCheck(FALSE);
  1590. }
  1591. if(m_key_ctrl.GetCheck())//"ctrl"键是被按下
  1592. {
  1593. keybd_event(VK_CONTROL,0,KEYEVENTF_KEYUP,0);
  1594. m_key_ctrl.SetCheck(FALSE);
  1595. }
  1596. if(m_key_alt.GetCheck())//"alt"键是被按下
  1597. {
  1598. keybd_event(VK_MENU,0,KEYEVENTF_KEYUP,0);
  1599. m_key_alt.SetCheck(FALSE);
  1600. }
  1601. ReleaseFocus();
  1602. }
  1603. void CKeyBoardDlg::OnKeyG() 
  1604. {
  1605. ReleaseFocus();
  1606. char pChar;
  1607. pChar = 'g';
  1608. SHORT ks = VkKeyScan(pChar);
  1609. BYTE key = ks & 0xFF;
  1610. keybd_event(key,0,0,0);
  1611. keybd_event(key,0,KEYEVENTF_KEYUP,0);
  1612. if(m_key_shif.GetCheck())//"shift"键是被按下
  1613. {
  1614. keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
  1615. m_key_shif.SetCheck(FALSE);
  1616. }
  1617. if(m_key_ctrl.GetCheck())//"ctrl"键是被按下
  1618. {
  1619. keybd_event(VK_CONTROL,0,KEYEVENTF_KEYUP,0);
  1620. m_key_ctrl.SetCheck(FALSE);
  1621. }
  1622. if(m_key_alt.GetCheck())//"alt"键是被按下
  1623. {
  1624. keybd_event(VK_MENU,0,KEYEVENTF_KEYUP,0);
  1625. m_key_alt.SetCheck(FALSE);
  1626. }
  1627. ReleaseFocus();
  1628. }
  1629. void CKeyBoardDlg::OnKeyH() 
  1630. {
  1631. ReleaseFocus();
  1632. char pChar;
  1633. pChar = 'h';
  1634. SHORT ks = VkKeyScan(pChar);
  1635. BYTE key = ks & 0xFF;
  1636. keybd_event(key,0,0,0);
  1637. keybd_event(key,0,KEYEVENTF_KEYUP,0);
  1638. if(m_key_shif.GetCheck())//"shift"键是被按下
  1639. {
  1640. keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
  1641. m_key_shif.SetCheck(FALSE);
  1642. }
  1643. if(m_key_ctrl.GetCheck())//"ctrl"键是被按下
  1644. {
  1645. keybd_event(VK_CONTROL,0,KEYEVENTF_KEYUP,0);
  1646. m_key_ctrl.SetCheck(FALSE);
  1647. }
  1648. if(m_key_alt.GetCheck())//"alt"键是被按下
  1649. {
  1650. keybd_event(VK_MENU,0,KEYEVENTF_KEYUP,0);
  1651. m_key_alt.SetCheck(FALSE);
  1652. }
  1653. ReleaseFocus();
  1654. }
  1655. void CKeyBoardDlg::OnKeyJ() 
  1656. {
  1657. ReleaseFocus();
  1658. char pChar;
  1659. pChar = 'j';
  1660. SHORT ks = VkKeyScan(pChar);
  1661. BYTE key = ks & 0xFF;
  1662. keybd_event(key,0,0,0);
  1663. keybd_event(key,0,KEYEVENTF_KEYUP,0);
  1664. if(m_key_shif.GetCheck())//"shift"键是被按下
  1665. {
  1666. keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
  1667. m_key_shif.SetCheck(FALSE);
  1668. }
  1669. if(m_key_ctrl.GetCheck())//"ctrl"键是被按下
  1670. {
  1671. keybd_event(VK_CONTROL,0,KEYEVENTF_KEYUP,0);
  1672. m_key_ctrl.SetCheck(FALSE);
  1673. }
  1674. if(m_key_alt.GetCheck())//"alt"键是被按下
  1675. {
  1676. keybd_event(VK_MENU,0,KEYEVENTF_KEYUP,0);
  1677. m_key_alt.SetCheck(FALSE);
  1678. }
  1679. ReleaseFocus();
  1680. }
  1681. void CKeyBoardDlg::OnKeyK() 
  1682. {
  1683. ReleaseFocus();
  1684. char pChar;
  1685. pChar = 'k';
  1686. SHORT ks = VkKeyScan(pChar);
  1687. BYTE key = ks & 0xFF;
  1688. keybd_event(key,0,0,0);
  1689. keybd_event(key,0,KEYEVENTF_KEYUP,0);
  1690. if(m_key_shif.GetCheck())//"shift"键是被按下
  1691. {
  1692. keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
  1693. m_key_shif.SetCheck(FALSE);
  1694. }
  1695. if(m_key_ctrl.GetCheck())//"ctrl"键是被按下
  1696. {
  1697. keybd_event(VK_CONTROL,0,KEYEVENTF_KEYUP,0);
  1698. m_key_ctrl.SetCheck(FALSE);
  1699. }
  1700. if(m_key_alt.GetCheck())//"alt"键是被按下
  1701. {
  1702. keybd_event(VK_MENU,0,KEYEVENTF_KEYUP,0);
  1703. m_key_alt.SetCheck(FALSE);
  1704. }
  1705. ReleaseFocus();
  1706. }
  1707. void CKeyBoardDlg::OnKeyL() 
  1708. {
  1709. ReleaseFocus();
  1710. char pChar;
  1711. pChar = 'l';
  1712. SHORT ks = VkKeyScan(pChar);
  1713. BYTE key = ks & 0xFF;
  1714. keybd_event(key,0,0,0);
  1715. keybd_event(key,0,KEYEVENTF_KEYUP,0);
  1716. if(m_key_shif.GetCheck())//"shift"键是被按下
  1717. {
  1718. keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
  1719. m_key_shif.SetCheck(FALSE);
  1720. }
  1721. if(m_key_ctrl.GetCheck())//"ctrl"键是被按下
  1722. {
  1723. keybd_event(VK_CONTROL,0,KEYEVENTF_KEYUP,0);
  1724. m_key_ctrl.SetCheck(FALSE);
  1725. }
  1726. if(m_key_alt.GetCheck())//"alt"键是被按下
  1727. {
  1728. keybd_event(VK_MENU,0,KEYEVENTF_KEYUP,0);
  1729. m_key_alt.SetCheck(FALSE);
  1730. }
  1731. ReleaseFocus();
  1732. }
  1733. void CKeyBoardDlg::OnKeyL1() 
  1734. {
  1735. ReleaseFocus();
  1736. char pChar;
  1737. pChar = ';';
  1738. SHORT ks = VkKeyScan(pChar);
  1739. BYTE key = ks & 0xFF;
  1740. keybd_event(key,0,0,0);
  1741. keybd_event(key,0,KEYEVENTF_KEYUP,0);
  1742. if(m_key_shif.GetCheck())//"shift"键是被按下
  1743. {
  1744. keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
  1745. m_key_shif.SetCheck(FALSE);
  1746. }
  1747. ReleaseFocus();
  1748. }
  1749. void CKeyBoardDlg::OnKeyL2() 
  1750. {
  1751. ReleaseFocus();
  1752. char pChar;
  1753. pChar = ''';
  1754. SHORT ks = VkKeyScan(pChar);
  1755. BYTE key = ks & 0xFF;
  1756. keybd_event(key,0,0,0);
  1757. keybd_event(key,0,KEYEVENTF_KEYUP,0);
  1758. if(m_key_shif.GetCheck())//"shift"键是被按下
  1759. {
  1760. keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
  1761. m_key_shif.SetCheck(FALSE);
  1762. }
  1763. ReleaseFocus();
  1764. }
  1765. void CKeyBoardDlg::OnKeyZ() 
  1766. {
  1767. ReleaseFocus();
  1768. char pChar;
  1769. pChar = 'z';
  1770. SHORT ks = VkKeyScan(pChar);
  1771. BYTE key = ks & 0xFF;
  1772. keybd_event(key,0,0,0);
  1773. keybd_event(key,0,KEYEVENTF_KEYUP,0);
  1774. if(m_key_shif.GetCheck())//"shift"键是被按下
  1775. {
  1776. keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
  1777. m_key_shif.SetCheck(FALSE);
  1778. }
  1779. if(m_key_ctrl.GetCheck())//"ctrl"键是被按下
  1780. {
  1781. keybd_event(VK_CONTROL,0,KEYEVENTF_KEYUP,0);
  1782. m_key_ctrl.SetCheck(FALSE);
  1783. }
  1784. if(m_key_alt.GetCheck())//"alt"键是被按下
  1785. {
  1786. keybd_event(VK_MENU,0,KEYEVENTF_KEYUP,0);
  1787. m_key_alt.SetCheck(FALSE);
  1788. }
  1789. ReleaseFocus();
  1790. }
  1791. void CKeyBoardDlg::OnKeyX() 
  1792. {
  1793. ReleaseFocus();
  1794. char pChar;
  1795. pChar = 'x';
  1796. SHORT ks = VkKeyScan(pChar);
  1797. BYTE key = ks & 0xFF;
  1798. keybd_event(key,0,0,0);
  1799. keybd_event(key,0,KEYEVENTF_KEYUP,0);
  1800. if(m_key_shif.GetCheck())//"shift"键是被按下
  1801. {
  1802. keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
  1803. m_key_shif.SetCheck(FALSE);
  1804. }
  1805. if(m_key_ctrl.GetCheck())//"ctrl"键是被按下
  1806. {
  1807. keybd_event(VK_CONTROL,0,KEYEVENTF_KEYUP,0);
  1808. m_key_ctrl.SetCheck(FALSE);
  1809. }
  1810. if(m_key_alt.GetCheck())//"alt"键是被按下
  1811. {
  1812. keybd_event(VK_MENU,0,KEYEVENTF_KEYUP,0);
  1813. m_key_alt.SetCheck(FALSE);
  1814. }
  1815. ReleaseFocus();
  1816. }
  1817. void CKeyBoardDlg::OnKeyC() 
  1818. {
  1819. ReleaseFocus();
  1820. char pChar;
  1821. pChar = 'c';
  1822. SHORT ks = VkKeyScan(pChar);
  1823. BYTE key = ks & 0xFF;
  1824. keybd_event(key,0,0,0);
  1825. keybd_event(key,0,KEYEVENTF_KEYUP,0);
  1826. if(m_key_shif.GetCheck())//"shift"键是被按下
  1827. {
  1828. keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
  1829. m_key_shif.SetCheck(FALSE);
  1830. }
  1831. if(m_key_ctrl.GetCheck())//"ctrl"键是被按下
  1832. {
  1833. keybd_event(VK_CONTROL,0,KEYEVENTF_KEYUP,0);
  1834. m_key_ctrl.SetCheck(FALSE);
  1835. }
  1836. if(m_key_alt.GetCheck())//"alt"键是被按下
  1837. {
  1838. keybd_event(VK_MENU,0,KEYEVENTF_KEYUP,0);
  1839. m_key_alt.SetCheck(FALSE);
  1840. }
  1841. ReleaseFocus();
  1842. }
  1843. void CKeyBoardDlg::OnKeyV() 
  1844. {
  1845. ReleaseFocus();
  1846. char pChar;
  1847. pChar = 'v';
  1848. SHORT ks = VkKeyScan(pChar);
  1849. BYTE key = ks & 0xFF;
  1850. keybd_event(key,0,0,0);
  1851. keybd_event(key,0,KEYEVENTF_KEYUP,0);
  1852. if(m_key_shif.GetCheck())//"shift"键是被按下
  1853. {
  1854. keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
  1855. m_key_shif.SetCheck(FALSE);
  1856. }
  1857. if(m_key_ctrl.GetCheck())//"ctrl"键是被按下
  1858. {
  1859. keybd_event(VK_CONTROL,0,KEYEVENTF_KEYUP,0);
  1860. m_key_ctrl.SetCheck(FALSE);
  1861. }
  1862. if(m_key_alt.GetCheck())//"alt"键是被按下
  1863. {
  1864. keybd_event(VK_MENU,0,KEYEVENTF_KEYUP,0);
  1865. m_key_alt.SetCheck(FALSE);
  1866. }
  1867. ReleaseFocus();
  1868. }
  1869. void CKeyBoardDlg::OnKeyB() 
  1870. {
  1871. ReleaseFocus();
  1872. char pChar;
  1873. pChar = 'b';
  1874. SHORT ks = VkKeyScan(pChar);
  1875. BYTE key = ks & 0xFF;
  1876. keybd_event(key,0,0,0);
  1877. keybd_event(key,0,KEYEVENTF_KEYUP,0);
  1878. if(m_key_shif.GetCheck())//"shift"键是被按下
  1879. {
  1880. keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
  1881. m_key_shif.SetCheck(FALSE);
  1882. }
  1883. if(m_key_ctrl.GetCheck())//"ctrl"键是被按下
  1884. {
  1885. keybd_event(VK_CONTROL,0,KEYEVENTF_KEYUP,0);
  1886. m_key_ctrl.SetCheck(FALSE);
  1887. }
  1888. if(m_key_alt.GetCheck())//"alt"键是被按下
  1889. {
  1890. keybd_event(VK_MENU,0,KEYEVENTF_KEYUP,0);
  1891. m_key_alt.SetCheck(FALSE);
  1892. }
  1893. ReleaseFocus();
  1894. }
  1895. void CKeyBoardDlg::OnKeyN() 
  1896. {
  1897. ReleaseFocus();
  1898. char pChar;
  1899. pChar = 'n';
  1900. SHORT ks = VkKeyScan(pChar);
  1901. BYTE key = ks & 0xFF;
  1902. keybd_event(key,0,0,0);
  1903. keybd_event(key,0,KEYEVENTF_KEYUP,0);
  1904. if(m_key_shif.GetCheck())//"shift"键是被按下
  1905. {
  1906. keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
  1907. m_key_shif.SetCheck(FALSE);
  1908. }
  1909. if(m_key_ctrl.GetCheck())//"ctrl"键是被按下
  1910. {
  1911. keybd_event(VK_CONTROL,0,KEYEVENTF_KEYUP,0);
  1912. m_key_ctrl.SetCheck(FALSE);
  1913. }
  1914. if(m_key_alt.GetCheck())//"alt"键是被按下
  1915. {
  1916. keybd_event(VK_MENU,0,KEYEVENTF_KEYUP,0);
  1917. m_key_alt.SetCheck(FALSE);
  1918. }
  1919. ReleaseFocus();
  1920. }
  1921. void CKeyBoardDlg::OnKeyM() 
  1922. {
  1923. ReleaseFocus();
  1924. char pChar;
  1925. pChar = 'm';
  1926. SHORT ks = VkKeyScan(pChar);
  1927. BYTE key = ks & 0xFF;
  1928. keybd_event(key,0,0,0);
  1929. keybd_event(key,0,KEYEVENTF_KEYUP,0);
  1930. if(m_key_shif.GetCheck())//"shift"键是被按下
  1931. {
  1932. keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
  1933. m_key_shif.SetCheck(FALSE);
  1934. }
  1935. if(m_key_ctrl.GetCheck())//"ctrl"键是被按下
  1936. {
  1937. keybd_event(VK_CONTROL,0,KEYEVENTF_KEYUP,0);
  1938. m_key_ctrl.SetCheck(FALSE);
  1939. }
  1940. if(m_key_alt.GetCheck())//"alt"键是被按下
  1941. {
  1942. keybd_event(VK_MENU,0,KEYEVENTF_KEYUP,0);
  1943. m_key_alt.SetCheck(FALSE);
  1944. }
  1945. ReleaseFocus();
  1946. }
  1947. void CKeyBoardDlg::OnKeyM1() 
  1948. {
  1949. ReleaseFocus();
  1950. char pChar;
  1951. pChar = ',';
  1952. SHORT ks = VkKeyScan(pChar);
  1953. BYTE key = ks & 0xFF;
  1954. keybd_event(key,0,0,0);
  1955. keybd_event(key,0,KEYEVENTF_KEYUP,0);
  1956. if(m_key_shif.GetCheck())//"shift"键是被按下
  1957. {
  1958. keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
  1959. m_key_shif.SetCheck(FALSE);
  1960. }
  1961. ReleaseFocus();
  1962. }
  1963. void CKeyBoardDlg::OnKeyM2() 
  1964. {
  1965. ReleaseFocus();
  1966. char pChar;
  1967. pChar = '.';
  1968. SHORT ks = VkKeyScan(pChar);
  1969. BYTE key = ks & 0xFF;
  1970. keybd_event(key,0,0,0);
  1971. keybd_event(key,0,KEYEVENTF_KEYUP,0);
  1972. if(m_key_shif.GetCheck())//"shift"键是被按下
  1973. {
  1974. keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
  1975. m_key_shif.SetCheck(FALSE);
  1976. }
  1977. ReleaseFocus();
  1978. }
  1979. void CKeyBoardDlg::OnKeyM3() 
  1980. {
  1981. ReleaseFocus();
  1982. char pChar;
  1983. pChar = '/';
  1984. SHORT ks = VkKeyScan(pChar);
  1985. BYTE key = ks & 0xFF;
  1986. keybd_event(key,0,0,0);
  1987. keybd_event(key,0,KEYEVENTF_KEYUP,0);
  1988. if(m_key_shif.GetCheck())//"shift"键是被按下
  1989. {
  1990. keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
  1991. m_key_shif.SetCheck(FALSE);
  1992. }
  1993. ReleaseFocus();
  1994. }
  1995. void CKeyBoardDlg::OnKeyWnd() 
  1996. {
  1997. ReleaseFocus();
  1998. keybd_event(VK_LWIN,0,0,0);
  1999. keybd_event(VK_LWIN,0,KEYEVENTF_KEYUP,0);
  2000. ReleaseFocus();
  2001. }
  2002. void CKeyBoardDlg::OnKeyMenu() 
  2003. {
  2004. ReleaseFocus();
  2005. keybd_event(VK_APPS,0,0,0);
  2006. keybd_event(VK_APPS,0,KEYEVENTF_KEYUP,0);
  2007. ReleaseFocus();
  2008. }
  2009. void CKeyBoardDlg::OnKeyTop() 
  2010. {
  2011. ReleaseFocus();
  2012. keybd_event(VK_UP,0,0,0);
  2013. keybd_event(VK_UP,0,KEYEVENTF_KEYUP,0);
  2014. ReleaseFocus();
  2015. }
  2016. void CKeyBoardDlg::OnKeyBotton() 
  2017. {
  2018. ReleaseFocus();
  2019. keybd_event(VK_DOWN,0,0,0);
  2020. keybd_event(VK_DOWN,0,KEYEVENTF_KEYUP,0);
  2021. ReleaseFocus();
  2022. }
  2023. void CKeyBoardDlg::OnKeyLeft() 
  2024. {
  2025. ReleaseFocus();
  2026. keybd_event(VK_LEFT,0,0,0);
  2027. keybd_event(VK_LEFT,0,KEYEVENTF_KEYUP,0);
  2028. ReleaseFocus();
  2029. }
  2030. void CKeyBoardDlg::OnKeyRight() 
  2031. {
  2032. ReleaseFocus();
  2033. keybd_event(VK_RIGHT,0,0,0);
  2034. keybd_event(VK_RIGHT,0,KEYEVENTF_KEYUP,0);
  2035. ReleaseFocus();
  2036. }
  2037. void CKeyBoardDlg::OnKeySpace() 
  2038. {
  2039. ReleaseFocus();
  2040. keybd_event(VK_SPACE,0,0,0);
  2041. keybd_event(VK_SPACE,0,KEYEVENTF_KEYUP,0);
  2042. ReleaseFocus();
  2043. }
  2044. void CKeyBoardDlg::OnKeyEnter() 
  2045. {
  2046. ReleaseFocus();
  2047. keybd_event(VkKeyScan(0x0D) & 0xFF,0,0,0);
  2048. keybd_event(VkKeyScan(0x0D) & 0xFF,0,KEYEVENTF_KEYUP,0);
  2049. ReleaseFocus();
  2050. }
  2051. void CKeyBoardDlg::OnKeyPs() 
  2052. {
  2053. ReleaseFocus();
  2054. keybd_event(VK_SNAPSHOT,0,0,0);
  2055. keybd_event(VK_SNAPSHOT,0,KEYEVENTF_KEYUP,0);
  2056. ReleaseFocus();
  2057. }
  2058. void CKeyBoardDlg::OnKeyShif() 
  2059. {
  2060. ReleaseFocus();
  2061. if (m_key_shif.GetCheck())
  2062. {
  2063. keybd_event(VK_SHIFT,0,0,0);
  2064. }
  2065. else
  2066. {
  2067. keybd_event(VK_SHIFT,0,KEYEVENTF_KEYUP,0);
  2068. }
  2069. ReleaseFocus();
  2070. }
  2071. void CKeyBoardDlg::OnKeyCtrl() 
  2072. {
  2073. ReleaseFocus();
  2074. if (m_key_ctrl.GetCheck())
  2075. {
  2076. keybd_event(VK_CONTROL,0,0,0);
  2077. }
  2078. else
  2079. {
  2080. keybd_event(VK_CONTROL,0,KEYEVENTF_KEYUP,0);
  2081. }
  2082. ReleaseFocus();
  2083. }
  2084. void CKeyBoardDlg::OnKeyAlt() 
  2085. {
  2086. ReleaseFocus();
  2087. if (m_key_alt.GetCheck())
  2088. {
  2089. keybd_event(VK_MENU,0,0,0);
  2090. }
  2091. else
  2092. {
  2093. keybd_event(VK_MENU,0,KEYEVENTF_KEYUP,0);
  2094. }
  2095. ReleaseFocus();
  2096. }