Results 1 to 4 of 4

Thread: How to run a process modally?

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2003
    Location
    C:\Windows\Microsoft.NET\Framework
    Posts
    574

    How to run a process modally?

    Process A starts process B. How does process A ensure that process B's window runs modally?

  2. #2
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    Re: How to run a process modally?

    I hope this works
    Code:
                Control c = Control.FromHandle(proc.MainWindowHandle);
                if(c is Form){
                    return ((Form)c).Modal;
                }
    By the way, it's 2.0
    "I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
    My Blog

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2003
    Location
    C:\Windows\Microsoft.NET\Framework
    Posts
    574

    Re: How to run a process modally?

    Thanks. Even though that code doesn't work (because c always evaluates to null), I got a cue enough to wend my way:

    At least I got a handle of that process, which if I were on my own, I would have procured through PROCESS_INFO, CreateThreadProcessID, GetWindowFromProcessID etc.

    Now, I can call SetParent(hWnd, hWndParent) on that window handle. Won't make it modal but will help a great deal.

    Thanks again.

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: How to run a process modally?

    I'm not sure that you understand what "modal" means. A modal window is one that sits on top of another and doesn't allow access to that other form until the modal form is dismissed. If you want your app to do that with an external executable then you do it like this:
    VB Code:
    1. Process p = Process.Start("executable path here");
    2.  
    3. p.WaitForExit();
    Now your app will block until the app you started exits. If you want to do this with an existing process then you need to create a Process object for that running process.

    From what you posted in post #3 it looks like you want to make an external application's window an MDI child of your own. Which is it?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

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