window programming --keybord.txt

          1 Keyboardd Basics
          ?1) Ignoring the Keyboard
          ?Your programm does not need to act on every keyboard message it received,Window handle many keyboard message function itself.
          ?2)Who's Got thefocus
          ? Though the keyboard is shared by all the window in the application ,The DispatchMessage send the message to the window procedure associated the window which message is intended.
          ? The window that receives a particular keyboard event is the window has the input foucs.
          ? Sometime no window has input foucs,this is the case if all your programs have been minmized,window continue send keyboard to the active window ,but it is send in the deffert form from sending to the input foucs.
          ? A window procedure can be determine when its window has the input focus by trapping WM_SETFOCUS and WM_KILLFOCUS.
          ?3) Queues and Synchronization
          ? As the user presses and releases key on keyborad,Windows and keyboard device driver translate the hardware scan code into formatted message.Howerver the messages are not palced on the application queue right away,Instean Windows store these message in a system message queue .The System message queue is a single message maintained by windows specifically for the prelimary storage of user input from keyboard and the mouse. Window will take the next message from the system message queue and place it on the application message queue only when a window application has finished proecssing the previous user input message.
          4) Keystorkes and Character
          ?The message that an application receives from windows about keyboard events distingush between keystrokes and characters.
          ?for instance The keysokes has only one key labbed 'A' ,and the character may be 'a' or 'ctr-a' etc.
          2 Keystroke Message
          ?1)Wirtual key Codes
          ? The virtual key code is stored in the wParam parameter of WM_KEYDOWN,WM_KEYUP,the code identifies the key being pressed or release.
          ? 2)lParam Information
          ? the wParam message parameter contain virtual key code and the lparam message parameter contains other information in understanding the keystoke.
          ? 3) Shift States
          ? iState = GetKeyState (VK_SHIFT) ;
          ? iState variable will be negative if the Shift key is donw
          ? iState = GetKeyState (VK_CAPITAL) ;
          ? 4)Using Keystroke Messages
          ???
          ? 5)
          ?? case WM_KEYDOWN:
          ???? switch (wParam)
          ???? {
          ???? case VK_HOME:
          ????????? SendMessage (hwnd, WM_VSCROLL, SB_TOP, 0) ;
          ????????? break ;

          ???? case VK_END:
          ????????? SendMessage (hwnd, WM_VSCROLL, SB_BOTTOM, 0) ;
          ????????? break ;

          ???? case VK_PRIOR:
          ????????? SendMessage (hwnd, WM_VSCROLL, SB_PAGEUP, 0) ;
          ????????? break ;
          3 Character Messages
          Message Key or Code
          WM_KEYDOWN Virtual key code for `A' (0x41)
          WM_CHAR Character code for `a' (0x61)
          WM_KEYUP Virtual key code for `A' (0x41)

          Message Key or Code
          WM_KEYDOWN Virtual key code VK_SHIFT (0x10)
          WM_KEYDOWN Virtual key code for `A' (0x41)
          WM_CHAR Character code for `A' (0x41)
          WM_KEYUP Virtual key code for `A' (0x41)
          WM_KEYUP Virtual key code VK_SHIFT (0x10)

          Key Character Code Duplicated by ANSI C? Escape
          Backspace???? 0x08 Ctrl-H??????????????? \b
          Tab?????????? 0x09 Ctrl-I??????????????? \t
          Ctrl-Enter??? 0x0A Ctrl-J??????????????? \n
          Enter???????? 0x0D Ctrl-M???????????????? \r
          Esc 0x1B Ctrl-[

          ? case WM_CHAR:
          ???? [other program lines]
          ???? switch (wParam)
          ???? {
          ???? case `\b':????????? // backspace
          ????????? [other program line
          ????????? break ;
          ???? case `\t':????????? // tab
          ????????? [other program lines]
          ????????? break ;

          ???? case `\n':????????? // linefeed
          ????????? [other program lines]
          ????????? break ;

          ???? case `\r':????????? // carriage return
          ????????? [other program lines]
          ????????? break ;

          ???? default:??????????? // character codes
          ????????? [other program lines]
          ????????? break ;
          ???? }
          ???? return 0 ;

          posted on 2006-09-19 18:25 康文 閱讀(295) 評(píng)論(0)  編輯  收藏 所屬分類(lèi): c\c++

          <2006年9月>
          272829303112
          3456789
          10111213141516
          17181920212223
          24252627282930
          1234567

          導(dǎo)航

          統(tǒng)計(jì)

          常用鏈接

          留言簿(1)

          隨筆分類(lèi)

          隨筆檔案

          文章檔案

          搜索

          最新評(píng)論

          閱讀排行榜

          評(píng)論排行榜

          主站蜘蛛池模板: 金秀| 前郭尔| 新蔡县| 湘潭县| 荥阳市| 阿拉善左旗| 兴城市| 合山市| 德令哈市| 商河县| 扶沟县| 皮山县| 卓资县| 七台河市| 公主岭市| 涞水县| 长岭县| 宣武区| 怀柔区| 库尔勒市| 娱乐| 仁布县| 临武县| 乐亭县| 黑水县| 砀山县| 板桥市| 沙雅县| 布拖县| 扬州市| 彝良县| 双鸭山市| 襄樊市| 正镶白旗| 商河县| 广南县| 时尚| 句容市| 郎溪县| 浮梁县| 开封市|