Solved

Implementing a wait/status dialog

Posted on 1998-06-16
7
437 Views
Last Modified: 2013-11-20
Has anybody tried to implement a wait/status dialog while printing in a sinlge threaded MFC app? I got some code for an object to do this from MSJ, but it doesn't really seem to cut it. So I'm curious to know how you guys would do it. The criteria are:
1) A status bar is displayed showing how much of the job is done.
2) A cancel button is displayed so the user can cancel the print operation at any time.(Even while spooling to the printer.)
Any ideas?
0
Comment
Question by:Beatachon
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 10

Expert Comment

by:RONSLOW
ID: 1318051
There is a sample class which puts the progress dialog in a separate thread so that it can run in parallel with the operation it is showing the progress for.

If your printed output is paginated, then this is pretty easy to do.  In your OnPrepareDC, when printing, check m_nCurPage and set the progress appropriately.  If the users has cancelled the operation thru the progress dialog (that has the cancel button) then set m_bContinuePrinting to FALSE.


0
 

Author Comment

by:Beatachon
ID: 1318052
Well, that presents two problems:
1) Like I said, as of yet this application is not mult-threaded. It will be in the future, but as of this time it isn't.
2) Scanning the Cancel button during printing isn't the problem. I actually am using a print function in some third party library, and it has a callback which enables me to check if the Cancel button was pressed in the status dialog. A big problem arises, though, when the user is printing over the Network. This function sends a lot of data (graphics) to the printer, and because of that, the spooling is what's taking forever. This is the most likely place the user would want to hit cancel.

I would agree that the application should be multi-threaded. Maybe now's as good a time as any to get that stuff in there. (If there's no other way to do this.)
0
 
LVL 1

Expert Comment

by:Bridge
ID: 1318053
You could put the processing code in the onIdle function.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Expert Comment

by:t004024
ID: 1318054
As I can see it the main problem in having a cancel without multithread  is that, though the cancel button event is fired, the application does not process it until the current function execution is completed and the application goes back to the message queue, by which time the actual execution is over and the cancel is of no use.

But, if U are sending the data in chunks, then U could check the message queue to see if the cancel button event is queued after every chunk and if it is, remove it from the queue and stop the execution. I have not tried it and this is just a suggestion.
0
 
LVL 1

Accepted Solution

by:
amby earned 50 total points
ID: 1318055
Send datas through a Timer...

inconvenient of idle: long CPU time is possible between idles...

timers are simple to implement...
0
 

Author Comment

by:Beatachon
ID: 1318056
Yes, I thought of using OnIdle as well. I'm going to try it. Thanks.
0
 

Author Comment

by:Beatachon
ID: 1318057
I mean a timer...
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
sum28 challenge 31 117
post4 challenge 28 113
x-bar in Google Sheets 2 91
Increment column based of a FK 8 48
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

740 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