Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in tip

fogcreek shellext: added a keyboard help dialog box

Changeset 9683dff013bb

Parent 875fe9a6a44d

by David Golub

Changes to 9 files · Browse files at 9683dff013bb Showing diff from parent 875fe9a6a44d Diff from another changeset...

 
16
17
18
 
19
20
21
 
33
34
35
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
17
18
19
20
21
22
 
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
@@ -16,6 +16,7 @@
 #include "stdafx.h"    #include "RegistryConfig.h" +#include "TortoiseUtils.h"    int GetRegistryConfig(const CString& strName, CString& strRes)  { @@ -33,3 +34,30 @@
  ::RegCloseKey(hKey);   return lRes == ERROR_SUCCESS;  } + +void GetCMenuTranslation(const CString& strLang, LPCTSTR lpszName, + CStringW& strMenuText, CStringW& strHelpText) +{ + CStringW strSubKey = L"Software\\TortoiseHg\\CMenu\\"; + strSubKey += strLang; + strSubKey += L"\\"; + strSubKey += lpszName; + + ATLTRACE(L"GetCMenuTranslation: '%s'\n", (LPCWSTR)strSubKey); + + HKEY hKey = 0; + LONG lRes = ::RegOpenKeyExW(HKEY_CURRENT_USER, strSubKey, 0, KEY_READ, &hKey); + + if (lRes == ERROR_SUCCESS && hKey) + { + GetRegSZValueW(hKey, L"menuText", strMenuText); + GetRegSZValueW(hKey, L"helpText", strHelpText); + } + else + { + ATLTRACE(L"GetCMenuTranslation: RegOpenKeyExW('%s') failed\n", + (LPCWSTR)strSubKey); + } + + if (hKey) ::RegCloseKey(hKey); +}
 
16
17
18
 
 
 
16
17
18
19
20
@@ -16,3 +16,5 @@
 #pragma once    int GetRegistryConfig(const CString& strName, CString& strRes); +void GetCMenuTranslation(const CString& strLang, LPCTSTR lpszName, + CStringW& strMenuText, CStringW& strHelpText);
 
20
21
22
 
23
24
25
 
79
80
81
 
 
 
 
 
82
83
84
 
20
21
22
23
24
25
26
 
80
81
82
83
84
85
86
87
88
89
90
@@ -20,6 +20,7 @@
 #include "StringUtils.h"  #include "THgStatus.h"  #include "Kiln.h" +#include "KeyboardHelpDialog.h"    void RunDialog(HWND hWnd, const CString& strCmd, const CAtlList<CString>& listFiles,   const CString& strFolder) @@ -79,6 +80,11 @@
  }   return;   } + else if (strCmd == "keyboard") + { + CKeyboardHelpDialog dlg; + dlg.DoModal(hWnd); + }   else if (strCmd == "kiln")   {   KilnOpenRepo(hWnd, strCwd);
 
57
58
59
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
60
61
62
 
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
@@ -57,6 +57,41 @@
   #endif // APSTUDIO_INVOKED   + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_KEYBOARDHELP DIALOGEX 0, 0, 243, 167 +STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Keyboard Help" +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + DEFPUSHBUTTON "OK",IDOK,97,146,50,14 + LTEXT "The following shortcut keys are available when using TortoiseHg from Windows Explorer.",IDC_TOPTEXT,7,7,229,16 + LISTBOX IDC_KEYLIST,7,34,229,101,LBS_SORT | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP +END + + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO +BEGIN + IDD_KEYBOARDHELP, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 236 + TOPMARGIN, 7 + BOTTOMMARGIN, 160 + END +END +#endif // APSTUDIO_INVOKED +  #endif // English (United States) resources  /////////////////////////////////////////////////////////////////////////////  
 
206
207
208
 
209
210
211
 
236
237
238
 
239
240
241
 
206
207
208
209
210
211
212
 
237
238
239
240
241
242
243
@@ -206,6 +206,7 @@
  <ClCompile Include="Dirstate.cpp" />   <ClCompile Include="DirstateCache.cpp" />   <ClCompile Include="IconBitmapUtils.cpp" /> + <ClCompile Include="KeyboardHelpDialog.cpp" />   <ClCompile Include="Kiln.cpp" />   <ClCompile Include="QueryDirstate.cpp" />   <ClCompile Include="RegistryConfig.cpp" /> @@ -236,6 +237,7 @@
  <ClInclude Include="Dirstate.h" />   <ClInclude Include="DirstateCache.h" />   <ClInclude Include="IconBitmapUtils.h" /> + <ClInclude Include="KeyboardHelpDialog.h" />   <ClInclude Include="Kiln.h" />   <ClInclude Include="QueryDirstate.h" />   <ClInclude Include="RegistryConfig.h" />
 
84
85
86
 
 
 
87
88
89
 
155
156
157
 
 
 
158
159
160
 
84
85
86
87
88
89
90
91
92
 
158
159
160
161
162
163
164
165
166
@@ -84,6 +84,9 @@
  <ClCompile Include="RunDialog.cpp">   <Filter>Source Files</Filter>   </ClCompile> + <ClCompile Include="KeyboardHelpDialog.cpp"> + <Filter>Source Files</Filter> + </ClCompile>   </ItemGroup>   <ItemGroup>   <ClInclude Include="Directory.h"> @@ -155,6 +158,9 @@
  <ClInclude Include="RunDialog.h">   <Filter>Header Files</Filter>   </ClInclude> + <ClInclude Include="KeyboardHelpDialog.h"> + <Filter>Header Files</Filter> + </ClInclude>   </ItemGroup>   <ItemGroup>   <None Include="THgShell.def">
 
116
117
118
 
 
 
119
120
121
 
156
157
158
 
159
160
161
 
176
177
178
 
179
180
181
 
189
190
191
 
192
193
194
 
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
 
272
273
274
275
 
276
277
278
 
279
280
281
 
 
 
 
 
 
 
 
 
 
 
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
 
 
 
 
 
 
 
 
 
 
 
 
302
303
304
 
116
117
118
119
120
121
122
123
124
 
159
160
161
162
163
164
165
 
180
181
182
183
184
185
186
 
194
195
196
197
198
199
200
 
206
207
208
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
209
210
211
 
251
252
253
 
254
255
 
 
256
257
 
 
258
259
260
261
262
263
264
265
266
267
268
269
270
271
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
@@ -116,6 +116,9 @@
  { "kilnfiles", L"Kiln",   L"Opens the selected files in Kiln.",   "kiln.ico", 0 }, + { "keyboard", L"Keyboard Help", + L"Displays a list of keyboard shortcuts.", + "", 0 },     // Add new items here.   // Template: @@ -156,6 +159,7 @@
  "repoconf",   "userconf",   NULL, + "keyboard",   "about",  };   @@ -176,6 +180,7 @@
  NULL,   "kilnfiles",   NULL, + "keyboard",   "about",  };   @@ -189,6 +194,7 @@
  NULL,   "workbench",   NULL, + "keyboard",   "about",  };   @@ -200,33 +206,6 @@
  m_mapMenuId[idCmd] = m_mapMenuDesc[strName];  }   -void GetCMenuTranslation(const CString& strLang, LPCTSTR lpszName, - CStringW& strMenuText, CStringW& strHelpText) -{ - CStringW strSubKey = L"Software\\TortoiseHg\\CMenu\\"; - strSubKey += strLang; - strSubKey += L"\\"; - strSubKey += lpszName; - - ATLTRACE(L"GetCMenuTranslation: '%s'\n", (LPCWSTR)strSubKey); - - HKEY hKey = 0; - LONG lRes = ::RegOpenKeyExW(HKEY_CURRENT_USER, strSubKey, 0, KEY_READ, &hKey); - - if (lRes == ERROR_SUCCESS && hKey) - { - GetRegSZValueW(hKey, L"menuText", strMenuText); - GetRegSZValueW(hKey, L"helpText", strHelpText); - } - else - { - ATLTRACE(L"GetCMenuTranslation: RegOpenKeyExW('%s') failed\n", - (LPCWSTR)strSubKey); - } - - if (hKey) ::RegCloseKey(hKey); -} -  void CTortoiseHgCmenuBase::InitMenuMaps(const CMenuDescription *pMenuDescs, int nCount)  {   if (m_mapMenuDesc.IsEmpty()) @@ -272,33 +251,36 @@
  mii.cch = strMenuText.GetLength();   mii.wID = idCmd;   - if (CSysInfo::IsVistaOrLater()) + if (!strIconName.IsEmpty())   { - HBITMAP hBitmap = GetTortoiseIconBitmap(strIconName); - if (hBitmap) + if (CSysInfo::IsVistaOrLater())   { - mii.fMask |= MIIM_BITMAP; - mii.hbmpItem = hBitmap; + HBITMAP hBitmap = GetTortoiseIconBitmap(strIconName); + if (hBitmap) + { + mii.fMask |= MIIM_BITMAP; + mii.hbmpItem = hBitmap; + } + else + { + ATLTRACE(" ***** InsertMenuItemWithIcon1: can't find '%s'\n", + (LPCTSTR)strIconName); + }   }   else   { - ATLTRACE(" ***** InsertMenuItemWithIcon1: can't find '%s'\n", - (LPCTSTR)strIconName); - } - } - else - { - HICON hIcon = GetTortoiseIcon(strIconName); - if (hIcon) - { - mii.fMask |= MIIM_BITMAP | MIIM_DATA; - mii.dwItemData = (ULONG_PTR)hIcon; - mii.hbmpItem = HBMMENU_CALLBACK; - } - else - { - ATLTRACE(" ***** InsertMenuItemWithIcon1: can't find '%s'\n", - (LPCTSTR)strIconName); + HICON hIcon = GetTortoiseIcon(strIconName); + if (hIcon) + { + mii.fMask |= MIIM_BITMAP | MIIM_DATA; + mii.dwItemData = (ULONG_PTR)hIcon; + mii.hbmpItem = HBMMENU_CALLBACK; + } + else + { + ATLTRACE(" ***** InsertMenuItemWithIcon1: can't find '%s'\n", + (LPCTSTR)strIconName); + }   }   }   ::InsertMenuItemW(hMenu, indexMenu, TRUE, &mii);
 
9
10
11
 
 
 
12
13
14
15
16
17
 
18
19
 
20
21
22
 
9
10
11
12
13
14
15
16
17
18
19
 
20
21
 
22
23
24
25
@@ -9,14 +9,17 @@
 #define IDR_MODIFIED 105  #define IDR_UNVERSIONED 106  #define IDR_KEYBOARD 107 +#define IDD_KEYBOARDHELP 108 +#define IDC_KEYLIST 1000 +#define IDC_TOPTEXT 1001    // Next default values for new objects  //  #ifdef APSTUDIO_INVOKED  #ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 108 +#define _APS_NEXT_RESOURCE_VALUE 109  #define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1000 +#define _APS_NEXT_CONTROL_VALUE 1002  #define _APS_NEXT_SYMED_VALUE 101  #endif  #endif
 
24
25
26
 
27
28
29
30
 
24
25
26
27
28
29
 
30
@@ -24,7 +24,7 @@
 #include <atlbase.h>  extern CComModule _Module;  #include <atlcom.h> +#include <atlwin.h>  #include <atlstr.h>  #include <atlcoll.h> -#include <atlutil.h>  #include <shlobj.h>