CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 1999
    Location
    Bangalore, INDIA
    Posts
    70

    Please help: MDI / progress bar problem

    Hi all,
    i am working on a project which is an mdi with some (atleast 10) child forms.
    i need to show a progress bar dialog (with two progress bars, one total and one current and some labels and a cancel button)
    this progress bar is used by atleast 6 methods in the project, which have code to cancel the operation if the user presses cancel button
    in the progress dialog [all of them uses DoEvents])

    The problem is, the progress bar is never a modal form. so even if the progress bar is first in the z-order,
    i can still click all the menu items and toolbar buttons which creates a mess!.
    how can i avoid this problem.
    [one restriction is i cannot progress dialog with frmProgress.Show VbModal, frmMain]
    this is the last bit in my project. please help me how to solve this.
    regars,
    Sharath


  2. #2
    Join Date
    Dec 1999
    Location
    Dublin, Ireland
    Posts
    1,173

    Re: Please help: MDI / progress bar problem

    There are three parts to doing this:
    First set your dialog window to be the topmost window when you activate it

    private Sub Form_Activate()
    me.ZOrder vbBringToFront
    End Sub




    Second make your dialog box capture the mouse so that you cannot click on the other windows:

    '\\ Declarations....
    private Declare Function SetCaptureApi Lib "user32" Alias "SetCapture" (byval hwnd as Long) as Long
    Dim hOldCapture as Long

    private Sub Form_Load()
    hOldCapture = SetCaptureApi(me.hwnd)
    End Sub




    And finally prevent the CTRL+TAB type shortcut keys from switching windows. I think this needs Subclassing but we'll see if there's a simpler way first.

    HTH,
    Duncan

    -------------------------------------------------
    Ex. Datis: Duncan Jones
    Merrion Computing Ltd
    http://www.merrioncomputing.com
    '--8<-----------------------------------------
    NEW -The printer usage monitoring application
    '--8<------------------------------------------

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

Featured