MyEdit.h
上传用户:royluo
上传日期:2007-01-05
资源大小:1584k
文件大小:3k
源码类别:

游戏

开发平台:

Visual C++

  1. /*****************************************************************************
  2. *                                                                             
  3. *   MyEdit.h
  4. *                                                                             
  5. *   Electrical Engineering Faculty - Software Lab                             
  6. *   Spring semester 1998                                                      
  7. *                                                                             
  8. *   Tanks game                                                                
  9. *                                                                             
  10. *   Module description: Implements edit box control that handles all keyboard
  11. *                       inputs (for the keyboard mapping dialog).
  12. *                       
  13. *                                                                             
  14. *   Authors: Eran Yariv - 28484475                                           
  15. *            Moshe Zur  - 24070856                                           
  16. *                                                                            
  17. *                                                                            
  18. *   Date: 23/09/98                                                           
  19. *                                                                            
  20. ******************************************************************************/
  21. #ifndef _MYEDIT_H_
  22. #define _MYEDIT_H_
  23. #include <KeysTable.h>
  24. class CMyEdit : public CEdit
  25. {
  26. public:
  27.     CMyEdit::CMyEdit (CKeysTable* pKeys, int ind) : 
  28.       CEdit(), m_pKeys(pKeys), m_iIndex(ind)
  29.     {
  30.         ASSERT( pKeys );  // Dialog must receive a valid key table
  31.         ASSERT( SetKeyName (pKeys->GetKey(ind)) );  // Make sure key table isn't corrupted:
  32.                                                     // the key must be a legitimate one
  33.     }
  34.     
  35.     BOOL PreTranslateMessage(MSG* pMsg);    // We overload this function to take care of
  36.                                             // all keys passed to CEdit
  37.     void UpdateText ()  // Synchronize string with keytable, and update control's caption
  38.     {
  39.             // Assert that key code in table is allways legitimate:
  40.         ASSERT( SetKeyName (m_pKeys->GetKey(m_iIndex)) );
  41.         SetWindowText( m_cstrKeyName);
  42.     }
  43. private:
  44.     // Methods
  45.     BOOL SetKeyName (UINT nKey);
  46.     // Members
  47.     CString     m_cstrKeyName;  // Temp place to hold the key's name as appears to user
  48.     CKeysTable* m_pKeys;        // Points to the current key table being configured
  49.     int         m_iIndex;       // Holds the index in the keys' table corresponding 
  50.                                 //  with the control
  51. };
  52. #endif