I downloaded a bit of code from:
This works fine but I want to be able to disable the cancel button on the progress dialog. How could I do this? The code I use is :
int CFolderToolDlg::CopyFolders(char *szSourceFolderPath, char *szDestFolderPath)
{
CShellFileOp sfo; //use the CShellFileOp wrapper, it makes using the shell object easier
BOOL bAPICalled;
int nAPIReturnVal=0;
char Message[genericStringSize] = "Copying : ";
strcat(Message, szSourceFolderPath);
strcat(Message, " TO : "
;
strcat(Message,szDestFolderPath);
WriteToLog WriteMessage(Message, LogFilePath1);
sfo.AddSourceFile(szSourceFolderPath);
sfo.AddDestFile(szDestFolderPath);
// Set up a few flags that control the operation.
sfo.SetOperationFlags
( FO_COPY, // the operation type (copy in this case)
AfxGetMainWnd(), // pointer to parent window
FALSE, // flag - silent mode?
FALSE, // flag - allow undo?
FALSE, // flag - should wild cards affect files only?
TRUE, // flag - suppress confirmation messages?
TRUE, // flag - suppress confirmation messages when making directories?
FALSE, // flag - rename files when name collisions occur?
FALSE ); // flag - simple progress dialog?
// Start the operation.
if ( sfo.Go ( &bAPICalled, &nAPIReturnVal ) )
{
// The operation succeeded!
strcpy(Message, "Copyied : "
;
strcat(Message, szSourceFolderPath);
strcat(Message, " TO : "
;
strcat(Message,szDestFolderPath);
WriteMessage.Write(Message, LogFilePath1);
return(nAPIReturnVal);
}
else
{
if ( !bAPICalled )
{
AfxMessageBox("SHFileOperation() wasn't called"
;
// SHFileOperation() wasn't called - check the info you passed
// in to the CShellFileOp object. The DEBUG version will
// throw ASSERTs and/or show TRACE messages to help you out.
}
else
{
AfxMessageBox("SHFileOperation() returned nonzero (failure)"
;
// SHFileOperation() returned nonzero (failure). That return
// value is now in nAPIReturnVal.
}
}
return(nAPIReturnVal);
}
This works fine but I want to be able to disable the cancel button on the progress dialog. How could I do this? The code I use is :
int CFolderToolDlg::CopyFolders(char *szSourceFolderPath, char *szDestFolderPath)
{
CShellFileOp sfo; //use the CShellFileOp wrapper, it makes using the shell object easier
BOOL bAPICalled;
int nAPIReturnVal=0;
char Message[genericStringSize] = "Copying : ";
strcat(Message, szSourceFolderPath);
strcat(Message, " TO : "
strcat(Message,szDestFolderPath);
WriteToLog WriteMessage(Message, LogFilePath1);
sfo.AddSourceFile(szSourceFolderPath);
sfo.AddDestFile(szDestFolderPath);
// Set up a few flags that control the operation.
sfo.SetOperationFlags
( FO_COPY, // the operation type (copy in this case)
AfxGetMainWnd(), // pointer to parent window
FALSE, // flag - silent mode?
FALSE, // flag - allow undo?
FALSE, // flag - should wild cards affect files only?
TRUE, // flag - suppress confirmation messages?
TRUE, // flag - suppress confirmation messages when making directories?
FALSE, // flag - rename files when name collisions occur?
FALSE ); // flag - simple progress dialog?
// Start the operation.
if ( sfo.Go ( &bAPICalled, &nAPIReturnVal ) )
{
// The operation succeeded!
strcpy(Message, "Copyied : "
strcat(Message, szSourceFolderPath);
strcat(Message, " TO : "
strcat(Message,szDestFolderPath);
WriteMessage.Write(Message, LogFilePath1);
return(nAPIReturnVal);
}
else
{
if ( !bAPICalled )
{
AfxMessageBox("SHFileOperation() wasn't called"
// SHFileOperation() wasn't called - check the info you passed
// in to the CShellFileOp object. The DEBUG version will
// throw ASSERTs and/or show TRACE messages to help you out.
}
else
{
AfxMessageBox("SHFileOperation() returned nonzero (failure)"
// SHFileOperation() returned nonzero (failure). That return
// value is now in nAPIReturnVal.
}
}
return(nAPIReturnVal);
}