1 // SplitDialog.cpp
2 
3 #include "StdAfx.h"
4 #include "SplitDialog.h"
5 
6 #include "Common/StringToInt.h"
7 #include "Windows/Shell.h"
8 #include "Windows/FileName.h"
9 
10 #include "SplitUtils.h"
11 #ifdef LANG
12 #include "LangUtils.h"
13 #endif
14 
15 #include "CopyDialogRes.h"
16 
17 using namespace NWindows;
18 
19 #ifdef LANG
20 static CIDLangPair kIDLangPairs[] =
21 {
22   { IDC_STATIC_SPLIT_PATH, 0x03020501 },
23   { IDC_STATIC_SPLIT_VOLUME, 0x02000D40 },
24 };
25 #endif
26 
27 
OnInit()28 bool CSplitDialog::OnInit()
29 {
30   #ifdef LANG
31   LangSetWindowText(HWND(*this), 0x03020500);
32   LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0]));
33   #endif
34   _pathCombo.Attach(GetItem(IDC_COMBO_SPLIT_PATH));
35   _volumeCombo.Attach(GetItem(IDC_COMBO_SPLIT_VOLUME));
36 
37   if (!FilePath.IsEmpty())
38   {
39     UString title;
40     GetText(title);
41     title += L' ';
42     title += FilePath;
43     SetText(title);
44   }
45   _pathCombo.SetText(Path);
46   AddVolumeItems(_volumeCombo);
47   _volumeCombo.SetCurSel(0);
48   return CModalDialog::OnInit();
49 }
50 
OnButtonClicked(int buttonID,HWND buttonHWND)51 bool CSplitDialog::OnButtonClicked(int buttonID, HWND buttonHWND)
52 {
53   switch(buttonID)
54   {
55     case IDC_BUTTON_SPLIT_PATH:
56       OnButtonSetPath();
57       return true;
58   }
59   return CModalDialog::OnButtonClicked(buttonID, buttonHWND);
60 }
61 
OnButtonSetPath()62 void CSplitDialog::OnButtonSetPath()
63 {
64   UString currentPath;
65   _pathCombo.GetText(currentPath);
66   // UString title = L"Specify a location for output folder";
67   UString title = LangStringSpec(IDS_SET_FOLDER, 0x03020209);
68 
69   UString resultPath;
70   if (!NShell::BrowseForFolder(HWND(*this), title, currentPath, resultPath))
71     return;
72   NFile::NName::NormalizeDirPathPrefix(resultPath);
73   _pathCombo.SetCurSel(-1);
74   _pathCombo.SetText(resultPath);
75 }
76 
OnOK()77 void CSplitDialog::OnOK()
78 {
79   _pathCombo.GetText(Path);
80   UString volumeString;
81   _volumeCombo.GetText(volumeString);
82   volumeString.Trim();
83   if (!ParseVolumeSizes(volumeString, VolumeSizes) || VolumeSizes.Size() == 0)
84   {
85     ::MessageBoxW(*this, LangString(IDS_COMPRESS_INCORRECT_VOLUME_SIZE, 0x02000D41), L"7-Zip", 0);
86     return;
87   }
88   CModalDialog::OnOK();
89 }
90