more langpackedit sort tweaks -- from ee8753f8
[wdl.git] / WDL / win32_utf8.h
blob46f301a647e3ffe6176ef25067529b9f0716bbbf
1 #ifndef _WDL_WIN32_UTF8_H_
2 #define _WDL_WIN32_UTF8_H_
4 #ifdef __cplusplus
5 extern "C" {
6 #endif
8 #if defined(_WIN32) && !defined(WDL_NO_SUPPORT_UTF8)
10 #ifndef WDL_WIN32_UTF8_IMPL
11 #define WDL_WIN32_UTF8_IMPL
12 #define WDL_WIN32_UTF8_IMPL_NOTSTATIC
13 #endif
15 #include <windows.h>
16 #include <sys/stat.h>
17 #include <stdio.h>
19 #define LB_GETTEXTUTF8 (LB_GETTEXT|0x8000)
20 #define LB_GETTEXTLENUTF8 (LB_GETTEXTLEN|0x8000)
22 WDL_WIN32_UTF8_IMPL BOOL SetWindowTextUTF8(HWND hwnd, LPCTSTR str);
23 WDL_WIN32_UTF8_IMPL BOOL SetDlgItemTextUTF8(HWND hDlg, int nIDDlgItem, LPCTSTR lpString);
24 WDL_WIN32_UTF8_IMPL int GetWindowTextUTF8(HWND hWnd, LPTSTR lpString, int nMaxCount);
25 WDL_WIN32_UTF8_IMPL UINT GetDlgItemTextUTF8(HWND hDlg, int nIDDlgItem, LPTSTR lpString, int nMaxCount);
26 WDL_WIN32_UTF8_IMPL int MessageBoxUTF8(HWND hwnd, LPCTSTR lpText, LPCTSTR lpCaption, UINT fl);
28 WDL_WIN32_UTF8_IMPL BOOL CreateDirectoryUTF8(LPCTSTR path, LPSECURITY_ATTRIBUTES attr);
29 WDL_WIN32_UTF8_IMPL BOOL DeleteFileUTF8(LPCTSTR path);
30 WDL_WIN32_UTF8_IMPL BOOL MoveFileUTF8(LPCTSTR existfn, LPCTSTR newfn);
31 WDL_WIN32_UTF8_IMPL BOOL CopyFileUTF8(LPCTSTR existfn, LPCTSTR newfn, BOOL fie);
32 WDL_WIN32_UTF8_IMPL DWORD GetCurrentDirectoryUTF8(DWORD nBufferLength, LPTSTR lpBuffer);
33 WDL_WIN32_UTF8_IMPL DWORD GetTempPathUTF8(DWORD nBufferLength, LPTSTR lpBuffer);
34 WDL_WIN32_UTF8_IMPL BOOL SetCurrentDirectoryUTF8(LPCTSTR path);
35 WDL_WIN32_UTF8_IMPL BOOL RemoveDirectoryUTF8(LPCTSTR path);
36 WDL_WIN32_UTF8_IMPL HINSTANCE LoadLibraryUTF8(LPCTSTR path);
38 WDL_WIN32_UTF8_IMPL HANDLE CreateFileUTF8(LPCTSTR lpFileName,DWORD dwDesiredAccess,DWORD dwShareMode,LPSECURITY_ATTRIBUTES lpSecurityAttributes,DWORD dwCreationDisposition,DWORD dwFlagsAndAttributes,HANDLE hTemplateFile);
40 WDL_WIN32_UTF8_IMPL UINT DragQueryFileUTF8(HDROP hDrop, UINT idx, char *buf, UINT bufsz);
42 WDL_WIN32_UTF8_IMPL int DrawTextUTF8(HDC hdc, LPCTSTR str, int nc, LPRECT lpRect, UINT format);
44 WDL_WIN32_UTF8_IMPL BOOL GetOpenFileNameUTF8(LPOPENFILENAME lpofn);
45 WDL_WIN32_UTF8_IMPL BOOL GetSaveFileNameUTF8(LPOPENFILENAME lpofn);
47 #if _MSC_VER > 1700 && defined(_WIN64)
48 WDL_WIN32_UTF8_IMPL BOOL SHGetPathFromIDListUTF8(const struct _ITEMIDLIST __unaligned *pidl, LPSTR pszPath, int pszPathLen);
49 #else
50 WDL_WIN32_UTF8_IMPL BOOL SHGetPathFromIDListUTF8(const struct _ITEMIDLIST *pidl, LPSTR pszPath, int pszPathLen);
51 #endif
53 WDL_WIN32_UTF8_IMPL BOOL SHGetSpecialFolderPathUTF8(HWND hwndOwner, LPTSTR lpszPath, int pszPathLen, int csidl, BOOL create);
55 WDL_WIN32_UTF8_IMPL struct _ITEMIDLIST *SHBrowseForFolderUTF8(struct _browseinfoA *browseInfoA);
56 WDL_WIN32_UTF8_IMPL int WDL_UTF8_SendBFFM_SETSEL(HWND hwnd, const char *str); // sends BFFM_SETSELECTIONA or BFFM_SETSELECTIONW
58 WDL_WIN32_UTF8_IMPL HINSTANCE ShellExecuteUTF8(HWND hwnd, LPCTSTR lpOp, LPCTSTR lpFile, LPCTSTR lpParm, LPCTSTR lpDir, INT nShowCmd);
60 WDL_WIN32_UTF8_IMPL BOOL GetUserNameUTF8(LPTSTR lpString, LPDWORD nMaxCount);
61 WDL_WIN32_UTF8_IMPL BOOL GetComputerNameUTF8(LPTSTR lpString, LPDWORD nMaxCount);
63 WDL_WIN32_UTF8_IMPL BOOL InsertMenuUTF8(HMENU hMenu, UINT uPosition, UINT uFlags, UINT_PTR uIDNewItem, LPCTSTR str);
64 WDL_WIN32_UTF8_IMPL BOOL InsertMenuItemUTF8( HMENU hMenu,UINT uItem, BOOL fByPosition, LPMENUITEMINFO lpmii);
65 WDL_WIN32_UTF8_IMPL BOOL SetMenuItemInfoUTF8(HMENU hMenu, UINT uItem, BOOL fByPosition,LPMENUITEMINFO lpmii);
66 WDL_WIN32_UTF8_IMPL BOOL GetMenuItemInfoUTF8(HMENU hMenu, UINT uItem,BOOL fByPosition,LPMENUITEMINFO lpmii);
68 WDL_WIN32_UTF8_IMPL int statUTF8(const char *filename, struct stat *buffer);
69 WDL_WIN32_UTF8_IMPL FILE *fopenUTF8(const char *filename, const char *mode);
71 WDL_WIN32_UTF8_IMPL int GetKeyNameTextUTF8(LONG lParam, LPTSTR lpString, int nMaxCount);
74 WDL_WIN32_UTF8_IMPL WCHAR *WDL_UTF8ToWC(const char *buf, BOOL doublenull, int minsize, DWORD *sizeout);
76 WDL_WIN32_UTF8_IMPL BOOL WDL_HasUTF8(const char *_str);
78 WDL_WIN32_UTF8_IMPL void WDL_UTF8_HookComboBox(HWND h);
79 WDL_WIN32_UTF8_IMPL void WDL_UTF8_HookListView(HWND h);
80 WDL_WIN32_UTF8_IMPL void WDL_UTF8_HookListBox(HWND h);
81 WDL_WIN32_UTF8_IMPL void WDL_UTF8_HookTreeView(HWND h);
82 WDL_WIN32_UTF8_IMPL void WDL_UTF8_HookTabCtrl(HWND h);
84 WDL_WIN32_UTF8_IMPL LPSTR GetCommandParametersUTF8();
85 WDL_WIN32_UTF8_IMPL void WDL_UTF8_ListViewConvertDispInfoToW(void *di); //NMLVDISPINFO
87 WDL_WIN32_UTF8_IMPL UINT GetPrivateProfileIntUTF8(LPCTSTR appStr, LPCTSTR keyStr, INT def, LPCTSTR fnStr);
88 WDL_WIN32_UTF8_IMPL DWORD GetPrivateProfileStringUTF8(LPCTSTR appStr, LPCTSTR keyStr, LPCTSTR defStr, LPTSTR retStr, DWORD nSize, LPCTSTR fnStr);
89 WDL_WIN32_UTF8_IMPL BOOL WritePrivateProfileStringUTF8(LPCTSTR appStr, LPCTSTR keyStr, LPCTSTR str, LPCTSTR fnStr);
90 WDL_WIN32_UTF8_IMPL BOOL GetPrivateProfileStructUTF8(LPCTSTR appStr, LPCTSTR keyStr, LPVOID pStruct, UINT uSize, LPCTSTR fnStr);
91 WDL_WIN32_UTF8_IMPL BOOL WritePrivateProfileStructUTF8(LPCTSTR appStr, LPCTSTR keyStr, LPVOID pStruct, UINT uSize, LPCTSTR fnStr);
93 WDL_WIN32_UTF8_IMPL DWORD GetModuleFileNameUTF8(HMODULE hModule, LPTSTR fnStr, DWORD nSize);
95 WDL_WIN32_UTF8_IMPL DWORD GetLongPathNameUTF8(LPCTSTR lpszShortPath, LPSTR lpszLongPath, DWORD cchBuffer);
96 WDL_WIN32_UTF8_IMPL UINT GetTempFileNameUTF8(LPCTSTR lpPathName, LPCTSTR lpPrefixString, UINT uUnique, LPSTR lpTempFileName);
98 WDL_WIN32_UTF8_IMPL BOOL CreateProcessUTF8( LPCTSTR lpApplicationName, LPTSTR lpCommandLine,
99 LPSECURITY_ATTRIBUTES lpProcessAttributes,
100 LPSECURITY_ATTRIBUTES lpThreadAttributes, BOOL bInheritHandles,
101 DWORD dwCreationFlags,
102 LPVOID lpEnvironment,
103 LPCTSTR lpCurrentDirectory,
104 LPSTARTUPINFO lpStartupInfo,
105 LPPROCESS_INFORMATION lpProcessInformation);
107 #ifdef SetWindowText
108 #undef SetWindowText
109 #endif
110 #define SetWindowText SetWindowTextUTF8
112 #ifdef SetDlgItemText
113 #undef SetDlgItemText
114 #endif
115 #define SetDlgItemText SetDlgItemTextUTF8
118 #ifdef GetWindowText
119 #undef GetWindowText
120 #endif
121 #define GetWindowText GetWindowTextUTF8
123 #ifdef GetDlgItemText
124 #undef GetDlgItemText
125 #endif
126 #define GetDlgItemText GetDlgItemTextUTF8
128 #ifdef MessageBox
129 #undef MessageBox
130 #endif
131 #define MessageBox MessageBoxUTF8
133 #ifdef DragQueryFile
134 #undef DragQueryFile
135 #endif
136 #define DragQueryFile DragQueryFileUTF8
138 #ifdef GetOpenFileName
139 #undef GetOpenFileName
140 #endif
141 #define GetOpenFileName GetOpenFileNameUTF8
143 #ifdef GetSaveFileName
144 #undef GetSaveFileName
145 #endif
146 #define GetSaveFileName GetSaveFileNameUTF8
148 #ifdef ShellExecute
149 #undef ShellExecute
150 #endif
151 #define ShellExecute ShellExecuteUTF8
153 #ifdef GetUserName
154 #undef GetUserName
155 #endif
156 #define GetUserName GetUserNameUTF8
158 #ifdef GetComputerName
159 #undef GetComputerName
160 #endif
161 #define GetComputerName GetComputerNameUTF8
163 #ifdef CreateDirectory
164 #undef CreateDirectory
165 #endif
166 #define CreateDirectory CreateDirectoryUTF8
168 #ifdef DeleteFile
169 #undef DeleteFile
170 #endif
171 #define DeleteFile DeleteFileUTF8
173 #ifdef MoveFile
174 #undef MoveFile
175 #endif
176 #define MoveFile MoveFileUTF8
178 #ifdef CopyFile
179 #undef CopyFile
180 #endif
181 #define CopyFile CopyFileUTF8
183 #ifdef GetCurrentDirectory
184 #undef GetCurrentDirectory
185 #endif
186 #define GetCurrentDirectory GetCurrentDirectoryUTF8
188 #ifdef GetTempPath
189 #undef GetTempPath
190 #endif
191 #define GetTempPath GetTempPathUTF8
193 #ifdef SetCurrentDirectory
194 #undef SetCurrentDirectory
195 #endif
196 #define SetCurrentDirectory SetCurrentDirectoryUTF8
199 #ifdef RemoveDirectory
200 #undef RemoveDirectory
201 #endif
202 #define RemoveDirectory RemoveDirectoryUTF8
205 #ifdef CreateFile
206 #undef CreateFile
207 #endif
208 #define CreateFile CreateFileUTF8
211 #ifdef InsertMenu
212 #undef InsertMenu
213 #endif
214 #define InsertMenu InsertMenuUTF8
216 #ifdef InsertMenuItem
217 #undef InsertMenuItem
218 #endif
219 #define InsertMenuItem InsertMenuItemUTF8
221 #ifdef SetMenuItemInfo
222 #undef SetMenuItemInfo
223 #endif
224 #define SetMenuItemInfo SetMenuItemInfoUTF8
226 #ifdef GetMenuItemInfo
227 #undef GetMenuItemInfo
228 #endif
229 #define GetMenuItemInfo GetMenuItemInfoUTF8
231 #ifdef LoadLibrary
232 #undef LoadLibrary
233 #endif
234 #define LoadLibrary LoadLibraryUTF8
236 #ifdef GetPrivateProfileInt
237 #undef GetPrivateProfileInt
238 #endif
239 #define GetPrivateProfileInt GetPrivateProfileIntUTF8
241 #ifdef GetPrivateProfileString
242 #undef GetPrivateProfileString
243 #endif
244 #define GetPrivateProfileString GetPrivateProfileStringUTF8
246 #ifdef WritePrivateProfileString
247 #undef WritePrivateProfileString
248 #endif
249 #define WritePrivateProfileString WritePrivateProfileStringUTF8
251 #ifdef WritePrivateProfileStruct
252 #undef WritePrivateProfileStruct
253 #endif
254 #define WritePrivateProfileStruct WritePrivateProfileStructUTF8
256 #ifdef GetPrivateProfileStruct
257 #undef GetPrivateProfileStruct
258 #endif
259 #define GetPrivateProfileStruct GetPrivateProfileStructUTF8
262 #ifdef GetModuleFileName
263 #undef GetModuleFileName
264 #endif
265 #define GetModuleFileName GetModuleFileNameUTF8
267 #ifdef GetLongPathName
268 #undef GetLongPathName
269 #endif
270 #define GetLongPathName GetLongPathNameUTF8
272 #ifdef GetTempFileName
273 #undef GetTempFileName
274 #endif
275 #define GetTempFileName GetTempFileNameUTF8
277 #ifdef CreateProcess
278 #undef CreateProcess
279 #endif
280 #define CreateProcess CreateProcessUTF8
282 #ifdef fopen
283 #undef fopen
284 #endif
285 #define fopen fopenUTF8
287 #ifdef stat
288 #undef stat
289 #endif
290 #define stat(fn,s) statUTF8(fn,s)
291 typedef char wdl_utf8_chk_stat_types_assert_failed[sizeof(struct stat) == sizeof(struct _stat) ? 1 : -1];
293 #else
295 #if defined(WDL_CHECK_FOR_NON_UTF8_FOPEN) && defined(fopen)
296 #undef fopen
297 #endif
299 // compat defines for when UTF disabled
300 #define DrawTextUTF8 DrawText
301 #define statUTF8 stat
302 #define fopenUTF8 fopen
303 #define WDL_UTF8_HookComboBox(x) do { if (WDL_NORMALLY(x)) { } } while(0)
304 #define WDL_UTF8_HookListView(x) do { if (WDL_NORMALLY(x)) { } } while(0)
305 #define WDL_UTF8_HookListBox(x) do { if (WDL_NORMALLY(x)) { } } while(0)
306 #define WDL_UTF8_HookTreeView(x) do { if (WDL_NORMALLY(x)) { } } while(0)
307 #define WDL_UTF8_HookTabCtrl(x) do { if (WDL_NORMALLY(x)) { } } while(0)
308 #define WDL_UTF8_ListViewConvertDispInfoToW(x)
310 #define LB_GETTEXTUTF8 LB_GETTEXT
311 #define LB_GETTEXTLENUTF8 LB_GETTEXTLEN
314 #endif
316 #ifdef __cplusplus
318 #endif
320 #endif