How to prevent ctrl-s from saving the file in C++ PDFViewCtrl?

Q:

We are using PDFViewCtrl in C++ and we don’t want accelerators ctrl+s for saving file to work.
We have created an application in Visual Studio 2013 and using PdfViewCtrl for rendering PDF files however control ctrl+s works and allows user to save the file, which is not desirable.

A:

You can use the PDFViewCtrl.SetCustomEventHandlers(EventHandlers*) method. Set a callback to EventHandlers.key_down and key_up (only one is needed, not sure which though. The typdef for this callback is

typedef UInt8(* pdftron::PDF::PDFViewCtrl::KeyEventHandler)(struct KeyEvent *evt, void *custom_data)

Note, the return value. If you return true then PDFViewCtrl will not process the event.

So the following code should work for you

`
UInt8 OnKeyEvent(struct KeyEvent *evt, void *custom_data)
{
if(evt->m_controlDown && (evt->m_keyCode == 0x57 || evt->m_keyCode == 0x74))
{
return 1; // stop PDFViewCtrl from processing event.
}
return 0; // allow PDFViewCtrl to process event normally
}

`