Solved

Implementing a wait/status dialog

Posted on 1998-06-16
7
448 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
Get MySQL database support online, now!

At Percona’s web store you can order your MySQL database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit 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

Get HTML5 Certified

Want to be a web developer? You'll need to know HTML. Prepare for HTML5 certification by enrolling in July's Course of the Month! It's free for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

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 …
In this post we will learn different types of Android Layout and some basics of an Android App.
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 is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

636 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