Skip to content

HTTPS clone URL

Subversion checkout URL

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