-
Jan 4th, 2013, 11:41 AM
#1
Thread Starter
Hyperactive Member
Disabling cancel in the SHFileOperation Dialog
I want to disable "Cancel" button of the SHFileOperation dialogbox.
I need this to prevent user from cancel during file copy.
Any idea?
-
Jan 4th, 2013, 12:23 PM
#2
Re: Disabling cancel in the SHFileOperation Dialog
Preventing the user from cancelling would be inconsiderate, but if you really need to do that, then you should just hide the dialog box altogether (with the flag FOF_SILENT). But, if you don't want to hide the progress dialog box, then you could try searching for the hWnd of that dialog box and when found, search for the hWnd of the child Cancel button and call EnableWindow on it. You could search for the windows using either FindWindow, FindWindowEx, EnumWindows or even through Hooking.
Last edited by Bonnie West; Jan 4th, 2013 at 12:26 PM.
On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)
-
Jan 4th, 2013, 12:53 PM
#3
Thread Starter
Hyperactive Member
Re: Disabling cancel in the SHFileOperation Dialog
Originally Posted by Bonnie West
Preventing the user from cancelling would be inconsiderate, but if you really need to do that, then you should just hide the dialog box altogether (with the flag FOF_SILENT). But, if you don't want to hide the progress dialog box, then you could try searching for the hWnd of that dialog box and when found, search for the hWnd of the child Cancel button and call EnableWindow on it. You could search for the windows using either FindWindow, FindWindowEx, EnumWindows or even through Hooking.
I want to hide dialog by FOF_SILENT flag.
But I want to get progress status and display it, for example ??% or progressbar. is it possible?
-
Jan 4th, 2013, 02:07 PM
#4
Re: Disabling cancel in the SHFileOperation Dialog
Anything's possible once you get hold of the dialog box's hWnd. But the problem is how to acquire it. One way is to use a Timer control to start the search for the dialog box using FindWindow. You would enable the Timer just before the call to SHFileOperation. In its Timer event you would look for the classname and/or the caption of the dialog box with the FindWindow API. Upon obtaining the hWnd, you may now perform whatever operation you want to the dialog box. The Timer's Interval property would have to be adjusted properly to give ample time for the dialog box to show up. The Timer may keep on firing until either the hWnd was found or a 'grace period' elapsed.
On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)
-
Jan 4th, 2013, 07:52 PM
#5
Thread Starter
Hyperactive Member
Re: Disabling cancel in the SHFileOperation Dialog
I decided to do silent mode.
But still have a problem
In case of FO_COPY, silent mode(FOF_SILENT) work.
But in case of FO_MOVE, silent mode(FOF_SILENT) doesn't work.
How do I solve this?
-
Jan 5th, 2013, 02:35 AM
#6
Re: Disabling cancel in the SHFileOperation Dialog
Try:
Code:
.fFlags = FOF_SILENT Or FOF_NOCONFIRMATION Or FOF_NOERRORUI Or FOF_NOCONFIRMMKDIR 'Same as FOF_NO_UI
If that still doesn't work, then you may resort to the method I outlined in post #4.
On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|