Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

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