Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I downloaded a bit of code from: h

Status
Not open for further replies.

nerram

Programmer
Apr 23, 2003
56
IE
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);
}
 
find the handle of your button and use EnableWindow(TRUE or FALSE)..

Ion Filipski
1c.bmp

ICQ: 95034075
AIM: IonFilipski
filipski@excite.com
 
How do you find this handle? Where would you start?
 
I think there should be some CWnd* member variables. If not, try to find the ID and use GetDlgItem to egt the handle.

Ion Filipski
1c.bmp

ICQ: 95034075
AIM: IonFilipski
filipski@excite.com
 
IonFililski,
The only reference to CWnd I can find relates to the parent window. However there is hwnd which is a member of the SHFILEOPSTRUCT. The msdn describes this as:
hwnd
Window handle to the dialog box to display information about the status of the file operation.

In GetDlgItem(hwnd,???) what goes in for ??? to disable this window and in your post what does egt mean.
Regards,
nerram.
 
if you have only handle to your dialog, try to use

EnumChildWindows(....
get the text of each window, and find the window you need.

Ion Filipski
1c.bmp

ICQ: 95034075
AIM: IonFilipski
filipski@excite.com
 
Look in the resource view at the identifier for the control (something like IDC_BUTTON1). Then use the following:
GetDlgItem(IDC_BUTTON1)->ShowWindow(FALSE);
 
>stupidog
read attentive, there is no resource.

Ion Filipski
1c.bmp

ICQ: 95034075
AIM: IonFilipski
filipski@excite.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top