Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Use a form like a msgbox

Status
Not open for further replies.

denis60

Technical User
Apr 19, 2001
89
CA
Hi!
I use a button where it's process is very long.
I would like to use (create) a small form (like a msgbox without buttons) to show the progress of my process.

When i use a form it get the priority until i close it.I'd like to use it in paralel with my main form sending it data (text) and close it with my main form.

How is it possible ?
 
denis60,

Do you really need a special form for this? Could you just put Progress Bar on your main form?

Vladk
 
There might be several reasons why you need to use a form, generally because you need to convey more information about progress than you can with a progress bar. However, as vladk quite rightly points out, most apps use a progress bar, and may also use a status bar to show what the last activity was.

If you indeed need to use a form, you can "set the priority" as you say, to the main form by using the setfocus method. Just say frmMain.SetFocus, and frmMain will have the "priority". We normally say focus instead of priority, so if you want to read up on this concept, read up on focus.

That said, you won't be able to use the main form while your process is executing. This is because processes are synchronous, so your app will work on your process until it's done, and put everything else you try to do in a queue which it will execute when the current process is finished. If you want to have your process run in the background, and use your form while it's running, you will need to set up an asynchronous process. The easiest way to do this is with events; this should work for you just fine. (A more complex way to do it is with callback procedures, this gives you more control of the interaction of the foreground and background processes.)

MSDN doc has a great example of this, using a coffee pot analogy. You want to start the coffee, do whatever you feel like while the coffee's brewing, and then get notified when the coffee's done so you can pour yourself a cup. If you work through this, and read up some on asynchronous processes using events, you should be able to put it together.

HTH

Bob
 
Yes vladk i could use a progress bar, but sometime it's good to see information of each step of your progress. For people waiting it's more secure.

Thanks you both, i'll try to find out exemples on MSDN doc.
Happy christmas !!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top