by IDEAL Software Support » Mon Sep 15, 2014 6:42 am
It depends, whether a message is sent via Win API SendMessage() or PostMessage().
SendMessage() immediately jumps into the code of your application, therefore it is unsafe to call CloseDoc() from there.
PostMessage() puts the message onto the Windows message queue and is sent to your application when your app enters its main message loop. Here it is safe to call CloseDoc().
We checked our code, and the following messages are sent via SendMessage():
PRINT_MSG_SETUPSTART
PRINT_MSG_SETUPEND
PRINT_MSG_START
The following messages are sent via PostMessage():
PRINT_MSG_SETUPABORT
PRINT_MSG_ABORT
PRINT_MSG_END
Therefore it is safe to call CloseDoc() when receiving PRINT_MSG_ABORT or PRINT_MSG_END.
Otherwise - when receiving a message which does not allow to call CloseDoc() - you can always PostMessage() yourself a WM_USER message and close the document when receiving it. Or you can start a timer and close the document when the timer has finished.