Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

132 lines
3.7 KiB

  1. #ifndef __LANGUAGE_H__
  2. #define __LANGUAGE_H__
  3. //////////////////////////////////////////////////////////////////////////
  4. //
  5. //
  6. // language.h --- Header for language related classes.
  7. //
  8. //
  9. /*
  10. This file contains classes related to managing the UI language of HHCTRL.
  11. */
  12. //////////////////////////////////////////////////////////////////////////
  13. //
  14. // Forwards
  15. //
  16. class CLanguage ;
  17. //////////////////////////////////////////////////////////////////////////
  18. //
  19. // Constants
  20. //
  21. const LANGID c_LANGID_ENUM_EOF= static_cast<LANGID>(-1) ;
  22. //////////////////////////////////////////////////////////////////////////
  23. //
  24. // CLanguageEnum
  25. //
  26. /*
  27. This class enumerates the langids to attempt. If you are trying to access
  28. some object using a langid and that object may not be in that particular langid,
  29. you should use this class to get an array of langids to try.
  30. NOTE: This class should only be obtained from the CLanguage class below.
  31. */
  32. class CLanguageEnum
  33. {
  34. //--- Relationships
  35. friend CLanguage ;
  36. //--- Construction
  37. private:
  38. // Will return the langid passed in first. This is the
  39. CLanguageEnum(LANGID langid1 = NULL, LANGID langid2 = NULL, bool bSysOnly = false) ;
  40. public:
  41. virtual ~CLanguageEnum() ;
  42. //--- Access
  43. public:
  44. LANGID start() ;
  45. LANGID next() ; // The last LANGID is always 0 which can be used as a "search for anything" flag. After the 0, next returns c_LANGID_ENUM_EOF .
  46. //--- Member variables
  47. private:
  48. // Current index into array.
  49. int m_index ;
  50. // number of items in the array.
  51. int m_items ;
  52. // Number of LangIds to search
  53. LANGID* m_langids;
  54. };
  55. //////////////////////////////////////////////////////////////////////////
  56. //
  57. // CLanguage
  58. //
  59. class CLanguage
  60. {
  61. //--- Construction
  62. public:
  63. CLanguage() ;
  64. virtual ~CLanguage() ;
  65. //--- Access
  66. public:
  67. // All of the access functions are self initializing.
  68. // Returns the language identifier of the ui/resources.
  69. LANGID GetUiLanguage() ;
  70. // Set the LangId for the resources you want to use --- Used by external clients. Loads the correct satellite dll.
  71. LANGID SetUiLanguage(LANGID langid) ; // Returns the actually langid the control is set to.
  72. // Returns an enumerator to enumerate the possible ui languages. Caller responsible for deleting.
  73. CLanguageEnum* GetEnumerator(LANGID langidOther = NULL) {_Init(); return _GetEnumerator(langidOther); }
  74. // Load the satellite dll --- Called by the module.cpp.
  75. HINSTANCE LoadSatellite() {_Init(); return m_hSatellite ; } // This may appear wierd, but m_hSatellite is NULL if m_langid is 0x0409.
  76. // Return's the user's os ui language.
  77. LANGID GetUserOsUiLanguage() ; //REVIEW: Move to COsLanguage class?
  78. //--- Private Member functions
  79. private:
  80. void _Init() {if (!m_langid) _LoadSatellite(); }
  81. // Non-auto load.
  82. void _LoadSatellite() ;
  83. // Non-auto load.
  84. CLanguageEnum* _GetEnumerator(LANGID landidOther = NULL) ;
  85. // Enumerate only the sys lcids and english lcids. Used by satellite dlls.
  86. CLanguageEnum* _GetSysEnumerator(LANGID landidOther = NULL) ;
  87. //--- Member variables
  88. private:
  89. // Language ID of the user interface. This is either set by the client or by default when we load the satellite.
  90. LANGID m_langid ;
  91. // Satellite instance handle. If m_langid is 0x0409 (english) we don't have a satellite dll.
  92. HINSTANCE m_hSatellite ;
  93. // Function Pointer type for Get*DefaultUILanguage Functions
  94. typedef LANGID (WINAPI *FntPtr_GetDefaultUILanguage)();
  95. // Function pointer to the Get*DefaultUILanguage
  96. FntPtr_GetDefaultUILanguage m_fpGetUserDefaultUILanguage ;
  97. FntPtr_GetDefaultUILanguage m_fpGetSystemDefaultUILanguage ;
  98. // Pointer to the Module handle.
  99. HMODULE m_hNlsModule;
  100. };
  101. #endif //__LANGUAGE_H__