[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Taskbar text not responding on form.caption

Posted on 2009-02-24
30
Medium Priority
?
784 Views
Last Modified: 2013-12-25
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?
0
Comment
Question by:theo kouwenhoven
  • 17
  • 8
  • 5
30 Comments
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 23726513
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
 
LVL 16

Author Comment

by:theo kouwenhoven
ID: 23726822
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
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 23727000
I can' test it...perhaps you could do DoEvents() immediately after?

       Form1.Caption = Tel & " of " & TotRecords
       Form1.Refresh
       DoEvents    
       'process the record etc
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 16

Author Comment

by:theo kouwenhoven
ID: 23727852
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
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 23728118
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
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 23736836
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
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 23737494
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
 
LVL 16

Author Comment

by:theo kouwenhoven
ID: 23737581
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
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 23738082
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
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 23738174
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
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 500 total points
ID: 23738692
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
 
LVL 76

Assisted Solution

by:GrahamSkan
GrahamSkan earned 500 total points
ID: 23738821
Yes. Perhaps it is an XP problem.
0
 
LVL 16

Author Comment

by:theo kouwenhoven
ID: 23739060
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
 
LVL 16

Author Comment

by:theo kouwenhoven
ID: 23739121
Oh and

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

Works for me, so not an XP problem.
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 23739277
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
 
LVL 16

Author Comment

by:theo kouwenhoven
ID: 23739312
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
 
LVL 16

Author Comment

by:theo kouwenhoven
ID: 23739359
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
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 23739439
I would expect the procedure in your last comment to work. Does it?
0
 
LVL 16

Author Comment

by:theo kouwenhoven
ID: 23739576
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
 
LVL 16

Author Comment

by:theo kouwenhoven
ID: 23740143
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
 
LVL 16

Author Comment

by:theo kouwenhoven
ID: 23740213
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
 
LVL 16

Author Comment

by:theo kouwenhoven
ID: 23743436
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
 
LVL 16

Author Comment

by:theo kouwenhoven
ID: 23743450
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
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 23747208
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
 
LVL 16

Author Comment

by:theo kouwenhoven
ID: 23748083
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
 
LVL 16

Author Comment

by:theo kouwenhoven
ID: 23749614
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
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 23750897
Perhaps you could use a form that the user can't resize but is programatically positioned in one corner of the screen.
0
 
LVL 16

Author Comment

by:theo kouwenhoven
ID: 23750964
Yes Graham,

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


0
 
LVL 16

Author Comment

by:theo kouwenhoven
ID: 23755763
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
 
LVL 16

Author Comment

by:theo kouwenhoven
ID: 23770586
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

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses
Course of the Month17 days, 16 hours left to enroll

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question