Taskbar text not responding on form.caption

Hi Experts,

On my form, I use my form.caption to display a counter like 1 of 500 etc.
The reason of doing that in the form.caption is that I like to see it even if the form is minimized.
If the form is not minimized, it works for the form.caption.
but the Taskbar.caption is only changing when I click or drag the form.
How can I force the text in the taskbar to be updated?
LVL 17
MurpheyApplication ConsultantAsked:
Who is Participating?
 
Mike TomlinsonConnect With a Mentor Middle School Assistant TeacherCommented:
I just want to make sure we are all looking at the same thing...

GrahamSkan...I was able to get my Form Caption to change with the loop, but NOT the displayed text in the TASKBAR.  This was running with VB6 (and service pack) on a WinXP SP2 system.

So you're saying that the text in the TASKBAR is changing in real-time with your Form Caption?
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
Interesting...are you updating the Caption while in a loop?

Perhaps you need to use DoEvents() to force the form to update?  (even while minimized)

I don't have VB6 on this machine so I can't test it out sorry:

    Some kind of Loop

        some kind of processing

        Me.Caption = x of y
        DoEvents
    End Loop
0
 
MurpheyApplication ConsultantAuthor Commented:
Yes it's in a loop including do events: the loop is not in the form but in a module:

Do Until EOF(1)
        Line Input #1, record
        Tel = Tel + 1
        Form1.Caption = Tel & " of " & TotRecords
       
        'process the record etc
       
        DoEvents
Loop
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
Mike TomlinsonMiddle School Assistant TeacherCommented:
I can' test it...perhaps you could do DoEvents() immediately after?

       Form1.Caption = Tel & " of " & TotRecords
       Form1.Refresh
       DoEvents    
       'process the record etc
0
 
MurpheyApplication ConsultantAuthor Commented:
Tried that already With and without Refresh and or DoEvents all combinations

the speed is not to fast, process a record is ca.  7 records per 5 seconds

0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
Yeah...sorry.  I just fired up my old desktop with VB6 on it and tried it myself.  Never noticed that it did that before...  =\

Interestingly enough, equivalent VB.Net code actually works!  The caption in the TaskBar updates with the caption on the form.

I'll see what I can dig up on the issue.
0
 
GrahamSkanRetiredCommented:
This works for me - Win2000( SP4) & VB6(SP6)
Private Sub Timer1_Timer()
  Me.Caption = Val(Me.Caption) + 1
End Sub

Open in new window

0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
Try it in a LOOP with DoEvents though GrahamSkan...

I suppose if that's all we can get to work then you could intermittently read records when the Timer fires.
0
 
MurpheyApplication ConsultantAuthor Commented:
Your example is working but my program doesn't

I have XP SP4.....  but VB6(SP6) Never heard of where can I find the SP's for VB?

My program flow is:

Start with Sub Main
   Form1.show (minimized)
     do something 17000 times
         Change form1.caption
         <Do some stuff>
     loop
   end
end sub

Form1 contain ono objects, I only need the button on the task bar to inform me about the status

Thanks,
Murph

0
 
GrahamSkanRetiredCommented:
This also works in on my system
Private Sub Command1_Click()
    Do
        Me.Caption = Val(Me.Caption) + 1
        DoEvents
    Loop
End Sub

Open in new window

0
 
GrahamSkanRetiredCommented:
I'm worried now. I can no longer find VB6 service pack downloads on the MS sites. All that is offered are later versions of the run-time dll. I guess that they have been withdrawn.
0
 
GrahamSkanConnect With a Mentor RetiredCommented:
Yes. Perhaps it is an XP problem.
0
 
MurpheyApplication ConsultantAuthor Commented:
Ok SP6 installed :)

I found the problem, but not the solution.

Situation:
-Form1 containing a timer that fills the form.caption with something
-Module1 with a lot of DB handling etc.

When I put in the Form1.Load  a call to the Main routine in my Module, the module will be executed but the debug in the timer is never active.

When I start the project with Sub Main and put first Form1.Show then the Debug in the timer will be fired once before the rest of the module is is processed.

a DoEvents is included somwhere in the loop in processing of the main module. a Debug on this DoEvent is popping up in every cycle without the expected debug in the timer.

so any ideas ???
Regards,
Murph
0
 
MurpheyApplication ConsultantAuthor Commented:
Oh and

Private Sub Timer1_Timer()
  Me.Caption = Val(Me.Caption) + 1
End Sub

Works for me, so not an XP problem.
0
 
GrahamSkanRetiredCommented:
You will not be able to use the Timer while running a separate procedure, since VB6 is single threaded. Even if your timer event was called, the code would not know where it was when it was interrupted.

You will have to update the caption somewhere in your Main routine, or in any subroutines that it calls.
0
 
MurpheyApplication ConsultantAuthor Commented:
Hi GrahamSkan,

This is the situation in the module that runs.

Start with Sub Main
   Form1.show (minimized)
     do something 17000 times
         Change form1.caption
         <Do some stuff>
     loop
   end
end sub
0
 
MurpheyApplication ConsultantAuthor Commented:
maybe it will help to post the sub where it should happen:

Sub Proc_TxtF

Open Tempfile For Input As #1

    Do Until EOF(1)
        Line Input #1, rec$
        Recc = Recc + 1
        Form1.Caption = Recc & " of " & TotRecs
       
        process_Record rec$  'do some DB stuff and calculation
       
        Form1.Refresh
        DoEvents
    Loop

Close #1
End Sub
0
 
GrahamSkanRetiredCommented:
I would expect the procedure in your last comment to work. Does it?
0
 
MurpheyApplication ConsultantAuthor Commented:
Hi GrahamSkan:

I expected the same, it updates the Form1.Caption, but NOT the test in the taskbar and that is what I need.

Regards,
Murph
0
 
MurpheyApplication ConsultantAuthor Commented:
Hi experts,

Some more info.
The text in the taskbar-button is changing when I run the application and:
-click in the caption part of the form (not on other form positions)
or
-if I click on the taskbar button to minimize and restore.
so there must be some event that do that?????

Regards,
Murph
0
 
MurpheyApplication ConsultantAuthor Commented:
Hi again,

The same if I run in the editor (F5) the taskbar will be updated if I click the scrollbar of one of the open source windows from whatever module.

I was just testing and found that this works also (but is not usefull and very slow)
         If Form1.WindowState = 0 Then
            Form1.WindowState = 1
        Else
            Form1.WindowState = 0
        End If

:)
Regards
0
 
MurpheyApplication ConsultantAuthor Commented:
Hi,

I did some more testing until I was to tired to move my mouse  :-)
I tried to use a second form for the taskbar (didn't work)
I also thought :
  • maybe I need a second threads (don't know how),
  • maybe I can create a second application that is just acting as taskbar button
    - Do I have to send data to it.
    - Can it grab data from a label of my program.
    - Do I have figure out how hWnd works, to discover that it's so slow.
  • how difficult can it be to write a taskbar program (like the minimized Media Player)
consideration
I have to handle 18000 records, if a solution to display the required info takes....:
 1 second extra per record, then the program will run 3 hours longer (Unacceptable)
0.1 second extra per record, then the program will run 30 minutes longer (Unacceptable)
0.001 second extra per record, then the program will run 3 minutes longer (I can live with that) :)

Regards,
Murph
0
 
MurpheyApplication ConsultantAuthor Commented:
Correction... 1 second delay will be 5 hours longer :)
but lucky me, it are only 17099 records, that will save 15 minutes :) still unacceptable :)
0
 
GrahamSkanRetiredCommented:
As I said, I can't reproduce the problem, but you could modify your work-around so that it is only called every, say 100 records.
Sub Proc_TxtF
 
Open Tempfile For Input As #1
 
    Do Until EOF(1)
        Line Input #1, rec$
        Recc = Recc + 1
        Form1.Caption = Recc & " of " & TotRecs
        If TotRecs mod 100 = 0 then
           If Form1.WindowState = 0 Then
              Form1.WindowState = 1
           Else
               Form1.WindowState = 0
           End If
        end if 
        process_Record rec$  'do some DB stuff and calculation
       
        Form1.Refresh
        DoEvents
    Loop
 
Close #1
End Sub

Open in new window

0
 
MurpheyApplication ConsultantAuthor Commented:
Hi GrahamSkan,

Yes could do that, but not a nice solution, every 100 loops will update once per 1 minute every 10 loops will be a little annoying to see a screen popping up and down every 4,5 seconds for almost 2 hours.
(Processing of these 17099 records goes with 2,3 records per second)

But what about the idea of running a dummy program with only a form taht can be changed with a hWnd (don't know how) or is that technique slowing down the proces t=with hours?

Regards,
Murph
0
 
MurpheyApplication ConsultantAuthor Commented:
Hi Experts,

I can remove one option from the list:
  • maybe I can create a second application that is just acting as taskbar button
    This will not work, result is the same, Titel is updated, taskbar isn't
    (tried with hWnd and Set WindowsTitle)
Don't know how to continue.
I think a taskbar application like the minimized Media Player is the only option, but where do start with that, or isn't that possible with VB?

Thanks for your help,
Murph
0
 
GrahamSkanRetiredCommented:
Perhaps you could use a form that the user can't resize but is programatically positioned in one corner of the screen.
0
 
MurpheyApplication ConsultantAuthor Commented:
Yes Graham,

I have now a ToolsWindow (no taskbar button) but I'ts not what I want....


0
 
MurpheyApplication ConsultantAuthor Commented:
Hi Experts,

I really appreciate  your help, but I think we can't solve this in VB6 and XP.
I installed the program on Vista (not proud of that) and it works.
SO I assume it's a bug in XP and I will surender.

Thanks both of you I will double the points and split them.
If you discover some solution in the future, please let me know.

Regards,
Murphey
0
 
MurpheyApplication ConsultantAuthor Commented:
Just an update to share mu solution (workaround)

The application is made as a Sub Main()  module.
an other application is started the same time and is checking the rsult in the Database every 2 seconds using :
"select count(*) from tabel"
I dont know how processor consuming that is, but it works.

Regards,
Murph
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.