Results 1 to 12 of 12

Thread: [VB6] Class to show a standard Explorer-style progress window

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    5,654

    [VB6] Class to display a standard Explorer-style progress window


    cProgressWindow

    Windows provides a simple interface that allows you to use an asychronous Explorer-style progress dialog with just a few lines of code. So I thought I'd wrap up this functionality in a class to make it a bit easier to use, especially with automating checking for cancel, raising an event for it, and closing the dialog.

    It's all pretty self-explanatory... the class comes with a demo project that shows usage of the most basic options, and the class itself implements all the functionality (except setting an animation, because that's only supported in XP).

    Requirements
    Windows XP or newer
    oleexp.tlb, any version (or olelib)

    Future Work

    If you're working with files, you may want the more detailed progress window that you get with IFileOperation and Explorer in Windows 7... you can manually control such a progress dialog in a manner similar to this one with another interface supported by the same ProgressDialog object, IOperationsProgressDialog. You can then use it like this or as the custom dialog from IFileOperation.SetProgressDialog.
    I'll be putting up a demo of using that interface in a few days, but if you wanted to experiment in the mean time, all the definitions are already in oleexp (but this one isn't XP compatible and not present in olelib), and you can create an instance of it via
    Code:
    Dim cProg As IOperationsProgressDialog
    Set cProg = New ProgressDialog
    Note that with this version, your first call must be .StartProgressDialog, or you get a 'catastrophic error' message. Also always use .SetMode, or the dialog might just flash at the end of the operation instead of show throughout.

    Attached Files Attached Files
    Last edited by fafalone; Mar 17th, 2020 at 05:44 AM.

  2. #2
    Lively Member
    Join Date
    Sep 2016
    Location
    Texas panhandle
    Posts
    64

    Re: [VB6] Class to show a standard Explorer-style progress window

    Thanks for sharing
    Using oleexp3 v 3.1
    Got it to work with this change
    lFlag = SPBEGINF_MARQUEEPROGRESS ' PROGDLG_MARQUEEPROGRESS

  3. #3
    Fanatic Member
    Join Date
    Jul 2007
    Location
    Essex, UK.
    Posts
    578

    Re: [VB6] Class to show a standard Explorer-style progress window

    This is great. I haven't needed to adjust a Flag setting (Win 10 64).

    However it takes ages to appear, could this be made instant?

  4. #4
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    5,872

    Re: [VB6] Class to show a standard Explorer-style progress window

    Works fine for me on Win10 64bit, but also takes 4 to 5 seconds to appear

  5. #5
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,869

    Re: [VB6] Class to show a standard Explorer-style progress window

    Hi fafalone,

    This actually looks pretty cool. I've got many things I do that take a bit of time, most to do with Word and Excel automation. I've got this clunky "Working" window I throw onto the screen, and I'm considering swapping it out with your work. But, a few questions, if you don't mind:

    1) Can you have it display without the "Cancel" button?

    2) Can you programmatically position it anywhere on the screen? My users like my "Working" box to display up in the top-left corner.

    3) Does it have an option for a "Show More", similar to when Windows is doing a large copy? In certain instances, I will need to update my users to how things are progressing. For example, here's a snippet of how I use my "Working" form:

    Code:
    
        Working frm, True
        '
        WorkingLabel "Creating Multi-Cycle Ascii File."
        CreateMultiCycleEmgAsciiFile
        WorkingLabel "Creating Single-Cycle Ascii File."
        CreateSingleCycleEmgAsciiFile
        '
        WorkingLabel "Starting Excel EMG Worksheet."
    
    
        ' etcetera
    
    
    Thanks Much,
    Elroy
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  6. #6
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: [VB6] Class to show a standard Explorer-style progress window

    @Elroy. Here is the link for that interface. fafalone forgot to reference it

    As for your questions:
    1. No Cancel button. Yes for Vista+. It's an optional flag in the StartProgressDialog function: PROGDLG_NOCANCEL

    2. Positioning dialog. Don't see anywhere that the interface offers the dialog's hWnd. But we can typically get this by creating a hook just before displaying it, wait for dialog to be created, then positioning it and removing the hook

    3. Changing the text. Yes. In the class that fafalone provided are comments regarding that.
    Note: There is no "show more" option that I see. The TaskDialog implementation (Vista+ message box overhaul) offers that functionality along with progress bar but IIRC can't opt for button-free dialog without a bit of work to find the default "Ok" button and hide it. Can you disable it instead? Maybe, don't recall at the moment.
    Last edited by LaVolpe; Jan 6th, 2018 at 11:06 AM.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  7. #7
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,869

    Re: [VB6] Class to show a standard Explorer-style progress window

    @LaVolpe: Thanks. I'm not going to jump on this today, but it's definitely going on the "todo" list. Here's my little "Working" form that I currently use:

    Name:  Working.png
Views: 1467
Size:  3.4 KB

    I just change that lower label to report to the user what step we're on. It would take a bit of work, but I could estimate the percentage done as well. I suppose I could build my own bleed-bar, but just letting Windows take care of it sounds nice.

    Again, Thanks,
    Elroy
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  8. #8
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,869

    Re: [VB6] Class to show a standard Explorer-style progress window

    I just did a large copy. It's actually the "More details" "Fewer details" option that's nice. I could totally see my way to reporting my progress details in that area.

    I'm also wondering when that got introduced in Windows.
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  9. #9
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: [VB6] Class to show a standard Explorer-style progress window

    Quote Originally Posted by Elroy View Post
    I just did a large copy. It's actually the "More details" "Fewer details" option that's nice. I could totally see my way to reporting my progress details in that area.

    I'm also wondering when that got introduced in Windows.
    IOperationsProgressDialog usage gives you the "More/Fewer Details" option. That interface can be applied via IFileOperation which is the modern replacement for SHFileOperation API. Offered with Vista and beyond. The details button doesn't exist with the standard IProgressDialog shown in this posting. IProgressDialog is basically a generic, somewhat customizable, dialog.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  10. #10
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,869

    Re: [VB6] Class to show a standard Explorer-style progress window

    Thank you, LaVolpe.
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  11. #11

    Thread Starter
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    5,654

    Re: [VB6] Class to show a standard Explorer-style progress window

    The Show More option is part of IOperationsProgressDialog that's supported by the same default implementation (CLSID_ProgressDialog ProgressDialog object in the tlb). There's a note about it at the bottom of the first post (Future Work); you can use it just like this one too and I'll be posting a similar class for it soon; haven't been able to check in here for a couple days, sorry.

  12. #12
    Junior Member SaschaT's Avatar
    Join Date
    Mar 2017
    Location
    Berlin, Germany
    Posts
    23

    Resolved Re: [VB6] Class to show a standard Explorer-style progress window

    Quote Originally Posted by Elroy View Post
    ...
    2) Can you programmatically position it anywhere on the screen? My users like my "Working" box to display up in the top-left corner.
    ...
    Elroy
    Using an interface scanner I found out that ProgressDialog also supports these interfaces:
    IOperationsProgressDialog, IActionProgressDialog, IActionProgress, IObjectWithSite, IOleWindow

    Take the latter one to position the window altering the procedure OpenProgressWindow in the class e.g. as follows:
    Code:
    Public Sub OpenProgressWindow(dwFlags As PROGDLG, Optional hWndOwner As Long = 0&)
        m_hOwner = hWndOwner
        m_lFlag = dwFlags
        cProg.StartProgressDialog m_hOwner, Nothing, m_lFlag
        
        Dim IOLEW As IOleWindow
        Dim hwnd As Long
        Const SWP_NOSIZE = 1&
        Const SWP_SHOWWINDOW = &H40
        
        DoEvents
        Set IOLEW = cProg
        hwnd = IOLEW.GetWindow
        If hwnd <> 0 Then
            SetWindowPos hwnd, 0&, 10&, 10&, 0&, 0&, SWP_NOSIZE Or SWP_SHOWWINDOW
        End If
    End Sub
    This moves the progress window to the left corner of the display (10&,10&).
    You need furthermore to declare this API in the modules header:
    Code:
    Private Declare Function SetWindowPos Lib "user32.dll" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
    Should mention that the most of the other interfaces throw automation errors when using their methods.
    Last edited by SaschaT; Jan 26th, 2018 at 12:56 PM.

Tags for this Thread

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