荔园在线

荔园之美,在春之萌芽,在夏之绽放,在秋之收获,在冬之沉淀

[回到开始] [上一篇][下一篇]


发信人: Deny (Deny), 信区: Visual
标  题: [转载] 如何设置CAPS LOCK,SCROLL LOCK,NUM LOCk cudo (转寄)
发信站: BBS 荔园晨风站 (Sat Dec 23 22:12:28 2000), 转信

【 以下文字转载自 Deny 的信箱 】
【 原文由 denick.bbs@smth.org 所发表 】
发信人: sparrow (the end), 信区: VisualC
标  题: 如何设置CAPS LOCK,SCROLL LOCK,NUM LOCk的状态
发信站: BBS 水木清华站 (Sun Sep 24 03:19:51 2000)

MORE INFORMATION
The following sample code demonstrates how to change the state of any
key on all platforms. Simply pass the virtual key code (VK_CAPITAL,
VK_NUMLOCK or VK_SCROLL) and a flag to set or reset the key state to the
 PostVirtualKeyEvent:


Sample Code

   #include <windows.h>

   #define MAKEWORD(low, high)   ((WORD)(((BYTE)(low)) | \
                                 (((WORD)((BYTE)(high))) << 8)))

   void FAR PASCAL Keybd_Event(void);

   void FAR PASCAL PostVirtualKey(  BYTE bVirtualKey,
                                    BOOL fKeyUp)
   {
   WORD wARegister, wBRegister;

   // Convert the virtual-key code to the scan code
   BRegister = MAKEWORD((BYTE) MapVirtualKey(bVirtualKey, 0), 0);
   ARegister = MAKEWORD(bVirtualKey, (fKeyUp ? 0x80 : 0x00));
   _asm mov bx, wBRegister;   // BH = 0 (No prefix)
   _asm mov ax, wARegister;
   Keybd_Event();
   }

   int PASCAL WinMain(  HINSTANCE hInst,
                        HINSTANCE hPrevInst,
                        LPSTR szCmdLine,
                        int nCmdShow)
   {
   // Toggle the caps lock key
   PostVirtualKey(VK_CAPITAL, FALSE);
   PostVirtualKey(VK_CAPITAL, TRUE);

   return 0;
   }

--

※ 来源:·BBS 水木清华站 smth.org·[FROM: 166.111.161.47]
--
※ 转载:·BBS 荔园晨风站 bbs.szu.edu.cn·[FROM: 192.168.1.119]


[回到开始] [上一篇][下一篇]

荔园在线首页 友情链接:深圳大学 深大招生 荔园晨风BBS S-Term软件 网络书店