Results 1 to 4 of 4

Thread: How to make System Modal form

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2002
    Location
    FlyingOffice
    Posts
    178

    How to make System Modal form

    I have an exe (A), shell out another exe (B)

    What I want to do is keep A on the screen, but cannot get focus (like in modal form)
    and focus to B until B is unloaded

    Any Idea?

  2. #2
    Frenzied Member oh1mie's Avatar
    Join Date
    Sep 2001
    Location
    Finland
    Posts
    1,043
    Here we going...

    VB Code:
    1. Option Explicit
    2.  
    3. Public Const PROCESS_QUERY_INFORMATION = &H400
    4. Public Const STATUS_PENDING = &H103&
    5.  
    6. Public Declare Function OpenProcess Lib "kernel32" _
    7.  (ByVal dwDesiredAccess As Long, _
    8.   ByVal bInheritHandle As Long, _
    9.   ByVal dwProcessId As Long) As Long
    10.  
    11. Public Declare Function GetExitCodeProcess Lib "kernel32" _
    12.     (ByVal hProcess As Long, lpExitCode As Long) As Long
    13.  
    14. Public Declare Function CloseHandle Lib "kernel32" _
    15.    (ByVal hFile As Long) As Long
    16. Public Sub subShellAndWait(cmdline As String, Optional Param As Variant = 1)
    17.  
    18.     Dim hProcess  As Long
    19.     Dim ProcessId As Long
    20.     Dim exitCode  As Long
    21.    
    22.     ProcessId = Shell(cmdline, Param)
    23.     hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, False, ProcessId)
    24.  
    25.     Do
    26.       Call GetExitCodeProcess(hProcess, exitCode)
    27.       DoEvents
    28.     Loop While exitCode = STATUS_PENDING
    29.  
    30.     Call CloseHandle(hProcess)
    31.  
    32.     MsgBox "The shelled process " & cmdline & " has ended."
    33.  
    34. End Sub
    oh1mie/Vic


  3. #3

    Thread Starter
    Addicted Member
    Join Date
    May 2002
    Location
    FlyingOffice
    Posts
    178
    That is the code I am using now.

    But that will not make the original form modal, user can still click it and get the focus.

    I tried to have Me.Enabled in the original form, it works fine (it will not response to any click or keyboard event),
    except it got the focus.

  4. #4
    Fanatic Member Geespot's Avatar
    Join Date
    Oct 2001
    Location
    Birmingham, UK
    Posts
    577
    Is what you asking actually possible? because they are two complete seperate programs, so windows will treat them like two seperate programs.

    As far as i can see, it just isnt possible


    Though I could be wrong

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