Solved

Implementing a wait/status dialog

Posted on 1998-06-16
7
414 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
maven archtype selection in eclipse 1 53
Doc'in system (example?) BA 7 89
only14 challenge 19 69
either24  challenge 19 90
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
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 …
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.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

867 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

16 Experts available now in Live!

Get 1:1 Help Now