6 * Copyright (C) 2002 Robert Dickenson <robd@reactos.org>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
38 //#include <winspool.h>
53 BOOL CALLBACK
ExecuteDialogWndProc(HWND hDlg
, UINT message
, WPARAM wParam
, LPARAM lParam
)
55 static struct ExecuteDialog
* dlg
;
59 dlg
= (struct ExecuteDialog
*) lParam
;
66 GetWindowText(GetDlgItem(hDlg
, 201), dlg
->cmd
, MAX_PATH
);
67 dlg
->cmdshow
= Button_GetState(GetDlgItem(hDlg
,214))&BST_CHECKED
?
68 SW_SHOWMINIMIZED
: SW_SHOWNORMAL
;
70 } else if (id
== IDCANCEL
)
80 BOOL CALLBACK
OptionsConfirmationWndProc(HWND hDlg
, UINT message
, WPARAM wParam
, LPARAM lParam
)
82 static struct ExecuteDialog
* dlg
;
87 dlg
= (struct ExecuteDialog
*) lParam
;
88 Button_SetCheck(GetDlgItem(hDlg
,IDC_CONFIRMATION_FILE_DELETE
), Confirmation
& CONFIRM_FILE_DELETE
? BST_CHECKED
: BST_UNCHECKED
);
89 Button_SetCheck(GetDlgItem(hDlg
,IDC_CONFIRMATION_DIR_DELETE
), Confirmation
& CONFIRM_DIR_DELETE
? BST_CHECKED
: BST_UNCHECKED
);
90 Button_SetCheck(GetDlgItem(hDlg
,IDC_CONFIRMATION_FILE_REPLACE
), Confirmation
& CONFIRM_FILE_REPLACE
? BST_CHECKED
: BST_UNCHECKED
);
91 Button_SetCheck(GetDlgItem(hDlg
,IDC_CONFIRMATION_MOUSE_ACTIONS
), Confirmation
& CONFIRM_MOUSE_ACTIONS
? BST_CHECKED
: BST_UNCHECKED
);
92 Button_SetCheck(GetDlgItem(hDlg
,IDC_CONFIRMATION_DISK_COMMANDS
), Confirmation
& CONFIRM_DISK_COMMANDS
? BST_CHECKED
: BST_UNCHECKED
);
93 Button_SetCheck(GetDlgItem(hDlg
,IDC_CONFIRMATION_MODIFY_SYSTEM
), Confirmation
& CONFIRM_MODIFY_SYSTEM
? BST_CHECKED
: BST_UNCHECKED
);
98 GetWindowText(GetDlgItem(hDlg
, 201), dlg
->cmd
, MAX_PATH
);
99 dlg
->cmdshow
= Button_GetState(GetDlgItem(hDlg
,214))&BST_CHECKED
?SW_SHOWMINIMIZED
: SW_SHOWNORMAL
;
101 if (Button_GetState(GetDlgItem(hDlg
,IDC_CONFIRMATION_FILE_DELETE
)) & BST_CHECKED
)
102 Confirmation
|= CONFIRM_FILE_DELETE
;
103 else Confirmation
&= ~CONFIRM_FILE_DELETE
;
104 if (Button_GetState(GetDlgItem(hDlg
,IDC_CONFIRMATION_DIR_DELETE
)) & BST_CHECKED
)
105 Confirmation
|= CONFIRM_DIR_DELETE
;
106 else Confirmation
&= ~CONFIRM_DIR_DELETE
;
107 if (Button_GetState(GetDlgItem(hDlg
,IDC_CONFIRMATION_FILE_REPLACE
)) & BST_CHECKED
)
108 Confirmation
|= CONFIRM_FILE_REPLACE
;
109 else Confirmation
&= ~CONFIRM_FILE_REPLACE
;
110 if (Button_GetState(GetDlgItem(hDlg
,IDC_CONFIRMATION_MOUSE_ACTIONS
)) & BST_CHECKED
)
111 Confirmation
|= CONFIRM_MOUSE_ACTIONS
;
112 else Confirmation
&= ~CONFIRM_MOUSE_ACTIONS
;
113 if (Button_GetState(GetDlgItem(hDlg
,IDC_CONFIRMATION_DISK_COMMANDS
)) & BST_CHECKED
)
114 Confirmation
|= CONFIRM_DISK_COMMANDS
;
115 else Confirmation
&= ~CONFIRM_DISK_COMMANDS
;
116 if (Button_GetState(GetDlgItem(hDlg
,IDC_CONFIRMATION_MODIFY_SYSTEM
)) & BST_CHECKED
)
117 Confirmation
|= CONFIRM_MODIFY_SYSTEM
;
118 else Confirmation
&= ~CONFIRM_MODIFY_SYSTEM
;
121 } else if (id
== IDCANCEL
)
129 BOOL CALLBACK
ViewFileTypeWndProc(HWND hDlg
, UINT message
, WPARAM wParam
, LPARAM lParam
)
131 static struct ExecuteDialog
* dlg
;
136 dlg
= (struct ExecuteDialog
*)lParam
;
137 Button_SetCheck(GetDlgItem(hDlg
,IDC_VIEW_TYPE_DIRECTORIES
), ViewType
& VIEW_DIRECTORIES
? BST_CHECKED
: BST_UNCHECKED
);
138 Button_SetCheck(GetDlgItem(hDlg
,IDC_VIEW_TYPE_PROGRAMS
), ViewType
& VIEW_PROGRAMS
? BST_CHECKED
: BST_UNCHECKED
);
139 Button_SetCheck(GetDlgItem(hDlg
,IDC_VIEW_TYPE_DOCUMENTS
), ViewType
& VIEW_DOCUMENTS
? BST_CHECKED
: BST_UNCHECKED
);
140 Button_SetCheck(GetDlgItem(hDlg
,IDC_VIEW_TYPE_OTHERS
), ViewType
& VIEW_OTHER
? BST_CHECKED
: BST_UNCHECKED
);
141 Button_SetCheck(GetDlgItem(hDlg
,IDC_VIEW_TYPE_SYSFILES
), ViewType
& VIEW_SYSTEM
? BST_CHECKED
: BST_UNCHECKED
);
146 GetWindowText(GetDlgItem(hDlg
, 201), dlg
->cmd
, MAX_PATH
);
147 dlg
->cmdshow
= Button_GetState(GetDlgItem(hDlg
,214))&BST_CHECKED
?SW_SHOWMINIMIZED
: SW_SHOWNORMAL
;
149 if (Button_GetState(GetDlgItem(hDlg
,IDC_VIEW_TYPE_DIRECTORIES
)) & BST_CHECKED
)
150 ViewType
|= VIEW_DIRECTORIES
;
151 else ViewType
&= ~VIEW_DIRECTORIES
;
152 if (Button_GetState(GetDlgItem(hDlg
,IDC_VIEW_TYPE_PROGRAMS
)) & BST_CHECKED
)
153 ViewType
|= VIEW_PROGRAMS
;
154 else ViewType
&= ~VIEW_PROGRAMS
;
155 if (Button_GetState(GetDlgItem(hDlg
,IDC_VIEW_TYPE_DOCUMENTS
)) & BST_CHECKED
)
156 ViewType
|= VIEW_DOCUMENTS
;
157 else ViewType
&= ~VIEW_DOCUMENTS
;
158 if (Button_GetState(GetDlgItem(hDlg
,IDC_VIEW_TYPE_OTHERS
)) & BST_CHECKED
)
159 ViewType
|= VIEW_OTHER
;
160 else ViewType
&= ~VIEW_OTHER
;
161 if (Button_GetState(GetDlgItem(hDlg
,IDC_VIEW_TYPE_SYSFILES
)) & BST_CHECKED
)
162 ViewType
|= VIEW_SYSTEM
;
163 else ViewType
&= ~VIEW_SYSTEM
;
165 } else if (id
== IDCANCEL
)
172 ////////////////////////////////////////////////////////////////////////////////
175 [in] Specifies the total size of the file, in bytes.
176 TotalBytesTransferred
177 [in] Specifies the total number of bytes transferred from the source file to the destination file since the copy operation began.
179 [in] Specifies the total size of the current file stream, in bytes.
180 StreamBytesTransferred
181 [in] Specifies the total number of bytes in the current stream that have been transferred from the source file to the destination file since the copy operation began.
183 [in] Handle to the current stream. The stream number is 1 the first time CopyProgressRoutine is called.
185 [in] Specifies the reason that CopyProgressRoutine was called. This parameter can be one of the following values. Value Meaning
186 CALLBACK_CHUNK_FINISHED Another part of the data file was copied.
187 CALLBACK_STREAM_SWITCH Another stream was created and is about to be copied. This is the callback reason given when the callback routine is first invoked.
191 [in] Handle to the source file.
193 [in] Handle to the destination file
195 [in] The argument passed to CopyProgressRoutine by the CopyFileEx or MoveFileWithProgress function.
197 The CopyProgressRoutine function should return one of the following values.
200 PROGRESS_CONTINUE Continue the copy operation.
201 PROGRESS_CANCEL Cancel the copy operation and delete the destination file.
202 PROGRESS_STOP Stop the copy operation. It can be restarted at a later time.
203 PROGRESS_QUIET Continue the copy operation, but stop invoking CopyProgressRoutine to report progress.
205 DWORD CALLBACK
CopyProgressRoutine(
206 LARGE_INTEGER TotalFileSize
, // file size
207 LARGE_INTEGER TotalBytesTransferred
, // bytes transferred
208 LARGE_INTEGER StreamSize
, // bytes in stream
209 LARGE_INTEGER StreamBytesTransferred
, // bytes transferred for stream
210 DWORD dwStreamNumber
, // current stream
211 DWORD dwCallbackReason
, // callback reason
212 HANDLE hSourceFile
, // handle to source file
213 HANDLE hDestinationFile
, // handle to destination file
214 LPVOID lpData
// from CopyFileEx
220 BOOL CALLBACK
MoveFileWndProc(HWND hDlg
, UINT message
, WPARAM wParam
, LPARAM lParam
)
222 static struct ExecuteDialog
* dlg
;
224 TCHAR buffer_from
[1000];
225 TCHAR buffer_to
[1000];
229 dlg
= (struct ExecuteDialog
*)lParam
;
231 _tcscpy(buffer_from
, _T("C:\\TEMP\\API_SPY\\TEMP\\foobar.txt"));
232 SetDlgItemText(hDlg
, IDC_FILE_MOVE_FROM
, buffer_from
);
233 _tcscpy(buffer_to
, _T("C:\\TEMP\\API_SPY\\TEMP\\foobar2.txt"));
234 SetDlgItemText(hDlg
, IDC_FILE_MOVE_TO
, buffer_to
);
236 Button_SetCheck(GetDlgItem(hDlg,IDC_VIEW_TYPE_DIRECTORIES), ViewType & VIEW_DIRECTORIES ? BST_CHECKED : BST_UNCHECKED);
242 LPVOID lpData
= NULL
; // parameter for callback
243 DWORD dwFlags
= MOVEFILE_COPY_ALLOWED
; // move options
245 GetDlgItemText(hDlg
, IDC_FILE_MOVE_FROM
, buffer_from
, sizeof(buffer_from
));
246 GetDlgItemText(hDlg
, IDC_FILE_MOVE_TO
, buffer_to
, sizeof(buffer_to
));
248 BOOL MoveFileWithProgress(
249 LPCTSTR lpExistingFileName, // file name
250 LPCTSTR lpNewFileName, // new file name
251 LPPROGRESS_ROUTINE lpProgressRoutine, // callback function
252 LPVOID lpData, // parameter for callback
253 DWORD dwFlags // move options
256 DWORD dwFlags, // source and processing options
257 LPCVOID lpSource, // message source
258 DWORD dwMessageId, // message identifier
259 DWORD dwLanguageId, // language identifier
260 LPTSTR lpBuffer, // message buffer
261 DWORD nSize, // maximum size of message buffer
262 va_list *Arguments // array of message inserts
265 // if (!MoveFileWithProgress(buffer_from, buffer_to, &CopyProgressRoutine, lpData, dwFlags)) {
266 if (!MoveFileEx(buffer_from
, buffer_to
, dwFlags
)) {
267 DWORD err
= GetLastError();
269 if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER
| FORMAT_MESSAGE_FROM_SYSTEM
, NULL
, err
, 0, (LPTSTR
)&hMem
, 10, NULL
)) {
270 MessageBox(hDlg
, hMem
, szTitle
, MB_OK
);
273 MessageBox(hDlg
, _T("Unknown Error"), szTitle
, MB_OK
);
278 } else if (id
== IDCANCEL
)
287 extern TCHAR ViewTypeMaskStr[MAX_TYPE_MASK_LEN];