1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
23 // Notifications from shim to parent; wParam = event id
24 #define WM_TWAIN_EVENT (WM_USER + 1)
27 #define TWAIN_EVENT_NOTIFYHWND 0
29 // lParam is result (bool indicating success)
30 #define TWAIN_EVENT_REQUESTRESULT 1
33 #define TWAIN_EVENT_NONE 10
34 #define TWAIN_EVENT_QUIT 11
35 #define TWAIN_EVENT_SCANNING 12
37 // lParam is HANDLE to shared file mapping valid in context of parent process
38 #define TWAIN_EVENT_XFER 13
40 // Requests from parent to shim; wParam = request id
41 #define WM_TWAIN_REQUEST (WM_USER + 2)
43 #define TWAIN_REQUEST_QUIT 0 // Destroy()
44 #define TWAIN_REQUEST_SELECTSOURCE 1
45 #define TWAIN_REQUEST_INITXFER 2
47 // messages starting from this are not to be used for interprocess communications
48 #define WM_SHIM_INTERNAL (WM_USER + 200)
50 template <typename IntType
> std::string
Num2Hex(IntType n
)
52 std::stringstream sMsg
;
53 sMsg
<< "0x" << std::uppercase
<< std::setfill('0') << std::setw(sizeof(n
) * 2) << std::hex
58 void ThrowWin32Error(const char* sFunc
, DWORD nWin32Error
)
60 std::stringstream sMsg
;
61 sMsg
<< sFunc
<< " failed with Win32 error code " << Num2Hex(nWin32Error
) << "!";
63 throw std::exception(sMsg
.str().c_str());
66 void ThrowLastError(const char* sFunc
) { ThrowWin32Error(sFunc
, GetLastError()); }
68 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */