I would like to a utility that will allow me to abort an operation.
Ex. I have a GUI with a set of operations
{ COPY, CANCEL, DISPLAY, ABORT }
Whenever Abort is pressed The COPY operation will cease.
an return the file to its previous state (i.e. before the COPY
button was pressed }
Is there sample code available anywhere. Can I use onw of the WM_...
operations to perform this tasks.
Thank you very much for your time.
-Chibuike
--
C. Nwaeze
The MITRE Corporation.
email: nwa...@mitre.org
The correct way to do this is to put up a modeless dialog box.
While it is displayed, you do your copying. When the ABORT
button is pressed, the DlgProc for the modeless dialog box
can kill itself and set an 'aborted' flag. Periodically in
your processing, you check for the 'aborted' flag.
But the most important part, is that you must pump messages
to the dialog box. So, when you check periodically for the
'aborted' flag, you must also use a PeekMessage loop with
PM_REMOVE, followeed by a dispatch operation to the appropriate
window:
while(GetMessage(&msg,NULL,0,0,PM_REMOVE)){
if(!IsDialogMessage(hwnd_modeless,&msg)){
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
where hwnd_modeless is the HWND you saved from the CreateDialog()
call to create the modeless dialog box.
This not only pumps messages through the system to allow
other applications to run during the copy process, it also
processes the message corresponding to the ABORT button being
clicked. The latter is really important, because without it,
your DlgProc will never receive the 'button pressed' message
and the 'aborted' flag will never be set.
These are the same principles that are used with the "% done"
gas gauges and the 'abort' dialog for printing. Read up on
modeless dialog boxes.
You didn't say how the COPY, DISPLAY, CANCEL & ABORT functions
are implemented, i.e. as menu items, as buttons on a modal
dialog box or as buttons on a modeless dialog box. Usually
an operation (like COPY,PRINT etc) is initiated either from a
modal dialog box or a menu item. Once the operation starts,
a modeless dialog box is displayed with a CANCEL button.
For the DISPLAY operation, presumably this would work the same
as COPY. I don't know what the operation is, but if it is a
text file or bitmap to be displayed, presumably this is just
a window or a dialog box and a CANCEL or ABORT button wouldn't
make much sense for the operation.
Damn I'm in a chatty mood! Enough. Go read a book.
--
John A. Grant jag...@emr1.emr.ca
Airborne Geophysics
Geological Survey of Canada, Ottawa