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 康文 閱讀(288) 評論(0)  編輯  收藏 所屬分類: c\c++

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

          導(dǎo)航

          統(tǒng)計

          常用鏈接

          留言簿(1)

          隨筆分類

          隨筆檔案

          文章檔案

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 庆城县| 阿勒泰市| 玉溪市| 嵩明县| 宁德市| 临潭县| 大连市| 阿尔山市| 宿迁市| 通化市| 墨江| 武山县| 神木县| 平顶山市| 华安县| 临城县| 唐海县| 邵阳县| 文成县| 宁南县| 长乐市| 云浮市| 象山县| 越西县| 巨鹿县| 五大连池市| 碌曲县| 嘉荫县| 云梦县| 仪陇县| 和政县| 大安市| 缙云县| 鹰潭市| 新余市| 周宁县| 明星| 岚皋县| 临沂市| 福安市| 财经|