Controling a progressbar by its handle

G

Guy Cohen

Hi all

I use vb.net 2005
Lets say I have the handle number of a progress bar from program1.exe
Can I change the value of the progress bar from program2.exe using this
handle number?

TIA
Guy Cohen
 
H

Herfried K. Wagner [MVP]

Guy Cohen said:
I use vb.net 2005
Lets say I have the handle number of a progress bar from program1.exe
Can I change the value of the progress bar from program2.exe using this
handle number?

P/invoke 'SendMessage' + 'PBM_SETPOS'.
 
F

Family Tree Mike

If there were, presumably Program1.exe would "fix" the progress bar soon
after program2.exe changes it.
 
I

iwdu15

not tested and just a wild guess on my part, but try

System.Windows.Forms.ProgressBar.FromHandle

and let me know if that helps. the documentation doesnt specify if the
handle has to be from the same process, so i have no idea. Hope this helps,
let use know

--Jon
 
F

Family Tree Mike

If you are developing both program1.exe and program2.exe, then there should
be a way that is easier. If you are not developing program1.exe, then, what
makes you think that program2.exe knows better what the progress bar should
show?
 
H

Herfried K. Wagner [MVP]

iwdu15 said:
System.Windows.Forms.ProgressBar.FromHandle

and let me know if that helps. the documentation doesnt specify if the
handle has to be from the same process, so i have no idea.

It will have to be from the same process.
 
G

Guy Cohen

Family Tree Mike said:
If you are developing both program1.exe and program2.exe, then there should
be a way that is easier. If you are not developing program1.exe, then, what
makes you think that program2.exe knows better what the progress bar should
show?

Hi all and thanks for the reply.

Firstly its not a problem - I found a solution it can be done using API
....that is not wrong - is it ? ;)

re: what makes you think that program2.exe knows better what the progress
bar should show?

I develop windows services that handles stuff in the company during the night.
I want to develop a program that controls the status of the services and
that can tell what they are doing.

I had in mind to add a custom service control command - "send status"

In that custom command the service will update the progressbar and / or
textbox that it will have as "progress controls" in his properties.
I will use API to update these by their hwnd...
VOILA

Guy Cohen
 
K

kimiraikkonen

Hi all and thanks for the reply.

Firstly its not a problem - I found a solution it can be done using API
...that is not wrong - is it ? ;)

re: what makes you think that program2.exe knows better what the progress
bar should show?

I develop windows services that handles stuff in the company during the night.
I want to develop a program that controls the status of the services and
that can tell what they are doing.

I had in mind to add a custom service control command - "send status"

In that custom command the service will update the progressbar and / or
textbox that it will have as "progress controls" in his properties.
I will use API to update these by their hwnd...
VOILA

Guy Cohen

Guy,

I also wonder how to implement a progressbar to see an updated
position of a Windows Service using s"ervice controller" control.
Don't know which API function does show you the current service
proceeding situation within a progress bar, (also knowing it would be
good, not so criticial), reporting only "servicecontroller1.status" as
text.
 
G

Guy Cohen

kimiraikkonen said:
Guy,

I also wonder how to implement a progressbar to see an updated
position of a Windows Service using s"ervice controller" control.
Don't know which API function does show you the current service
proceeding situation within a progress bar, (also knowing it would be
good, not so criticial), reporting only "servicecontroller1.status" as
text.

Hi and thanks for the interest :)

What am I trying to do:
A screen with a listview , each listitem is a service, each listitem will
have at least three columns (current status e.g. sleeping or copying or
sending emails, description e.g. copying this table and finally a progressbar
showing the %)
A good example is the copy progress when you copy a table from one db to
another using sql server 2005 export/import table

I still did not write it ... as my boss wants me to do other important
tasks...
I wrote the service as follows:

part 1 = a vb dll that has all the necessary methods including ServiceStart
& ServiceStop.
This dll will also include three properties
a. Current Status
b. What am I doing
c. Job Percentage (0-100)

Whenever the dll will reach one of its task methods - the current status
will change to "Status x"
In this method the "what am i doing will change according to the current
point (e.g. copying this table"
If it will be in a loop the job percentage will also change.
Each time the loop ends the dll will raise an event "progress changed"


Part 2 = a vb service with the service start & stop methods.
In this part I declared the class in part1 and I intend to add three
properties
a. Current Status
b. What am I doing
c. Job Percentage (0-100)
The dll in part 1 will be declared withevents
Each time there is a progress update - the three properties will be updated.
Also here I should add some properties as the progressbar hwnd of the
service controller (and while it is zero - do not update it)
And include 2 custom service commands
1 to update the progress controls hwnd (probably make it read a file...)
2 to ask "what is your status?"


The Service controller (another program) :
will interact with the service (start/stop)
also will send two custom commands:
1: Get the progress controls hwnd from a file
2: Report "what is your status?"

As once Hannibal said: "i love when a plan comes together!"

Guy Cohen
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top