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

          導航

          統計

          常用鏈接

          留言簿(1)

          隨筆分類

          隨筆檔案

          文章檔案

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 启东市| 蒙阴县| 郎溪县| 呼玛县| 察雅县| 平罗县| 蒲城县| 澳门| 黎城县| 开远市| 景东| 安泽县| 金昌市| 江永县| 大冶市| 高碑店市| 津南区| 长沙县| 淮北市| 昌宁县| 寻乌县| 通海县| 泗阳县| 新丰县| 苗栗市| 武乡县| 马鞍山市| 溆浦县| 喜德县| 黄龙县| 澜沧| 铜山县| 海宁市| 开平市| 中超| 宜丰县| 湘乡市| 温州市| 巴林左旗| 南皮县| 顺义区|