~ubuntu-installer/wubi/trunk

« back to all changes in this revision

Viewing changes to src/7z/CPP/7zip/UI/FileManager/MyLoadMenu.cpp

  • Committer: Agostino Russo
  • Date: 2008-12-04 00:37:30 UTC
  • Revision ID: agostino.russo@gmail.com-20081204003730-3o051yp78d6ujckl
* Bumped version to 9.04
* Added required binaries (will be compiled at a later stage)
* Added uninstallation page
* Added BitTorrent source
* Added documentation and licenses
* Connected download managers
* Fixed download status updates
* Added more information to the README
* Made the tasklist thread daemonic so that it does not prevent the
  main application from quitting

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// MyLoadMenu
 
2
 
 
3
#include "StdAfx.h"
 
4
 
 
5
#include "Common/StringConvert.h"
 
6
 
 
7
#include "Windows/Menu.h"
 
8
#include "Windows/Error.h"
 
9
#include "Windows/Clipboard.h"
 
10
 
 
11
#include "../../PropID.h"
 
12
 
 
13
#include "resource.h"
 
14
#include "App.h"
 
15
#include "AboutDialog.h"
 
16
#include "../Common/CompressCall.h"
 
17
 
 
18
#include "HelpUtils.h"
 
19
#include "LangUtils.h"
 
20
#include "PluginInterface.h"
 
21
 
 
22
static const UINT kOpenBookmarkMenuID = 730;
 
23
static const UINT kSetBookmarkMenuID = 740;
 
24
 
 
25
extern HINSTANCE g_hInstance;
 
26
 
 
27
static LPCWSTR kFMHelpTopic = L"FM/index.htm";
 
28
 
 
29
extern void OptionsDialog(HWND hwndOwner, HINSTANCE hInstance);
 
30
 
 
31
using namespace NWindows;
 
32
 
 
33
static const int kFileMenuIndex = 0;
 
34
static const int kEditMenuIndex = 1;
 
35
static const int kViewMenuIndex = 2;
 
36
static const int kBookmarksMenuIndex = kViewMenuIndex + 1;
 
37
 
 
38
struct CStringLangPair
 
39
{
 
40
  wchar_t *String;
 
41
  UINT32 LangID;
 
42
};
 
43
 
 
44
static CStringLangPair kStringLangPairs[] = 
 
45
{
 
46
  { L"&File",  0x03000102 },
 
47
  { L"&Edit",  0x03000103 },
 
48
  { L"&View",  0x03000104 },
 
49
  { L"&Bookmarks", 0x03000107 },
 
50
  { L"&Tools", 0x03000105 },
 
51
  { L"&Help",  0x03000106 },
 
52
};
 
53
 
 
54
UINT32 kAddToFavoritesLangID = 0x03000710;
 
55
UINT32 kToolbarsLangID = 0x03000451;
 
56
 
 
57
/*
 
58
static int FindStringLangItem(const UString &anItem)
 
59
{
 
60
  for (int i = 0; i < sizeof(kStringLangPairs) / 
 
61
      sizeof(kStringLangPairs[0]); i++)
 
62
    if (anItem.CompareNoCase(kStringLangPairs[i].String) == 0)
 
63
      return i;
 
64
  return -1;
 
65
}
 
66
*/
 
67
 
 
68
static CIDLangPair kIDLangPairs[] = 
 
69
{
 
70
  // File
 
71
  { IDM_FILE_OPEN, 0x03000210 },
 
72
  { IDM_FILE_OPEN_INSIDE, 0x03000211 },
 
73
  { IDM_FILE_OPEN_OUTSIDE, 0x03000212 },
 
74
  { IDM_FILE_VIEW, 0x03000220 },
 
75
  { IDM_FILE_EDIT, 0x03000221 },
 
76
  { IDM_RENAME, 0x03000230 },
 
77
  { IDM_COPY_TO, 0x03000231 },
 
78
  { IDM_MOVE_TO, 0x03000232 },
 
79
  { IDM_DELETE, 0x03000233 },
 
80
  { IDM_FILE_PROPERTIES, 0x03000240 },
 
81
  { IDM_FILE_COMMENT, 0x03000241 },
 
82
  { IDM_FILE_CRC, 0x03000242 },
 
83
  { IDM_FILE_SPLIT, 0x03000270 },
 
84
  { IDM_FILE_COMBINE, 0x03000271 },
 
85
  { IDM_CREATE_FOLDER, 0x03000250 },
 
86
  { IDM_CREATE_FILE, 0x03000251 },
 
87
  { IDCLOSE, 0x03000260 },
 
88
 
 
89
  // Edit
 
90
  { IDM_EDIT_CUT, 0x03000320 },
 
91
  { IDM_EDIT_COPY, 0x03000321 },
 
92
  { IDM_EDIT_PASTE, 0x03000322 },
 
93
 
 
94
  { IDM_SELECT_ALL, 0x03000330 },
 
95
  { IDM_DESELECT_ALL, 0x03000331 },
 
96
  { IDM_INVERT_SELECTION, 0x03000332 },
 
97
  { IDM_SELECT, 0x03000333 },
 
98
  { IDM_DESELECT, 0x03000334 },
 
99
  { IDM_SELECT_BY_TYPE, 0x03000335 },
 
100
  { IDM_DESELECT_BY_TYPE, 0x03000336 },
 
101
 
 
102
  { IDM_VIEW_LARGE_ICONS, 0x03000410 },
 
103
  { IDM_VIEW_SMALL_ICONS, 0x03000411 },
 
104
  { IDM_VIEW_LIST, 0x03000412 },
 
105
  { IDM_VIEW_DETAILS, 0x03000413 },
 
106
 
 
107
  { IDM_VIEW_ARANGE_BY_NAME, 0x02000204 },
 
108
  { IDM_VIEW_ARANGE_BY_TYPE, 0x02000214 },
 
109
  { IDM_VIEW_ARANGE_BY_DATE, 0x0200020C },
 
110
  { IDM_VIEW_ARANGE_BY_SIZE, 0x02000207 },
 
111
  { IDM_VIEW_ARANGE_NO_SORT, 0x03000420 },
 
112
 
 
113
  { IDM_OPEN_ROOT_FOLDER, 0x03000430 },
 
114
  { IDM_OPEN_PARENT_FOLDER, 0x03000431 },
 
115
  { IDM_FOLDERS_HISTORY, 0x03000432 },
 
116
 
 
117
  { IDM_VIEW_REFRESH, 0x03000440 },
 
118
  
 
119
  { IDM_VIEW_FLAT_VIEW, 0x03000449 },
 
120
  { IDM_VIEW_TWO_PANELS, 0x03000450 },
 
121
  { IDM_VIEW_ARCHIVE_TOOLBAR, 0x03000460 },
 
122
  { IDM_VIEW_STANDARD_TOOLBAR, 0x03000461 },
 
123
  { IDM_VIEW_TOOLBARS_LARGE_BUTTONS, 0x03000462 },
 
124
  { IDM_VIEW_TOOLBARS_SHOW_BUTTONS_TEXT, 0x03000463 },
 
125
 
 
126
  { IDM_OPTIONS, 0x03000510 },
 
127
  { IDM_BENCHMARK, 0x03000511 },
 
128
  
 
129
  { IDM_HELP_CONTENTS, 0x03000610 },
 
130
  { IDM_ABOUT, 0x03000620 }
 
131
};
 
132
 
 
133
 
 
134
static int FindLangItem(int ControlID)
 
135
{
 
136
  for (int i = 0; i < sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0]); i++)
 
137
    if (kIDLangPairs[i].ControlID == ControlID)
 
138
      return i;
 
139
  return -1;
 
140
}
 
141
 
 
142
 
 
143
/*
 
144
static bool g_IsNew_fMask = true;
 
145
 
 
146
class CInit_fMask
 
147
{
 
148
public:
 
149
  CInit_fMask()
 
150
  {
 
151
    g_IsNew_fMask = false;
 
152
    OSVERSIONINFO vi;
 
153
    vi.dwOSVersionInfoSize = sizeof(vi);
 
154
    if (::GetVersionEx(&vi)) 
 
155
    {
 
156
      g_IsNew_fMask = (vi.dwMajorVersion > 4 || 
 
157
        (vi.dwMajorVersion == 4 && vi.dwMinorVersion > 0));
 
158
    }
 
159
    g_IsNew_fMask = false;
 
160
  }
 
161
} g_Init_fMask;
 
162
 
 
163
// it's hack for supporting Windows NT
 
164
// constants are from WinUser.h
 
165
 
 
166
#if(WINVER < 0x0500)
 
167
#define MIIM_STRING      0x00000040
 
168
#define MIIM_BITMAP      0x00000080
 
169
#define MIIM_FTYPE       0x00000100
 
170
#endif
 
171
 
 
172
static UINT Get_fMaskForString()
 
173
{
 
174
  return g_IsNew_fMask ? MIIM_STRING : MIIM_TYPE;
 
175
}
 
176
 
 
177
static UINT Get_fMaskForFTypeAndString()
 
178
{
 
179
  return g_IsNew_fMask ? (MIIM_STRING | MIIM_FTYPE) : MIIM_TYPE;
 
180
}
 
181
*/
 
182
 
 
183
static UINT Get_fMaskForString()
 
184
{
 
185
  return MIIM_TYPE;
 
186
}
 
187
 
 
188
static UINT Get_fMaskForFTypeAndString()
 
189
{
 
190
  return MIIM_TYPE;
 
191
}
 
192
 
 
193
 
 
194
 
 
195
static void MyChangeMenu(HMENU menuLoc, int level, int menuIndex)
 
196
{
 
197
  CMenu menu;
 
198
  menu.Attach(menuLoc);
 
199
  for (int i = 0; i < menu.GetItemCount(); i++)
 
200
  {
 
201
    CMenuItem item;
 
202
    item.fMask = Get_fMaskForString() | MIIM_SUBMENU | MIIM_ID;
 
203
    item.fType = MFT_STRING;
 
204
    if (menu.GetItem(i, true, item))
 
205
    {
 
206
      UString newString;
 
207
      if (item.hSubMenu)
 
208
      {
 
209
        if (level == 1 && menuIndex == kBookmarksMenuIndex)
 
210
          newString = LangString(kAddToFavoritesLangID);
 
211
        else
 
212
        {
 
213
          MyChangeMenu(item.hSubMenu, level + 1, i);
 
214
          if (level == 1 && menuIndex == kViewMenuIndex)
 
215
          {
 
216
            newString = LangString(kToolbarsLangID);
 
217
          }
 
218
          else
 
219
          {
 
220
            if (level == 0 && i < sizeof(kStringLangPairs) / 
 
221
              sizeof(kStringLangPairs[0]))
 
222
              newString = LangString(kStringLangPairs[i].LangID);
 
223
            else
 
224
              continue;
 
225
          }
 
226
        }
 
227
        if (newString.IsEmpty())
 
228
          continue;
 
229
      }
 
230
      else
 
231
      {
 
232
        int langPos = FindLangItem(item.wID);
 
233
        if (langPos < 0)
 
234
          continue;
 
235
        newString = LangString(kIDLangPairs[langPos].LangID);
 
236
        if (newString.IsEmpty())
 
237
          continue;
 
238
        UString shorcutString = item.StringValue;
 
239
        int tabPos = shorcutString.ReverseFind(wchar_t('\t'));
 
240
        if (tabPos >= 0)
 
241
          newString += shorcutString.Mid(tabPos);
 
242
      }
 
243
      {
 
244
        item.StringValue = newString;
 
245
        item.fMask = Get_fMaskForString();
 
246
        item.fType = MFT_STRING;
 
247
        menu.SetItem(i, true, item);
 
248
      }
 
249
    }
 
250
  }
 
251
}
 
252
 
 
253
CMenu g_FileMenu;
 
254
 
 
255
class CFileMenuDestroyer
 
256
{
 
257
public:
 
258
  ~CFileMenuDestroyer()
 
259
  {
 
260
    if ((HMENU)g_FileMenu != 0)
 
261
      g_FileMenu.Destroy();
 
262
  }
 
263
} g_FileMenuDestroyer;
 
264
 
 
265
 
 
266
void MyLoadMenu(HWND hWnd)
 
267
{
 
268
  if ((HMENU)g_FileMenu != 0)
 
269
    g_FileMenu.Destroy();
 
270
  HMENU oldMenu = ::GetMenu(hWnd);
 
271
  HMENU baseMenu = ::LoadMenu(g_hInstance, MAKEINTRESOURCE(IDM_MENU));
 
272
  ::SetMenu(hWnd, baseMenu);
 
273
  ::DestroyMenu(oldMenu);
 
274
  if (!g_LangID.IsEmpty())
 
275
  {
 
276
    HMENU menuOld = ::GetMenu(hWnd);
 
277
    MyChangeMenu(menuOld, 0, 0);
 
278
  }
 
279
  ::DrawMenuBar(hWnd);
 
280
}
 
281
 
 
282
extern HWND g_HWND;
 
283
void MyLoadMenu()
 
284
{
 
285
  MyLoadMenu(g_HWND);
 
286
}
 
287
 
 
288
static void CopyMenu(HMENU srcMenuSpec, HMENU destMenuSpec)
 
289
{
 
290
  CMenu srcMenu;
 
291
  srcMenu.Attach(srcMenuSpec);
 
292
  CMenu destMenu;
 
293
  destMenu.Attach(destMenuSpec);
 
294
  int startPos = 0;
 
295
  for (int i = 0; i < srcMenu.GetItemCount(); i++)
 
296
  {
 
297
    CMenuItem item;
 
298
    item.fMask = MIIM_STATE | MIIM_ID | Get_fMaskForFTypeAndString();
 
299
    item.fType = MFT_STRING;
 
300
    if (srcMenu.GetItem(i, true, item))
 
301
      if (destMenu.InsertItem(startPos, true, item))
 
302
        startPos++;
 
303
  }
 
304
}
 
305
 
 
306
void OnMenuActivating(HWND /* hWnd */, HMENU hMenu, int position)
 
307
{
 
308
  if (::GetSubMenu(::GetMenu(g_HWND), position) != hMenu)
 
309
    return;
 
310
  if (position == kFileMenuIndex)
 
311
  {
 
312
    if ((HMENU)g_FileMenu == 0)
 
313
    {
 
314
      g_FileMenu.CreatePopup();
 
315
      CopyMenu(hMenu, g_FileMenu);
 
316
    }
 
317
    CMenu menu;
 
318
    menu.Attach(hMenu);
 
319
    while (menu.GetItemCount() > 0)
 
320
    {
 
321
      if (!menu.RemoveItem(0, MF_BYPOSITION))
 
322
        break;
 
323
    }
 
324
    // CopyMenu(g_FileMenu, hMenu);
 
325
    g_App.GetFocusedPanel().CreateFileMenu(hMenu);
 
326
  }
 
327
  else if (position == kEditMenuIndex)
 
328
  {
 
329
    /*
 
330
    CMenu menu;
 
331
    menu.Attach(hMenu);
 
332
    menu.EnableItem(IDM_EDIT_CUT, MF_ENABLED);
 
333
    menu.EnableItem(IDM_EDIT_COPY, MF_ENABLED);
 
334
    menu.EnableItem(IDM_EDIT_PASTE, IsClipboardFormatAvailableHDROP() ? MF_ENABLED : MF_GRAYED);
 
335
    */
 
336
  }
 
337
  else if (position == kViewMenuIndex)
 
338
  {
 
339
    // View;
 
340
    CMenu menu;
 
341
    menu.Attach(hMenu);
 
342
    menu.CheckRadioItem(IDM_VIEW_LARGE_ICONS, IDM_VIEW_DETAILS, 
 
343
      IDM_VIEW_LARGE_ICONS + g_App.GetListViewMode(), MF_BYCOMMAND);
 
344
    menu.CheckItem(IDM_VIEW_TWO_PANELS, MF_BYCOMMAND |
 
345
        ((g_App.NumPanels == 2) ? MF_CHECKED : MF_UNCHECKED));
 
346
    menu.CheckItem(IDM_VIEW_FLAT_VIEW, MF_BYCOMMAND |
 
347
        ((g_App.GetFlatMode()) ? MF_CHECKED : MF_UNCHECKED));
 
348
    menu.CheckItem(IDM_VIEW_ARCHIVE_TOOLBAR, MF_BYCOMMAND |
 
349
        (g_App.ShowArchiveToolbar ? MF_CHECKED : MF_UNCHECKED));
 
350
    menu.CheckItem(IDM_VIEW_STANDARD_TOOLBAR, MF_BYCOMMAND |
 
351
        (g_App.ShowStandardToolbar ? MF_CHECKED : MF_UNCHECKED));
 
352
    menu.CheckItem(IDM_VIEW_TOOLBARS_LARGE_BUTTONS, MF_BYCOMMAND |
 
353
        (g_App.LargeButtons ? MF_CHECKED : MF_UNCHECKED));
 
354
    menu.CheckItem(IDM_VIEW_TOOLBARS_SHOW_BUTTONS_TEXT, MF_BYCOMMAND |
 
355
        (g_App.ShowButtonsLables ? MF_CHECKED : MF_UNCHECKED));
 
356
  }
 
357
  else if (position == kBookmarksMenuIndex)
 
358
  {
 
359
    CMenu menu;
 
360
    menu.Attach(hMenu);
 
361
 
 
362
    CMenu subMenu;
 
363
    subMenu.Attach(menu.GetSubMenu(0));
 
364
    while (subMenu.GetItemCount() > 0)
 
365
      subMenu.RemoveItem(subMenu.GetItemCount() - 1, MF_BYPOSITION);
 
366
    int i;
 
367
    for (i = 0; i < 10; i++)
 
368
    {
 
369
      UString s = LangString(IDS_BOOKMARK, 0x03000720);
 
370
      s += L" ";
 
371
      wchar_t c = (wchar_t)(L'0' + i);
 
372
      s += c;
 
373
      s += L"\tAlt+Shift+";
 
374
      s += c;
 
375
      subMenu.AppendItem(MF_STRING, kSetBookmarkMenuID + i, s);
 
376
    }
 
377
 
 
378
    while (menu.GetItemCount() > 2)
 
379
      menu.RemoveItem(menu.GetItemCount() - 1, MF_BYPOSITION);
 
380
 
 
381
    for (i = 0; i < 10; i++)
 
382
    {
 
383
      UString path = g_App.AppState.FastFolders.GetString(i);
 
384
      const int kMaxSize = 100;
 
385
      const int kFirstPartSize = kMaxSize / 2;
 
386
      if (path.Length() > kMaxSize)
 
387
      {
 
388
        path = path.Left(kFirstPartSize) + UString(L" ... ") +
 
389
          path.Right(kMaxSize - kFirstPartSize);
 
390
      }
 
391
      UString s = path;
 
392
      if (s.IsEmpty())
 
393
        s = L"-";
 
394
      s += L"\tAlt+";
 
395
      s += (wchar_t)(L'0' + i);
 
396
      menu.AppendItem(MF_STRING, kOpenBookmarkMenuID + i, s);
 
397
    }
 
398
  }
 
399
}
 
400
 
 
401
/*
 
402
It doesn't help
 
403
void OnMenuUnActivating(HWND hWnd, HMENU hMenu, int id)
 
404
{
 
405
  if (::GetSubMenu(::GetMenu(g_HWND), 0) != hMenu)
 
406
    return;
 
407
  // g_App.GetFocusedPanel()._contextMenu.Release();
 
408
}
 
409
 
 
410
void OnMenuUnActivating(HWND hWnd)
 
411
{
 
412
}
 
413
*/
 
414
 
 
415
 
 
416
void LoadFileMenu(HMENU hMenu, int startPos, bool /* forFileMode */, bool programMenu)
 
417
{
 
418
  {
 
419
    CMenu srcMenu;
 
420
    srcMenu.Attach(::GetSubMenu(::GetMenu(g_HWND), 0));
 
421
    if ((HMENU)g_FileMenu == 0)
 
422
    {
 
423
      g_FileMenu.CreatePopup();
 
424
      CopyMenu(srcMenu, g_FileMenu);
 
425
    }
 
426
  }
 
427
 
 
428
  CMenu destMenu;
 
429
  destMenu.Attach(hMenu);
 
430
  
 
431
  for (int i = 0; i < g_FileMenu.GetItemCount(); i++)
 
432
  {
 
433
    CMenuItem item;
 
434
 
 
435
    item.fMask = MIIM_STATE | MIIM_ID | Get_fMaskForFTypeAndString();
 
436
    item.fType = MFT_STRING;
 
437
    if (g_FileMenu.GetItem(i, true, item))
 
438
    {
 
439
      if (!programMenu)
 
440
        if (item.wID == IDCLOSE)
 
441
          continue;
 
442
      /*
 
443
      bool createItem = (item.wID == IDM_CREATE_FOLDER || item.wID == IDM_CREATE_FILE);
 
444
      if (forFileMode)
 
445
      {
 
446
        if (createItem)
 
447
         continue;
 
448
      }
 
449
      else
 
450
      {
 
451
        if (!createItem)
 
452
         continue;
 
453
      }
 
454
      */
 
455
      if (destMenu.InsertItem(startPos, true, item))
 
456
        startPos++;
 
457
    }
 
458
  }
 
459
  while (destMenu.GetItemCount() > 0)
 
460
  {
 
461
    CMenuItem item;
 
462
    item.fMask = MIIM_TYPE;
 
463
    item.fType = 0;
 
464
    // item.dwTypeData = 0;
 
465
    int lastIndex = destMenu.GetItemCount() - 1;
 
466
    if (!destMenu.GetItem(lastIndex, true, item))
 
467
      break;
 
468
    if(item.fType != MFT_SEPARATOR)
 
469
      break;
 
470
    if (!destMenu.RemoveItem(lastIndex, MF_BYPOSITION))
 
471
      break;
 
472
  }
 
473
}
 
474
 
 
475
bool ExecuteFileCommand(int id)
 
476
{
 
477
  if (id >= kPluginMenuStartID)
 
478
  {
 
479
    g_App.GetFocusedPanel().InvokePluginCommand(id);
 
480
    g_App.GetFocusedPanel()._sevenZipContextMenu.Release();
 
481
    g_App.GetFocusedPanel()._systemContextMenu.Release();
 
482
    return true;
 
483
  }
 
484
 
 
485
  switch (id)
 
486
  {
 
487
    // File
 
488
    case IDM_FILE_OPEN:
 
489
      g_App.OpenItem();
 
490
      break;
 
491
    case IDM_FILE_OPEN_INSIDE:
 
492
      g_App.OpenItemInside();
 
493
      break;
 
494
    case IDM_FILE_OPEN_OUTSIDE:
 
495
      g_App.OpenItemOutside();
 
496
      break;
 
497
    case IDM_FILE_VIEW:
 
498
      break;
 
499
    case IDM_FILE_EDIT:
 
500
      g_App.EditItem();
 
501
      break;
 
502
    case IDM_RENAME:
 
503
      g_App.Rename();
 
504
      break;
 
505
    case IDM_COPY_TO:
 
506
      g_App.CopyTo();
 
507
      break;
 
508
    case IDM_MOVE_TO:
 
509
      g_App.MoveTo();
 
510
      break;
 
511
    case IDM_DELETE:
 
512
    {
 
513
      bool shift = (::GetKeyState(VK_SHIFT) & 0x8000) != 0;
 
514
      g_App.Delete(!shift);
 
515
      break;
 
516
    }
 
517
    case IDM_FILE_CRC:
 
518
      g_App.CalculateCrc();
 
519
      break;
 
520
    case IDM_FILE_SPLIT:
 
521
      g_App.Split();
 
522
      break;
 
523
    case IDM_FILE_COMBINE:
 
524
      g_App.Combine();
 
525
      break;
 
526
    case IDM_FILE_PROPERTIES:
 
527
      g_App.Properties();
 
528
      break;
 
529
    case IDM_FILE_COMMENT:
 
530
      g_App.Comment();
 
531
      break;
 
532
 
 
533
    case IDM_CREATE_FOLDER:
 
534
      g_App.CreateFolder();
 
535
      break;
 
536
    case IDM_CREATE_FILE:
 
537
      g_App.CreateFile();
 
538
      break;
 
539
    default:
 
540
      return false;
 
541
  } 
 
542
  return true;
 
543
}
 
544
 
 
545
bool OnMenuCommand(HWND hWnd, int id)
 
546
{
 
547
  if (ExecuteFileCommand(id))
 
548
    return true;
 
549
 
 
550
  switch (id)
 
551
  {
 
552
    // File
 
553
    case IDCLOSE:
 
554
      SendMessage(hWnd, WM_ACTIVATE, MAKEWPARAM(WA_INACTIVE, 0), (LPARAM)hWnd);
 
555
      SendMessage (hWnd, WM_CLOSE, 0, 0);
 
556
      break;
 
557
    
 
558
    // Edit
 
559
    case IDM_EDIT_CUT:
 
560
      g_App.EditCut();
 
561
      break;
 
562
    case IDM_EDIT_COPY:
 
563
      g_App.EditCopy();
 
564
      break;
 
565
    case IDM_EDIT_PASTE:
 
566
      g_App.EditPaste();
 
567
      break;
 
568
    case IDM_SELECT_ALL:
 
569
      g_App.SelectAll(true);
 
570
      g_App.RefreshStatusBar();
 
571
      break;
 
572
    case IDM_DESELECT_ALL:
 
573
      g_App.SelectAll(false);
 
574
      g_App.RefreshStatusBar();
 
575
      break;
 
576
    case IDM_INVERT_SELECTION:
 
577
      g_App.InvertSelection();
 
578
      g_App.RefreshStatusBar();
 
579
      break;
 
580
    case IDM_SELECT:
 
581
      g_App.SelectSpec(true);
 
582
      g_App.RefreshStatusBar();
 
583
      break;
 
584
    case IDM_DESELECT:
 
585
      g_App.SelectSpec(false);
 
586
      g_App.RefreshStatusBar();
 
587
      break;
 
588
    case IDM_SELECT_BY_TYPE:
 
589
      g_App.SelectByType(true);
 
590
      g_App.RefreshStatusBar();
 
591
      break;
 
592
    case IDM_DESELECT_BY_TYPE:
 
593
      g_App.SelectByType(false);
 
594
      g_App.RefreshStatusBar();
 
595
      break;
 
596
 
 
597
    //View
 
598
    case IDM_VIEW_LARGE_ICONS:
 
599
    case IDM_VIEW_SMALL_ICONS:
 
600
    case IDM_VIEW_LIST:
 
601
    case IDM_VIEW_DETAILS:
 
602
    {
 
603
      UINT index = id - IDM_VIEW_LARGE_ICONS;
 
604
      if (index < 4)
 
605
      {
 
606
        g_App.SetListViewMode(index);
 
607
        /*
 
608
        CMenu menu;
 
609
        menu.Attach(::GetSubMenu(::GetMenu(hWnd), kViewMenuIndex));
 
610
        menu.CheckRadioItem(IDM_VIEW_LARGE_ICONS, IDM_VIEW_DETAILS, 
 
611
            id, MF_BYCOMMAND);
 
612
        */
 
613
      }
 
614
      break;
 
615
    }
 
616
    case IDM_VIEW_ARANGE_BY_NAME:
 
617
    {
 
618
      g_App.SortItemsWithPropID(kpidName);
 
619
      break;
 
620
    }
 
621
    case IDM_VIEW_ARANGE_BY_TYPE:
 
622
    {
 
623
      g_App.SortItemsWithPropID(kpidExtension);
 
624
      break;
 
625
    }
 
626
    case IDM_VIEW_ARANGE_BY_DATE:
 
627
    {
 
628
      g_App.SortItemsWithPropID(kpidLastWriteTime);
 
629
      break;
 
630
    }
 
631
    case IDM_VIEW_ARANGE_BY_SIZE:
 
632
    {
 
633
      g_App.SortItemsWithPropID(kpidSize);
 
634
      break;
 
635
    }
 
636
    case IDM_VIEW_ARANGE_NO_SORT:
 
637
    {
 
638
      g_App.SortItemsWithPropID(kpidNoProperty);
 
639
      break;
 
640
    }
 
641
 
 
642
    case IDM_OPEN_ROOT_FOLDER:
 
643
      g_App.OpenRootFolder();
 
644
      break;
 
645
    case IDM_OPEN_PARENT_FOLDER:
 
646
      g_App.OpenParentFolder();
 
647
      break;
 
648
    case IDM_FOLDERS_HISTORY:
 
649
      g_App.FoldersHistory();
 
650
      break;
 
651
    case IDM_VIEW_REFRESH:
 
652
      g_App.RefreshView();
 
653
      break;
 
654
    case IDM_VIEW_FLAT_VIEW:
 
655
      g_App.ChangeFlatMode();
 
656
      break;
 
657
    case IDM_VIEW_TWO_PANELS:
 
658
      g_App.SwitchOnOffOnePanel();
 
659
      break;
 
660
    case IDM_VIEW_STANDARD_TOOLBAR:
 
661
      g_App.SwitchStandardToolbar();
 
662
      break;
 
663
    case IDM_VIEW_ARCHIVE_TOOLBAR:
 
664
      g_App.SwitchArchiveToolbar();
 
665
      break;
 
666
    case IDM_VIEW_TOOLBARS_SHOW_BUTTONS_TEXT:
 
667
      g_App.SwitchButtonsLables();
 
668
      break;
 
669
    case IDM_VIEW_TOOLBARS_LARGE_BUTTONS:
 
670
      g_App.SwitchLargeButtons();
 
671
      break;
 
672
 
 
673
    // Tools
 
674
    case IDM_OPTIONS:
 
675
      OptionsDialog(hWnd, g_hInstance);
 
676
      break;
 
677
          
 
678
    case IDM_BENCHMARK:
 
679
      Benchmark();
 
680
      break;
 
681
    // Help
 
682
    case IDM_HELP_CONTENTS:
 
683
      ShowHelpWindow(NULL, kFMHelpTopic);
 
684
      break;
 
685
    case IDM_ABOUT:
 
686
    {
 
687
      CAboutDialog dialog;
 
688
      dialog.Create(hWnd);
 
689
      break;
 
690
    }
 
691
    default:
 
692
    {
 
693
      if (id >= kOpenBookmarkMenuID && id <= kOpenBookmarkMenuID + 9)
 
694
      {
 
695
        g_App.OpenBookmark(id - kOpenBookmarkMenuID);
 
696
        return true;
 
697
      }
 
698
      else if (id >= kSetBookmarkMenuID && id <= kSetBookmarkMenuID + 9)
 
699
      {
 
700
        g_App.SetBookmark(id - kSetBookmarkMenuID);
 
701
        return true;
 
702
      }
 
703
      return false;
 
704
    }
 
705
  }
 
706
  return true;
 
707
}
 
708