Displaying a progress form


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 10 of 10

Thread: Displaying a progress form

  1. #1
    Ted Young Guest

    Displaying a progress form


    I need some advice/suggestions for displaying a form that displays a progress
    bar. I am trying to avoid having my Progress Form lose focus......

    I have a Main form that does some processing. While this processing is occuring
    I display another form that simply has a progress bar on it (I display this
    form vbmodeless as I have no other choice since the processing is occuring
    in the main form).

    The code looks something like this in my frmMain:

    frmProgress.Show vbmodeless
    frmProgress.ProgressBar.Value = 20

    'Processing in frmMain
    ......
    ......

    frmProgress.ProgressBar.Value = 40

    This works fine, EXCEPT for the fact that while processing is occuring AND
    the frmProgress is displayed the user CAN click somewhere else and this will
    result in the frmProgress losing focus....Then the progress form is no longer
    visible.

    Any ideas or suggestion on how to have this frmProgress act like a vbmodal
    form? Maybe using events?

    Any ideas would be greatly appreciated.

    Thanks!

  2. #2
    Robert Gelb Guest

    Re: Displaying a progress form

    instead of
    frmProgress.show vbModeless

    use
    frmProgress.show vbModeless, me

    This will force frmProgress form to stay on top of the main form.

    --
    Robert Gelb
    www.vbRad.com
    Source, Tips, Tricks, Components

    "Ted Young" <tyoung@mlnusa.com> wrote in message
    news:39b7cc8d$1@news.devx.com...
    >
    > I need some advice/suggestions for displaying a form that displays a

    progress
    > bar. I am trying to avoid having my Progress Form lose focus......
    >
    > I have a Main form that does some processing. While this processing is

    occuring
    > I display another form that simply has a progress bar on it (I display

    this
    > form vbmodeless as I have no other choice since the processing is occuring
    > in the main form).
    >
    > The code looks something like this in my frmMain:
    >
    > frmProgress.Show vbmodeless
    > frmProgress.ProgressBar.Value = 20
    >
    > 'Processing in frmMain
    > .....
    > .....
    >
    > frmProgress.ProgressBar.Value = 40
    >
    > This works fine, EXCEPT for the fact that while processing is occuring AND
    > the frmProgress is displayed the user CAN click somewhere else and this

    will
    > result in the frmProgress losing focus....Then the progress form is no

    longer
    > visible.
    >
    > Any ideas or suggestion on how to have this frmProgress act like a vbmodal
    > form? Maybe using events?
    >
    > Any ideas would be greatly appreciated.
    >
    > Thanks!




  3. #3
    Ted Young Guest

    Re: Displaying a progress form


    Robert,

    Thanks for the feedback.

    I tried that and while it does keep the progress form on top, when I click
    somewhere it causes the processing to stop until I click back on the progress
    form.

    I'd prefer to not interrupt the processing going on.

    Any other ideas?

    Thanks!

    "Robert Gelb" <robertgelbNOSPAMFORME@zdnetonebox.com> wrote:
    >instead of
    >frmProgress.show vbModeless
    >
    >use
    >frmProgress.show vbModeless, me
    >
    >This will force frmProgress form to stay on top of the main form.
    >
    >--
    >Robert Gelb
    >www.vbRad.com
    >Source, Tips, Tricks, Components
    >
    >"Ted Young" <tyoung@mlnusa.com> wrote in message
    >news:39b7cc8d$1@news.devx.com...
    >>
    >> I need some advice/suggestions for displaying a form that displays a

    >progress
    >> bar. I am trying to avoid having my Progress Form lose focus......
    >>
    >> I have a Main form that does some processing. While this processing is

    >occuring
    >> I display another form that simply has a progress bar on it (I display

    >this
    >> form vbmodeless as I have no other choice since the processing is occuring
    >> in the main form).
    >>
    >> The code looks something like this in my frmMain:
    >>
    >> frmProgress.Show vbmodeless
    >> frmProgress.ProgressBar.Value = 20
    >>
    >> 'Processing in frmMain
    >> .....
    >> .....
    >>
    >> frmProgress.ProgressBar.Value = 40
    >>
    >> This works fine, EXCEPT for the fact that while processing is occuring

    AND
    >> the frmProgress is displayed the user CAN click somewhere else and this

    >will
    >> result in the frmProgress losing focus....Then the progress form is no

    >longer
    >> visible.
    >>
    >> Any ideas or suggestion on how to have this frmProgress act like a vbmodal
    >> form? Maybe using events?
    >>
    >> Any ideas would be greatly appreciated.
    >>
    >> Thanks!

    >
    >



  4. #4
    Steve Barker Guest

    Re: Displaying a progress form

    Ted,

    Would disabling the main form when you show the progress form, then re-enabling it
    when the process is complete, do the trick? Or, what about doing away with the
    progress form altogether, and showing the progress bar in the status area of the
    main form?

    Steve Barker

    Ted Young wrote:

    > I need some advice/suggestions for displaying a form that displays a progress
    > bar. I am trying to avoid having my Progress Form lose focus......
    >
    > I have a Main form that does some processing. While this processing is occuring
    > I display another form that simply has a progress bar on it (I display this
    > form vbmodeless as I have no other choice since the processing is occuring
    > in the main form).
    >
    > The code looks something like this in my frmMain:
    >
    > frmProgress.Show vbmodeless
    > frmProgress.ProgressBar.Value = 20
    >
    > 'Processing in frmMain
    > .....
    > .....
    >
    > frmProgress.ProgressBar.Value = 40
    >
    > This works fine, EXCEPT for the fact that while processing is occuring AND
    > the frmProgress is displayed the user CAN click somewhere else and this will
    > result in the frmProgress losing focus....Then the progress form is no longer
    > visible.
    >
    > Any ideas or suggestion on how to have this frmProgress act like a vbmodal
    > form? Maybe using events?
    >
    > Any ideas would be greatly appreciated.
    >
    > Thanks!



  5. #5
    Ted Young Guest

    Re: Displaying a progress form


    Steve,

    I could hide the main form while the progress form is being displayed. Although
    I rather have the main form showing if possible. I also would rather the
    progress be on its own form.

    Is there anyway to display a progress form using Events that will always
    be displayed as a vbmodal type form?

    Thanks!


    Steve Barker <Barker@SentinelSystems.com> wrote:
    >Ted,
    >
    >Would disabling the main form when you show the progress form, then re-enabling

    it
    >when the process is complete, do the trick? Or, what about doing away with

    the
    >progress form altogether, and showing the progress bar in the status area

    of the
    >main form?
    >
    >Steve Barker
    >
    >Ted Young wrote:
    >
    >> I need some advice/suggestions for displaying a form that displays a progress
    >> bar. I am trying to avoid having my Progress Form lose focus......
    >>
    >> I have a Main form that does some processing. While this processing is

    occuring
    >> I display another form that simply has a progress bar on it (I display

    this
    >> form vbmodeless as I have no other choice since the processing is occuring
    >> in the main form).
    >>
    >> The code looks something like this in my frmMain:
    >>
    >> frmProgress.Show vbmodeless
    >> frmProgress.ProgressBar.Value = 20
    >>
    >> 'Processing in frmMain
    >> .....
    >> .....
    >>
    >> frmProgress.ProgressBar.Value = 40
    >>
    >> This works fine, EXCEPT for the fact that while processing is occuring

    AND
    >> the frmProgress is displayed the user CAN click somewhere else and this

    will
    >> result in the frmProgress losing focus....Then the progress form is no

    longer
    >> visible.
    >>
    >> Any ideas or suggestion on how to have this frmProgress act like a vbmodal
    >> form? Maybe using events?
    >>
    >> Any ideas would be greatly appreciated.
    >>
    >> Thanks!

    >



  6. #6
    Jreg (Glenn) Guest

    Re: Displaying a progress form

    perhaps you could restrict the mouse movements to the confines of the
    progress for eliminating the possibility of the user clicking anywhere but
    on the progress form. one draw back though.....your users may not enjoy
    being restricted like this.



    Glenn (Jreg)
    jedireg@usa.nospam.net



  7. #7
    Steve Barker Guest

    Re: Displaying a progress form

    Ted,

    I didn't mean hide the main form, I meant disable it by setting the enabled property
    to false while your task is running, the setting it back to true afterwards. The
    form would be visible but the user could not do anything with it.

    As far as I know, I don't think you can display the progress form modally and have
    the main form continue processing. Someone else could have some magic for this
    however.

    Steve Barker

    Ted Young wrote:

    > Steve,
    >
    > I could hide the main form while the progress form is being displayed. Although
    > I rather have the main form showing if possible. I also would rather the
    > progress be on its own form.
    >
    > Is there anyway to display a progress form using Events that will always
    > be displayed as a vbmodal type form?
    >
    > Thanks!
    >
    > Steve Barker <Barker@SentinelSystems.com> wrote:
    > >Ted,
    > >
    > >Would disabling the main form when you show the progress form, then re-enabling

    > it
    > >when the process is complete, do the trick? Or, what about doing away with

    > the
    > >progress form altogether, and showing the progress bar in the status area

    > of the
    > >main form?
    > >
    > >Steve Barker
    > >
    > >Ted Young wrote:
    > >
    > >> I need some advice/suggestions for displaying a form that displays a progress
    > >> bar. I am trying to avoid having my Progress Form lose focus......
    > >>
    > >> I have a Main form that does some processing. While this processing is

    > occuring
    > >> I display another form that simply has a progress bar on it (I display

    > this
    > >> form vbmodeless as I have no other choice since the processing is occuring
    > >> in the main form).
    > >>
    > >> The code looks something like this in my frmMain:
    > >>
    > >> frmProgress.Show vbmodeless
    > >> frmProgress.ProgressBar.Value = 20
    > >>
    > >> 'Processing in frmMain
    > >> .....
    > >> .....
    > >>
    > >> frmProgress.ProgressBar.Value = 40
    > >>
    > >> This works fine, EXCEPT for the fact that while processing is occuring

    > AND
    > >> the frmProgress is displayed the user CAN click somewhere else and this

    > will
    > >> result in the frmProgress losing focus....Then the progress form is no

    > longer
    > >> visible.
    > >>
    > >> Any ideas or suggestion on how to have this frmProgress act like a vbmodal
    > >> form? Maybe using events?
    > >>
    > >> Any ideas would be greatly appreciated.
    > >>
    > >> Thanks!

    > >


    --
    Steve Barker, Software Developer
    Barker@SentinelSystems.com

    Sentinel Systems Corporation
    1620 Kipling Street
    Lakewood, CO 80215

    Toll-Free: (800) 456-9955
    In Colorado: (303) 242-2000
    Fax: (303) 242-2010
    Web Site: http://www.SentinelSystems.com
    Sales: Sales@SentinelSystems.com
    Support: Support@SentinelSystems.com



  8. #8
    Robert Gelb Guest

    Re: Displaying a progress form

    In that case you can use a hack. In the sub where you fire up the progress
    form, instead set a timer's Enabled property to True and call the progress
    form from the Timer1_Timer event using the vbModal flag.

    --
    Robert Gelb
    www.vbRad.com
    Source, Tips, Tricks, Components

    "Ted Young" <tyoung@mlnusa.com> wrote in message
    news:39b8e7b9$1@news.devx.com...
    >
    > Robert,
    >
    > Thanks for the feedback.
    >
    > I tried that and while it does keep the progress form on top, when I click
    > somewhere it causes the processing to stop until I click back on the

    progress
    > form.
    >
    > I'd prefer to not interrupt the processing going on.
    >
    > Any other ideas?
    >
    > Thanks!
    >
    > "Robert Gelb" <robertgelbNOSPAMFORME@zdnetonebox.com> wrote:
    > >instead of
    > >frmProgress.show vbModeless
    > >
    > >use
    > >frmProgress.show vbModeless, me
    > >
    > >This will force frmProgress form to stay on top of the main form.
    > >
    > >--
    > >Robert Gelb
    > >www.vbRad.com
    > >Source, Tips, Tricks, Components
    > >
    > >"Ted Young" <tyoung@mlnusa.com> wrote in message
    > >news:39b7cc8d$1@news.devx.com...
    > >>
    > >> I need some advice/suggestions for displaying a form that displays a

    > >progress
    > >> bar. I am trying to avoid having my Progress Form lose focus......
    > >>
    > >> I have a Main form that does some processing. While this processing is

    > >occuring
    > >> I display another form that simply has a progress bar on it (I display

    > >this
    > >> form vbmodeless as I have no other choice since the processing is

    occuring
    > >> in the main form).
    > >>
    > >> The code looks something like this in my frmMain:
    > >>
    > >> frmProgress.Show vbmodeless
    > >> frmProgress.ProgressBar.Value = 20
    > >>
    > >> 'Processing in frmMain
    > >> .....
    > >> .....
    > >>
    > >> frmProgress.ProgressBar.Value = 40
    > >>
    > >> This works fine, EXCEPT for the fact that while processing is occuring

    > AND
    > >> the frmProgress is displayed the user CAN click somewhere else and this

    > >will
    > >> result in the frmProgress losing focus....Then the progress form is no

    > >longer
    > >> visible.
    > >>
    > >> Any ideas or suggestion on how to have this frmProgress act like a

    vbmodal
    > >> form? Maybe using events?
    > >>
    > >> Any ideas would be greatly appreciated.
    > >>
    > >> Thanks!

    > >
    > >

    >




  9. #9
    Michael Culley Guest

    Re: Displaying a progress form


    Steve, Ted,

    I have spent a fair amount of time on this problem before and came up with
    a pretty good although not perfect solution. If you would like me to send
    you a sample email me directly as I don't always have time to look at vbzone.

    My first idea was to put an event on the status form call RunLongProcess.
    I show the status form and it raises an event which the main form traps.
    This work quite well. In the event I put the long process. Code on the main
    form would look like this.

    Option Explicit

    Private withevents mfrmStatus as frmStatus

    Sub Command1_Click
    Set mfrmStatus = New frmStatus
    mfrmStatus.Show vbModal
    set mfrmStatus = Nothing
    End sub

    Sub mfrmStatus_RunLongProcess
    Dim lngX as long
    For lngX = 1 to 100000
    mfrmStatus.PercentComplete =lngx/1000
    if mfrmStatus.CancelPushed then exit Sub
    next
    End Sub

    This worked well with no problems at all. But I wanted to wrap it up a little
    more as when everyone at work had to use it they had to search through all
    the props of the form to find the properties I added. So I turned it into
    a custom control. It all worked well except for one problem. For some reason
    when a modal form is shown from a usercontrol all events are turned off.
    So the RunLongProcessEvent didn't fire which was the whole point of the control.
    It all worked fine if the OCX and EXE where compiled or both in the IDE,
    but if the OCX was compiled and the EXE was in the IDE it didn't work. I
    haven't solved this problem yet.

    Hope this helps

    Michael Culley



    Steve Barker <Barker@SentinelSystems.com> wrote:
    >Ted,
    >
    >I didn't mean hide the main form, I meant disable it by setting the enabled

    property
    >to false while your task is running, the setting it back to true afterwards.

    The
    >form would be visible but the user could not do anything with it.
    >
    >As far as I know, I don't think you can display the progress form modally

    and have
    >the main form continue processing. Someone else could have some magic for

    this
    >however.
    >
    >Steve Barker
    >
    >Ted Young wrote:
    >
    >> Steve,
    >>
    >> I could hide the main form while the progress form is being displayed.

    Although
    >> I rather have the main form showing if possible. I also would rather

    the
    >> progress be on its own form.
    >>
    >> Is there anyway to display a progress form using Events that will always
    >> be displayed as a vbmodal type form?
    >>
    >> Thanks!
    >>
    >> Steve Barker <Barker@SentinelSystems.com> wrote:
    >> >Ted,
    >> >
    >> >Would disabling the main form when you show the progress form, then re-enabling

    >> it
    >> >when the process is complete, do the trick? Or, what about doing away

    with
    >> the
    >> >progress form altogether, and showing the progress bar in the status

    area
    >> of the
    >> >main form?
    >> >
    >> >Steve Barker
    >> >
    >> >Ted Young wrote:
    >> >
    >> >> I need some advice/suggestions for displaying a form that displays

    a progress
    >> >> bar. I am trying to avoid having my Progress Form lose focus......
    >> >>
    >> >> I have a Main form that does some processing. While this processing

    is
    >> occuring
    >> >> I display another form that simply has a progress bar on it (I display

    >> this
    >> >> form vbmodeless as I have no other choice since the processing is occuring
    >> >> in the main form).
    >> >>
    >> >> The code looks something like this in my frmMain:
    >> >>
    >> >> frmProgress.Show vbmodeless
    >> >> frmProgress.ProgressBar.Value = 20
    >> >>
    >> >> 'Processing in frmMain
    >> >> .....
    >> >> .....
    >> >>
    >> >> frmProgress.ProgressBar.Value = 40
    >> >>
    >> >> This works fine, EXCEPT for the fact that while processing is occuring

    >> AND
    >> >> the frmProgress is displayed the user CAN click somewhere else and

    this
    >> will
    >> >> result in the frmProgress losing focus....Then the progress form is

    no
    >> longer
    >> >> visible.
    >> >>
    >> >> Any ideas or suggestion on how to have this frmProgress act like a

    vbmodal
    >> >> form? Maybe using events?
    >> >>
    >> >> Any ideas would be greatly appreciated.
    >> >>
    >> >> Thanks!
    >> >

    >
    >--
    >Steve Barker, Software Developer
    >Barker@SentinelSystems.com
    >
    >Sentinel Systems Corporation
    >1620 Kipling Street
    >Lakewood, CO 80215
    >
    >Toll-Free: (800) 456-9955
    >In Colorado: (303) 242-2000
    >Fax: (303) 242-2010
    >Web Site: http://www.SentinelSystems.com
    >Sales: Sales@SentinelSystems.com
    >Support: Support@SentinelSystems.com
    >
    >



  10. #10
    Alex Guest

    Re: Displaying a progress form


    Ted
    You can try something like this

    Create project with two forms named frmMain and frmSplash

    frmMain

    Put 2 buttons on the form: Command1 and Command2
    Set caption of Command1 to "Long task"

    ----Code----

    Public bWorking As Boolean

    Private Sub Command1_Click()
    bWorking = True
    frmSplash.Show vbModeless, Me
    Sleep 10
    bWorking = False
    Unload frmSplash
    End Sub

    Public Sub Sleep(Seconds As Single)
    Dim Start As Single, Finish As Single, n As Integer
    Start = Timer
    Finish = Start + Seconds
    Do While Timer < Finish:
    DoEvents
    n = n + 1
    If n = 1000 Then
    frmSplash.Label1.Caption = Int(Finish - Timer)
    n = 0
    End If
    If bWorking = False Then Exit Sub
    Loop
    End Sub


    Private Sub Command2_Click()
    Debug.Print "Command2_Click"
    End Sub



    frmSplash
    Put 1 button on the form: btnCancel and set it caption to "Cancel" and one
    label control

    ----Code----
    Private Sub btnCancel_Click()
    frmMain.bWorking = False
    End Sub


    Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    If frmMain.bWorking Then Beep: Cancel = True
    End Sub

    Alex


    "Ted Young" <tyoung@mlnusa.com> wrote:
    >
    >I need some advice/suggestions for displaying a form that displays a progress
    >bar. I am trying to avoid having my Progress Form lose focus......
    >
    >I have a Main form that does some processing. While this processing is

    occuring
    >I display another form that simply has a progress bar on it (I display this
    >form vbmodeless as I have no other choice since the processing is occuring
    >in the main form).
    >
    >The code looks something like this in my frmMain:
    >
    >frmProgress.Show vbmodeless
    >frmProgress.ProgressBar.Value = 20
    >
    >'Processing in frmMain
    >......
    >......
    >
    >frmProgress.ProgressBar.Value = 40
    >
    >This works fine, EXCEPT for the fact that while processing is occuring AND
    >the frmProgress is displayed the user CAN click somewhere else and this

    will
    >result in the frmProgress losing focus....Then the progress form is no longer
    >visible.
    >
    >Any ideas or suggestion on how to have this frmProgress act like a vbmodal
    >form? Maybe using events?
    >
    >Any ideas would be greatly appreciated.
    >
    >Thanks!



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center