1 #ifndef _WDL_WIN32_UTF8_H_
2 #define _WDL_WIN32_UTF8_H_
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
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
);
50 WDL_WIN32_UTF8_IMPL BOOL
SHGetPathFromIDListUTF8(const struct _ITEMIDLIST
*pidl
, LPSTR pszPath
, int pszPathLen
);
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
);
110 #define SetWindowText SetWindowTextUTF8
112 #ifdef SetDlgItemText
113 #undef SetDlgItemText
115 #define SetDlgItemText SetDlgItemTextUTF8
121 #define GetWindowText GetWindowTextUTF8
123 #ifdef GetDlgItemText
124 #undef GetDlgItemText
126 #define GetDlgItemText GetDlgItemTextUTF8
131 #define MessageBox MessageBoxUTF8
136 #define DragQueryFile DragQueryFileUTF8
138 #ifdef GetOpenFileName
139 #undef GetOpenFileName
141 #define GetOpenFileName GetOpenFileNameUTF8
143 #ifdef GetSaveFileName
144 #undef GetSaveFileName
146 #define GetSaveFileName GetSaveFileNameUTF8
151 #define ShellExecute ShellExecuteUTF8
156 #define GetUserName GetUserNameUTF8
158 #ifdef GetComputerName
159 #undef GetComputerName
161 #define GetComputerName GetComputerNameUTF8
163 #ifdef CreateDirectory
164 #undef CreateDirectory
166 #define CreateDirectory CreateDirectoryUTF8
171 #define DeleteFile DeleteFileUTF8
176 #define MoveFile MoveFileUTF8
181 #define CopyFile CopyFileUTF8
183 #ifdef GetCurrentDirectory
184 #undef GetCurrentDirectory
186 #define GetCurrentDirectory GetCurrentDirectoryUTF8
191 #define GetTempPath GetTempPathUTF8
193 #ifdef SetCurrentDirectory
194 #undef SetCurrentDirectory
196 #define SetCurrentDirectory SetCurrentDirectoryUTF8
199 #ifdef RemoveDirectory
200 #undef RemoveDirectory
202 #define RemoveDirectory RemoveDirectoryUTF8
208 #define CreateFile CreateFileUTF8
214 #define InsertMenu InsertMenuUTF8
216 #ifdef InsertMenuItem
217 #undef InsertMenuItem
219 #define InsertMenuItem InsertMenuItemUTF8
221 #ifdef SetMenuItemInfo
222 #undef SetMenuItemInfo
224 #define SetMenuItemInfo SetMenuItemInfoUTF8
226 #ifdef GetMenuItemInfo
227 #undef GetMenuItemInfo
229 #define GetMenuItemInfo GetMenuItemInfoUTF8
234 #define LoadLibrary LoadLibraryUTF8
236 #ifdef GetPrivateProfileInt
237 #undef GetPrivateProfileInt
239 #define GetPrivateProfileInt GetPrivateProfileIntUTF8
241 #ifdef GetPrivateProfileString
242 #undef GetPrivateProfileString
244 #define GetPrivateProfileString GetPrivateProfileStringUTF8
246 #ifdef WritePrivateProfileString
247 #undef WritePrivateProfileString
249 #define WritePrivateProfileString WritePrivateProfileStringUTF8
251 #ifdef WritePrivateProfileStruct
252 #undef WritePrivateProfileStruct
254 #define WritePrivateProfileStruct WritePrivateProfileStructUTF8
256 #ifdef GetPrivateProfileStruct
257 #undef GetPrivateProfileStruct
259 #define GetPrivateProfileStruct GetPrivateProfileStructUTF8
262 #ifdef GetModuleFileName
263 #undef GetModuleFileName
265 #define GetModuleFileName GetModuleFileNameUTF8
267 #ifdef GetLongPathName
268 #undef GetLongPathName
270 #define GetLongPathName GetLongPathNameUTF8
272 #ifdef GetTempFileName
273 #undef GetTempFileName
275 #define GetTempFileName GetTempFileNameUTF8
280 #define CreateProcess CreateProcessUTF8
285 #define fopen fopenUTF8
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];
295 #if defined(WDL_CHECK_FOR_NON_UTF8_FOPEN) && defined(fopen)
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