1 #ifndef AFX_ARCVIEWDLG_H__91EDF9F6_142E_4E25_BCE3_448E937E29D9__INCLUDED_
2 #define AFX_ARCVIEWDLG_H__91EDF9F6_142E_4E25_BCE3_448E937E29D9__INCLUDED_
3
4 #include "NoahApp.h"
5 #include "Archiver.h"
6 #include "resource.h"
7
8 class CArcViewDlg : public kiDialog, kiDataObject
9 {
10 public:
11 CArcViewDlg( CArchiver* ptr,arcname& fnm,const kiPath& ddir )
12 : kiDialog( IDD_ARCVIEW ), m_pArc( ptr ),
13 m_fname( fnm ), m_ddir( ddir )
14 {
15 AddRef();
16 myapp().get_tempdir( m_tdir );
17 }
18
19 private: //-- ダイアログとしての処理
20
21 BOOL CALLBACK proc( UINT msg, WPARAM wp, LPARAM lp );
22 BOOL onInit();
23 bool onOK();
24 bool onCancel();
25 void setdir()
26 {
27 char str[MAX_PATH];
28 sendMsgToItem( IDC_DDIR, WM_GETTEXT, MAX_PATH, (LPARAM)str );
29 m_ddir = str;
30 m_ddir.beBackSlash( true );
31 m_ddir.mkdir();
32 m_ddir.beShortPath();
33 }
34 bool setSelection()
35 {
36 bool x=false;
37 LVITEM it;
38 it.mask = (LVIF_PARAM | LVIF_STATE);
39 it.iSubItem = 0;
40 it.stateMask = LVIS_SELECTED;
41 for( it.iItem=0; sendMsgToItem( IDC_FILELIST, LVM_GETITEM, 0, (LPARAM)&it ); it.iItem++ )
42 if( ((arcfile*)it.lParam)->selected = (0!=(LVIS_SELECTED&it.state)) )
43 x = true;
44 return x;
45 }
46 int hlp_cnt_check();
47 bool m_bAble;
48
49 private: //-- ドラッグ&ドロップ処理
50
51 bool giveData( const FORMATETC& fmt, STGMEDIUM* stg, bool firstcall );
52
53 private: //-- ソート処理
54
55 void DoSort( int col );
56 static int CALLBACK lv_compare( LPARAM p1, LPARAM p2, LPARAM type );
57 bool m_bSmallFirst[6];
58
59 private: //-- 右クリック
60
61 void DoRMenu();
62 void GenerateDirMenu( HMENU m, int& id, StrArray* sx, const kiPath& pth );
63
64 private: //-- 解凍作業
65
66 CArchiver* m_pArc;
67 arcname m_fname;
68 kiPath m_ddir, m_tdir;
69 aflArray m_files;
70
71 //-- 存在しているウインドウ数管理。
72 public: static void clear() { st_nLife=0; }
73 private:static void hello() { st_nLife++; }
74 static void byebye() { if(--st_nLife==0) kiWindow::loopbreak(); }
75 static int st_nLife;
76 };
77
78
79 class CArcPwdDlg : public kiDialog
80 {
81 char *buf;
82 const char *nam;
83 int siz;
84 public:
85 CArcPwdDlg( HWND h, char* x, int s, const char* n ) : kiDialog( IDD_PASSWORD ), buf(x), siz(s), nam(n)
86 {
87 doModal( h );
88 }
89 BOOL onInit()
90 {
91 sendMsgToItem( IDC_MASK, BM_SETCHECK, BST_CHECKED );
92 sendMsgToItem( IDC_EDIT, EM_SETLIMITTEXT, siz );
93 sendMsgToItem( IDC_EDIT, EM_SETPASSWORDCHAR, '*' );
94 sendMsg( WM_SETTEXT, 0, (LPARAM)nam );
95 ::SetFocus( item(IDC_EDIT) );
96 return TRUE;
97 }
98 BOOL CALLBACK proc( UINT msg, WPARAM wp, LPARAM lp )
99 {
100 if( msg==WM_COMMAND && LOWORD(wp)==IDC_MASK )
101 {
102 if( BST_CHECKED==sendMsgToItem( IDC_MASK, BM_GETCHECK ) )
103 sendMsgToItem( IDC_EDIT, EM_SETPASSWORDCHAR, '*' );
104 else
105 sendMsgToItem( IDC_EDIT, EM_SETPASSWORDCHAR );
106 ::InvalidateRect( item(IDC_EDIT), NULL, TRUE );
107 }
108 return FALSE;
109 }
110 bool onOK()
111 {
112 sendMsgToItem( IDC_EDIT, WM_GETTEXT, siz, (LPARAM)buf );
113 return true;
114 }
115 };
116
117 class CArcProgressDlg : public kiDialog
118 {
119 unsigned int bl;
120 public:
121 CArcProgressDlg( unsigned int barlimit, bool packing=false )
122 : kiDialog( IDD_PROGRESS ), bl( barlimit )
123 {
124 createModeless();
125 if( bl<0x10000 )
126 sendMsgToItem( IDC_BAR, PBM_SETRANGE, 0, MAKELPARAM(0,bl) );
127 if( packing )
128 sendMsg( WM_SETTEXT, 0, (LPARAM)"Compressing..." );
129 kiWindow::setFront( hwnd() );
130 msgloop();
131 }
132 ~CArcProgressDlg()
133 {
134 if( isAlive() )
135 end( IDCANCEL );
136 }
137 bool msgloop()
138 {
139 kiWindow::msg();
140 return isAlive();
141 }
142 void change( const char* name=NULL, unsigned int pos=0xffffffff )
143 {
144 if( name ) sendMsgToItem( IDC_FNAME, WM_SETTEXT, 0, (LPARAM)name );
145 if( pos!=0xffffffff )
146 if( bl<0x10000 )sendMsgToItem( IDC_BAR, PBM_SETPOS, pos );
147 else sendMsgToItem( IDC_BAR, PBM_SETPOS, pos*100/bl );
148 }
149 };
150
151
152 class CArcPathCheckDlg
153 {
154 private:
155 class TheDlg : public kiDialog
156 {
157 public:
158 TheDlg( const char* path, HWND h )
159 : kiDialog(IDD_PATHCHECK), result(CANCEL), path(path) { doModal(h); }
160 enum { YES, ALL_YES, CANCEL } result;
161 private:
162 const char* path;
163 BOOL onInit()
164 {
165 sendMsgToItem( IDC_PATHNAME, WM_SETTEXT, 0, (LPARAM)path );
166 return TRUE;
167 }
168 BOOL CALLBACK proc( UINT msg, WPARAM wp, LPARAM lp )
169 {
170 if( msg==WM_COMMAND )
171 switch( LOWORD(wp) )
172 {
173 case IDYES: result = YES; end(IDOK); return TRUE;
174 case ID_ALLYES: result = ALL_YES; end(IDOK); return TRUE;
175 case ID_ALLNO: result = CANCEL; end(IDCANCEL); return TRUE;
176 }
177 return FALSE;
178 }
179 };
180
181 private:
182 bool all_yes;
183
184 public:
185 CArcPathCheckDlg() : all_yes(false) {}
186
187 bool is_ok_to_extract( const char* path, kiWindow* wnd )
188 {
189 if( all_yes )
190 return true;
191 switch( TheDlg(path,wnd?wnd->hwnd():NULL).result )
192 {
193 case TheDlg::ALL_YES: all_yes = true;
194 case TheDlg::YES: return true;
195 }
196 return false;
197 }
198 };
199
200
201 #endif