Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Implementing a wait/status dialog

Posted on 1998-06-16
7
Medium Priority
?
457 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

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 200 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

Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

Question has a verified solution.

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

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 …
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
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.
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…

722 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