Results 1 to 6 of 6

Thread: Disabling cancel in the SHFileOperation Dialog

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2012
    Posts
    433

    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?

  2. #2
    Default Member Bonnie West's Avatar
    Join Date
    Jun 2012
    Location
    InIDE
    Posts
    4,060

    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)

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2012
    Posts
    433

    Re: Disabling cancel in the SHFileOperation Dialog

    Quote Originally Posted by Bonnie West View Post
    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?

  4. #4
    Default Member Bonnie West's Avatar
    Join Date
    Jun 2012
    Location
    InIDE
    Posts
    4,060

    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)

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2012
    Posts
    433

    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?

  6. #6
    Default Member Bonnie West's Avatar
    Join Date
    Jun 2012
    Location
    InIDE
    Posts
    4,060

    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
  •  



Click Here to Expand Forum to Full Width