NEW: Owlet: Added TPrinter::GetName; returns the device name.
Here is a rewrite of EvSettingChange, dealing with the issues mentioned in my earlier post. void TRichEditorApp::EvSettingChange([[maybe_unused]] uint flags, LPCTSTR section) { if (!Printer || IsPrinting || section != _T("windows"s)) return; const auto isPrinterInstalled = [](LPCTSTR name) noexcept { auto h = HANDLE{}; const auto ok = !!::OpenPrinter(const_cast<LPTSTR>(name), &h, nullptr); if (ok) ::ClosePrinter(h); return ok; }; // Check whether our printer is still installed. If not, use the default...
@jogbybl wrote: I tried to put the TPrinter creation in a std::async, but unfortunately it hangs That's not surprising, though, especially since in your case the TPrinter constructor opens a dialog box ("Waiting for printer connection"). Putting OWLNext objects on secondary threads is generally a bad idea, as we point out in "Multi-threading and OWLNext". I've tested with my own printer, an old Canon MP490, and it doesn't produce a message box, even if turned off. I tested both 32-bit and 64-bit...
OWLNext_Stable_Releases
OWLNext_Stable_Releases
OWLNext_Roadmap_and_Prereleases
OWLNext_Roadmap_and_Prereleases
@jogbybl wrote: I tried to put the TPrinter creation in a std::async, but unfortunately it hangs That's not surprising, though. Putting OWLNext objects on secondary threads is generally a bad idea, as we point out in "Multi-threading and OWLNext". That said, it is possible to create the default TPrinter object on the secondary thread, provided you pass it back to the main thread as the return type of your function passed to std::async. Then you use the returned TPrinter object on the main thread,...