Initial IBM OpenAFS 1.0 tree
[openafs.git] / src / WINNT / talocale / talocale.h
1 #ifndef TALOCALE_H
2 #define TALOCALE_H
3
4
5 /*
6  * DEFINITIONS ________________________________________________________________
7  *
8  */
9
10 #if defined(UNICODE) && !defined(_UNICODE)
11 #define _UNICODE
12 #endif
13 #if defined(_UNICODE) && !defined(UNICODE)
14 #define UNICODE
15 #endif
16
17 #include <windows.h>
18 #include <commctrl.h>
19 #include <tchar.h>
20
21 typedef struct
22    {
23    WORD cchString;
24    WCHAR achString[1]; // contains {cchString} members
25    } STRINGTEMPLATE, *LPSTRINGTEMPLATE;
26 typedef const STRINGTEMPLATE *LPCSTRINGTEMPLATE;
27
28 /*
29  * PROTOTYPES _________________________________________________________________
30  *
31  */
32
33 #include <WINNT/tal_string.h>
34 #include <WINNT/tal_dialog.h>
35 #include <WINNT/tal_alloc.h>
36
37 #ifndef REALLOC
38 #define REALLOC(_a,_c,_r,_i) TaLocaleReallocFunction ((LPVOID*)&_a,sizeof(*_a),&_c,_r,_i)
39 extern BOOL TaLocaleReallocFunction (LPVOID *ppTarget, size_t cbElement, size_t *pcTarget, size_t cReq, size_t cInc);
40 #endif
41
42
43 /*
44  *** TaLocale_SpecifyModule
45  *
46  * Adds the given module handle to TaLocale's known list of possible sources
47  * for localized resource data. By default, the list is initialized with
48  * the current executable's module handle; if resources are to be extracted
49  * from other .DLLs using the functions in the TaLocale library, this routine
50  * should be called first to notify TaLocale about each .DLL.
51  *
52  */
53
54 #define MODULE_PRIORITY_HIGHEST   1     // Search this module first
55 #define MODULE_PRIORITY_BOOSTED  40     // Search this module fairly early
56 #define MODULE_PRIORITY_NORMAL   50     // Search this module any time
57 #define MODULE_PRIORITY_LOWEST  100     // Search this module last
58 #define MODULE_PRIORITY_REMOVE    0     // Never search this module again
59
60 extern void TaLocale_SpecifyModule (HINSTANCE hInstance = NULL, WORD wSearchPriority = MODULE_PRIORITY_NORMAL);
61
62
63 /*
64  *** TaLocale_LoadCorrespondingModule
65  *
66  * This routine looks for a .DLL named after the specified module, but
67  * with a suffix reflecting the current locale--it loads that library
68  * and adds it to the active-resources chain (via TaLocale_SpecifyModule()).
69  * The .DLL should ideally live in the same directory as the specified
70  * module; if not, it should at least be on the path.
71  *
72  */
73
74 extern HINSTANCE TaLocale_LoadCorrespondingModule (HINSTANCE hInstance = NULL, WORD wSearchPriority = MODULE_PRIORITY_BOOSTED);
75
76 extern HINSTANCE TaLocale_LoadCorrespondingModuleByName (HINSTANCE hInstance, LPTSTR pszFilename, WORD wSearchPriority = MODULE_PRIORITY_BOOSTED);
77
78
79 /*
80  *** TaLocale_EnumModule
81  *
82  * Enables enumeration of each of the product modules which will be seached
83  * by TaLocale for resources. Use TaLocale_SpecifyModule to modify this list.
84  * Modules will be returned in priority order, with the highest-priority
85  * modules being searched first.
86  *
87  */
88
89 extern BOOL TaLocale_EnumModule (size_t iModule, HINSTANCE *phInstance = NULL, WORD *pwSearchPriority = NULL);
90
91
92 /*
93  *** TaLocale_GetLanguage
94  *** TaLocale_SetLanguage
95  *
96  * Allows specification of a default language for resources extracted by
97  * the functions exported by tal_string.h and tal_dialog.h. When a particular
98  * string or dialog resource is required, the resource which matches this
99  * specified language will be retrieved--if no localized resource is available,
100  * the default resource will instead be used.
101  *
102  */
103
104 extern LANGID TaLocale_GetLanguage (void);
105 extern void TaLocale_SetLanguage (LANGID lang);
106
107
108 /*
109  *** TaLocale_GetLanguageOverride
110  *** TaLocale_SetLanguageOverride
111  *** TaLocale_RemoveLanguageOverride
112  *
113  * Allows specification of a persistent default language for resources
114  * extracted by the functions exported by tal_string.h and tal_dialog.h.
115  * If a language override (which is really just a registry entry) exists,
116  * all TaLocale-based applications will default to that locale when first
117  * run.
118  *
119  */
120
121 extern LANGID TaLocale_GetLanguageOverride (void);
122 extern void TaLocale_SetLanguageOverride (LANGID lang);
123 extern void TaLocale_RemoveLanguageOverride (void);
124
125
126 /*
127  *** TaLocale_GetResource
128  *
129  * Returns a pointer an in-memory image of a language-specific resource.
130  * The resource is found by searching all specified module handles
131  * (as determined automatically, or as specified by previous calls to
132  * TaLocale_SpecifyModule()) for an equivalent resource identifier matching
133  * the requested resource type and localized into the requested language.
134  * In the event that a matching localized resource cannot be found, the
135  * search is repeated using LANG_USER_DEFAULT.
136  *
137  * The pointer returned should be treated as read-only, and should not be freed.
138  *
139  */
140
141 extern LPCVOID TaLocale_GetResource (LPCTSTR pszType, LPCTSTR pszRes, LANGID lang = LANG_USER_DEFAULT, HINSTANCE *phInstFound = NULL);
142
143
144 /*
145  *** TaLocale_GetStringResource
146  *** TaLocale_GetDialogResource
147  *
148  * Convenience wrappers around TaLocale_GetResource for obtaining resources
149  * of a particular type by numeric identifier; these routines specify the
150  * default language (from TaLocale_SetLanguage()) when calling
151  * TaLocale_GetResource().
152  *
153  */
154
155 extern LPCSTRINGTEMPLATE TaLocale_GetStringResource (int ids, HINSTANCE *phInstFound = NULL);
156 extern LPCDLGTEMPLATE TaLocale_GetDialogResource (int idd, HINSTANCE *phInstFound = NULL);
157
158
159 /*
160  *** TaLocale_LoadMenu
161  *** TaLocale_LoadImage
162  *** TaLocale_LoadIcon
163  *** TaLocale_LoadAccelerators
164  *
165  * Replacements for Win32 functions. By using these functions instead, the
166  * caller can load the appropriate resources regardless of the module in
167  * which they reside, or the language which is required.
168  *
169  */
170
171 extern HMENU TaLocale_LoadMenu (int idm);
172 extern HANDLE TaLocale_LoadImage (int idi, UINT imageType, int cx, int cy, UINT imageFlags);
173 extern HICON TaLocale_LoadIcon (int idi);
174 extern HACCEL TaLocale_LoadAccelerators (int ida);
175
176
177 #endif
178