Eureka! I solved it.
Here is how:
When you show the modeless print dialog, you can disable the calling Form in Delphi. Then you can use the OnCommandStateChange event to detect when the user Prints or Cancels the Print dialog.
Example code:
WebBrowser1.OnCommandStateChange:=WebBrowser1CommandStateChange;
WebBrowser1.ControlInterface.ExecWB(OLECMDID_PRINT, OLECMDEXECOPT_PROMPTUSER,
vaIn, vaOut);
procedure TForm1.WebBrowser1CommandStateChange(Sender: TObject; Command:
Integer; Enable: WordBool);
begin
if Enabled then
Enabled:=false
else begin
Enabled:=true;
WebBrowser1.OnCommandStateChange:=nil;
end;
end;
I kindly ask you people to test my solution, as I'm not sure of the reliability of this code.
Thanks!