1 // CopyDialog.cpp
2 
3 #include "StdAfx.h"
4 
5 #include "../../../Windows/FileName.h"
6 
7 #include "../../../Windows/Control/Static.h"
8 
9 #include "BrowseDialog.h"
10 #include "CopyDialog.h"
11 
12 #ifdef LANG
13 #include "LangUtils.h"
14 #endif
15 
16 using namespace NWindows;
17 
OnInit()18 bool CCopyDialog::OnInit()
19 {
20   #ifdef LANG
21   LangSetDlgItems(*this, NULL, 0);
22   #endif
23   _path.Attach(GetItem(IDC_COPY));
24   SetText(Title);
25 
26   NControl::CStatic staticContol;
27   staticContol.Attach(GetItem(IDT_COPY));
28   staticContol.SetText(Static);
29   #ifdef UNDER_CE
30   // we do it, since WinCE selects Value\something instead of Value !!!!
31   _path.AddString(Value);
32   #endif
33   FOR_VECTOR (i, Strings)
34     _path.AddString(Strings[i]);
35   _path.SetText(Value);
36   SetItemText(IDT_COPY_INFO, Info);
37   NormalizeSize(true);
38   return CModalDialog::OnInit();
39 }
40 
OnSize(WPARAM,int xSize,int ySize)41 bool CCopyDialog::OnSize(WPARAM /* wParam */, int xSize, int ySize)
42 {
43   int mx, my;
44   GetMargins(8, mx, my);
45   int bx1, bx2, by;
46   GetItemSizes(IDCANCEL, bx1, by);
47   GetItemSizes(IDOK, bx2, by);
48   int y = ySize - my - by;
49   int x = xSize - mx - bx1;
50 
51   InvalidateRect(NULL);
52 
53   {
54     RECT r;
55     GetClientRectOfItem(IDB_COPY_SET_PATH, r);
56     int bx = RECT_SIZE_X(r);
57     MoveItem(IDB_COPY_SET_PATH, xSize - mx - bx, r.top, bx, RECT_SIZE_Y(r));
58     ChangeSubWindowSizeX(_path, xSize - mx - mx - bx - mx);
59   }
60 
61   {
62     RECT r;
63     GetClientRectOfItem(IDT_COPY_INFO, r);
64     NControl::CStatic staticContol;
65     staticContol.Attach(GetItem(IDT_COPY_INFO));
66     int yPos = r.top;
67     staticContol.Move(mx, yPos, xSize - mx * 2, y - 2 - yPos);
68   }
69 
70   MoveItem(IDCANCEL, x, y, bx1, by);
71   MoveItem(IDOK, x - mx - bx2, y, bx2, by);
72 
73   return false;
74 }
75 
OnButtonClicked(int buttonID,HWND buttonHWND)76 bool CCopyDialog::OnButtonClicked(int buttonID, HWND buttonHWND)
77 {
78   switch (buttonID)
79   {
80     case IDB_COPY_SET_PATH:
81       OnButtonSetPath();
82       return true;
83   }
84   return CModalDialog::OnButtonClicked(buttonID, buttonHWND);
85 }
86 
OnButtonSetPath()87 void CCopyDialog::OnButtonSetPath()
88 {
89   UString currentPath;
90   _path.GetText(currentPath);
91 
92   const UString title = LangString(IDS_SET_FOLDER);
93 
94   UString resultPath;
95   if (!MyBrowseForFolder(*this, title, currentPath, resultPath))
96     return;
97   NFile::NName::NormalizeDirPathPrefix(resultPath);
98   _path.SetCurSel(-1);
99   _path.SetText(resultPath);
100 }
101 
OnOK()102 void CCopyDialog::OnOK()
103 {
104   _path.GetText(Value);
105   CModalDialog::OnOK();
106 }
107