1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
|
/******************************************************************************
*
*
* Notepad2
*
* Helpers.h
* Definitions for general helper functions and macros
*
* See Readme.txt for more information about this source code.
* Please send me your comments to this work.
*
* See License.txt for details about distribution and modification.
*
* (c) Florian Balmer 1996-2011
* florian.balmer@gmail.com
* http://www.flos-freeware.ch
*
*
******************************************************************************/
extern HINSTANCE g_hInstance;
extern UINT16 g_uWinVer;
#define COUNTOF(ar) (sizeof(ar)/sizeof(ar[0]))
#define CSTRLEN(s) (COUNTOF(s)-1)
extern WCHAR szIniFile[MAX_PATH];
#define IniGetString(lpSection,lpName,lpDefault,lpReturnedStr,nSize) \
GetPrivateProfileString(lpSection,lpName,lpDefault,lpReturnedStr,nSize,szIniFile)
#define IniGetInt(lpSection,lpName,nDefault) \
GetPrivateProfileInt(lpSection,lpName,nDefault,szIniFile)
#define IniSetString(lpSection,lpName,lpString) \
WritePrivateProfileString(lpSection,lpName,lpString,szIniFile)
#define IniDeleteSection(lpSection) \
WritePrivateProfileSection(lpSection,NULL,szIniFile)
__inline BOOL IniSetInt(LPCWSTR lpSection,LPCWSTR lpName,int i) {
WCHAR tch[32]; wsprintf(tch,L"%i",i); return IniSetString(lpSection,lpName,tch);
}
#define LoadIniSection(lpSection,lpBuf,cchBuf) \
GetPrivateProfileSection(lpSection,lpBuf,cchBuf,szIniFile);
#define SaveIniSection(lpSection,lpBuf) \
WritePrivateProfileSection(lpSection,lpBuf,szIniFile)
int IniSectionGetString(LPCWSTR,LPCWSTR,LPCWSTR,LPWSTR,int);
int IniSectionGetInt(LPCWSTR,LPCWSTR,int);
BOOL IniSectionSetString(LPWSTR,LPCWSTR,LPCWSTR);
__inline BOOL IniSectionSetInt(LPWSTR lpCachedIniSection,LPCWSTR lpName,int i) {
WCHAR tch[32]; wsprintf(tch,L"%i",i); return IniSectionSetString(lpCachedIniSection,lpName,tch);
}
extern HWND hwndEdit;
__inline void BeginWaitCursor()
{
SendMessage(hwndEdit,SCI_SETCURSOR,(WPARAM)SC_CURSORWAIT,0);
}
__inline void EndWaitCursor()
{
POINT pt;
SendMessage(hwndEdit,SCI_SETCURSOR,(WPARAM)SC_CURSORNORMAL,0);
GetCursorPos(&pt);
SetCursorPos(pt.x,pt.y);
}
#define Is2k() (g_uWinVer >= 0x0500)
#define IsXP() (g_uWinVer >= 0x0501)
#define IsVista() (g_uWinVer >= 0x0600)
#define IsW7() (g_uWinVer >= 0x0601)
BOOL PrivateIsAppThemed();
HRESULT PrivateSetCurrentProcessExplicitAppUserModelID(PCWSTR);
BOOL IsElevated();
//BOOL SetExplorerTheme(HWND);
BOOL BitmapMergeAlpha(HBITMAP,COLORREF);
BOOL BitmapAlphaBlend(HBITMAP,COLORREF,BYTE);
BOOL BitmapGrayScale(HBITMAP);
BOOL VerifyContrast(COLORREF,COLORREF);
BOOL IsFontAvailable(LPCWSTR);
BOOL SetWindowTitle(HWND,UINT,BOOL,UINT,LPCWSTR,int,BOOL,UINT,BOOL,LPCWSTR);
void SetWindowTransparentMode(HWND,BOOL);
void CenterDlgInParent(HWND);
void GetDlgPos(HWND,LPINT,LPINT);
void SetDlgPos(HWND,int,int);
void ResizeDlg_Init(HWND,int,int,int);
void ResizeDlg_Destroy(HWND,int*,int*);
void ResizeDlg_Size(HWND,LPARAM,int*,int*);
void ResizeDlg_GetMinMaxInfo(HWND,LPARAM);
HDWP DeferCtlPos(HDWP,HWND,int,int,int,UINT);
void MakeBitmapButton(HWND,int,HINSTANCE,UINT);
void MakeColorPickButton(HWND,int,HINSTANCE,COLORREF);
void DeleteBitmapButton(HWND,int);
#define StatusSetSimple(hwnd,b) SendMessage(hwnd,SB_SIMPLE,(WPARAM)b,0)
BOOL StatusSetText(HWND,UINT,LPCWSTR);
BOOL StatusSetTextID(HWND,UINT,UINT);
int StatusCalcPaneWidth(HWND,LPCWSTR);
int Toolbar_GetButtons(HWND,int,LPWSTR,int);
int Toolbar_SetButtons(HWND,int,LPCWSTR,void*,int);
LRESULT SendWMSize(HWND);
#define EnableCmd(hmenu,id,b) EnableMenuItem(hmenu,id,(b)\
?MF_BYCOMMAND|MF_ENABLED:MF_BYCOMMAND|MF_GRAYED)
#define CheckCmd(hmenu,id,b) CheckMenuItem(hmenu,id,(b)\
?MF_BYCOMMAND|MF_CHECKED:MF_BYCOMMAND|MF_UNCHECKED)
BOOL IsCmdEnabled(HWND, UINT);
#define GetString(id,pb,cb) LoadString(g_hInstance,id,pb,cb)
#define StrEnd(pStart) (pStart + lstrlen(pStart))
int FormatString(LPWSTR,int,UINT,...);
void PathRelativeToApp(LPWSTR,LPWSTR,int,BOOL,BOOL,BOOL);
void PathAbsoluteFromApp(LPWSTR,LPWSTR,int,BOOL);
BOOL PathIsLnkFile(LPCWSTR);
BOOL PathGetLnkPath(LPCWSTR,LPWSTR,int);
BOOL PathIsLnkToDirectory(LPCWSTR,LPWSTR,int);
BOOL PathCreateDeskLnk(LPCWSTR);
BOOL PathCreateFavLnk(LPCWSTR,LPCWSTR,LPCWSTR);
BOOL StrLTrim(LPWSTR,LPCWSTR);
BOOL TrimString(LPWSTR);
BOOL ExtractFirstArgument(LPCWSTR, LPWSTR, LPWSTR);
void PrepareFilterStr(LPWSTR);
void StrTab2Space(LPWSTR);
void PathFixBackslashes(LPWSTR);
void ExpandEnvironmentStringsEx(LPWSTR,DWORD);
void PathCanonicalizeEx(LPWSTR);
DWORD GetLongPathNameEx(LPWSTR,DWORD);
DWORD_PTR SHGetFileInfo2(LPCWSTR,DWORD,SHFILEINFO*,UINT,UINT);
int FormatNumberStr(LPWSTR);
BOOL SetDlgItemIntEx(HWND,int,UINT);
#define MBCSToWChar(c,a,w,i) MultiByteToWideChar(c,0,a,-1,w,i)
#define WCharToMBCS(c,w,a,i) WideCharToMultiByte(c,0,w,-1,a,i,NULL,NULL)
UINT GetDlgItemTextA2W(UINT,HWND,int,LPSTR,int);
UINT SetDlgItemTextA2W(UINT,HWND,int,LPSTR);
LRESULT ComboBox_AddStringA2W(UINT,HWND,LPCSTR);
UINT CodePageFromCharSet(UINT);
//==== MRU Functions ==========================================================
#define MRU_MAXITEMS 24
#define MRU_NOCASE 1
#define MRU_UTF8 2
typedef struct _mrulist {
WCHAR szRegKey[256];
int iFlags;
int iSize;
LPWSTR pszItems[MRU_MAXITEMS];
} MRULIST, *PMRULIST, *LPMRULIST;
LPMRULIST MRU_Create(LPCWSTR,int,int);
BOOL MRU_Destroy(LPMRULIST);
BOOL MRU_Add(LPMRULIST,LPCWSTR);
BOOL MRU_AddFile(LPMRULIST,LPCWSTR,BOOL,BOOL);
BOOL MRU_Delete(LPMRULIST,int);
BOOL MRU_DeleteFileFromStore(LPMRULIST,LPCWSTR);
BOOL MRU_Empty(LPMRULIST);
int MRU_Enum(LPMRULIST,int,LPWSTR,int);
BOOL MRU_Load(LPMRULIST);
BOOL MRU_Save(LPMRULIST);
BOOL MRU_MergeSave(LPMRULIST,BOOL,BOOL,BOOL);
//==== Themed Dialogs =========================================================
#ifndef DLGTEMPLATEEX
#pragma pack(push, 1)
typedef struct {
WORD dlgVer;
WORD signature;
DWORD helpID;
DWORD exStyle;
DWORD style;
WORD cDlgItems;
short x;
short y;
short cx;
short cy;
} DLGTEMPLATEEX;
#pragma pack(pop)
#endif
BOOL GetThemedDialogFont(LPWSTR,WORD*);
DLGTEMPLATE* LoadThemedDialogTemplate(LPCTSTR,HINSTANCE);
#define ThemedDialogBox(hInstance,lpTemplate,hWndParent,lpDialogFunc) \
ThemedDialogBoxParam(hInstance,lpTemplate,hWndParent,lpDialogFunc,0)
INT_PTR ThemedDialogBoxParam(HINSTANCE,LPCTSTR,HWND,DLGPROC,LPARAM);
HWND CreateThemedDialogParam(HINSTANCE,LPCTSTR,HWND,DLGPROC,LPARAM);
//==== UnSlash Functions ======================================================
void TransformBackslashes(char*,BOOL,UINT);
//==== MinimizeToTray Functions - see comments in Helpers.c ===================
BOOL GetDoAnimateMinimize(VOID);
VOID MinimizeWndToTray(HWND hWnd);
VOID RestoreWndFromTray(HWND hWnd);
/// End of Helpers.h \\\
|