Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Making the Disk Defragmenter a Modal dialog

Making the Disk Defragmenter a Modal dialog

Scheduled Pinned Locked Moved C / C++ / MFC
c++question
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    dipuks
    wrote on last edited by
    #1

    Hey I am opening the Disk Defragmenter from inside my C++ WIN32 app using the ShellExecuteEx function. Now i want to make sure that the Disk Defragmenter is a modal dialog, so that User is not able to click any part of my app. I set one window to EnableWindow(FALSE), but there are other frame windows which can be clicked by User and then the Disk Defragmenter will go hiding or to back ground. Is there one generic way of making the Disk Defragmenter a modal window so that nothing else on the back ground can be clicked? From the ShellExecuteEx function, i can get the process handle to Disk Defragmenter. Thanks in advance.

    C L 2 Replies Last reply
    0
    • D dipuks

      Hey I am opening the Disk Defragmenter from inside my C++ WIN32 app using the ShellExecuteEx function. Now i want to make sure that the Disk Defragmenter is a modal dialog, so that User is not able to click any part of my app. I set one window to EnableWindow(FALSE), but there are other frame windows which can be clicked by User and then the Disk Defragmenter will go hiding or to back ground. Is there one generic way of making the Disk Defragmenter a modal window so that nothing else on the back ground can be clicked? From the ShellExecuteEx function, i can get the process handle to Disk Defragmenter. Thanks in advance.

      C Offline
      C Offline
      Chris Meech
      wrote on last edited by
      #2

      You can try blocking using the following

      WaitForSingleObject(m_hProcess, INFINITE); // m_hProcess is the DD process handle

      This won't make DD modal, it will just block your app until DD is finished. :)

      Chris Meech I am Canadian. [heard in a local bar] In theory there is no difference between theory and practice. In practice there is. [Yogi Berra] posting about Crystal Reports here is like discussing gay marriage on a catholic church’s website.[Nishant Sivakumar]

      1 Reply Last reply
      0
      • D dipuks

        Hey I am opening the Disk Defragmenter from inside my C++ WIN32 app using the ShellExecuteEx function. Now i want to make sure that the Disk Defragmenter is a modal dialog, so that User is not able to click any part of my app. I set one window to EnableWindow(FALSE), but there are other frame windows which can be clicked by User and then the Disk Defragmenter will go hiding or to back ground. Is there one generic way of making the Disk Defragmenter a modal window so that nothing else on the back ground can be clicked? From the ShellExecuteEx function, i can get the process handle to Disk Defragmenter. Thanks in advance.

        L Offline
        L Offline
        Luc Pattyn
        wrote on last edited by
        #3

        I think I know how to do so in .NET, and I assume unmanaged code could do similar things: - give your app a modal form F, and make it sufficiently large to hold DD's main form; - let that form F call DD and set DD's main form's parent to F. I assume this function[^] does that. Now DD itself should behave as a modal dialog to your app. I have a managed app (C#) that does similar things with e.g. MS Word. :)

        Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum

        Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups