Disclosure Statement: This site contains affiliate links, which means that I may receive a commission if you make a purchase using these links. As an eBay Partner, I earn from qualifying purchases.
If you find these projects useful please consider becoming a sponsor with Patreon, GitHub or Liberapay.

Intercepting print dialog

Post Reply
User avatar
salvadordf
Posts: 4564
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Intercepting print dialog

Post by salvadordf »

As far as I know, there are two ways to disable printing :
  • Overwrite the window.print JavaScript function. Add this code :

    Code: Select all

    TChromium.ExecuteJavascript('window.print=function(){}', 'about:blank', 0);
  • Hook the PrintDlg and PrintDlgEx functions in the Windows API. For more details about this, read this post message :
    https://www.briskbard.com/forum/viewtop ... 2373#p2373
User avatar
salvadordf
Posts: 4564
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Intercepting print dialog

Post by salvadordf »

After reading a little more about this kind of problems I would try to use the TChromium.OnLoadStart event and add this code inside that event :

Code: Select all

frame.ExecuteJavascript('window.print=function(){}', 'about:blank', 0);
This would override the window.print function in every loaded frame.
Post Reply