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