Solved

Implementing a wait/status dialog

Posted on 1998-06-16
7
402 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
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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 

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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
function returning CString in a regular win32 DLL 8 150
mixString challenge 36 98
format the code in java 6 73
wordmultiple challenge 12 92
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

746 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now