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