mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Windows: Fix Vista/7 compatibility
This commit is contained in:
parent
e49fb38d44
commit
ebc31e603b
1 changed files with 20 additions and 3 deletions
|
|
@ -501,12 +501,29 @@ static double getGlobalDPI()
|
|||
//==============================================================================
|
||||
class ScopedSuspendResumeNotificationRegistration
|
||||
{
|
||||
static auto& getFunctions()
|
||||
{
|
||||
struct Functions
|
||||
{
|
||||
using Register = HPOWERNOTIFY (WINAPI*) (HANDLE, DWORD);
|
||||
using Unregister = BOOL (WINAPI*) (HPOWERNOTIFY);
|
||||
|
||||
Register registerNotification = (Register) getUser32Function ("RegisterSuspendResumeNotification");
|
||||
Unregister unregisterNotification = (Unregister) getUser32Function ("UnregisterSuspendResumeNotification");
|
||||
|
||||
bool isValid() const { return registerNotification != nullptr && unregisterNotification != nullptr; }
|
||||
};
|
||||
|
||||
static Functions functions;
|
||||
return functions;
|
||||
}
|
||||
|
||||
public:
|
||||
ScopedSuspendResumeNotificationRegistration() = default;
|
||||
|
||||
explicit ScopedSuspendResumeNotificationRegistration (HWND window)
|
||||
: handle (SystemStats::getOperatingSystemType() >= SystemStats::Windows8_0
|
||||
? RegisterSuspendResumeNotification (window, DEVICE_NOTIFY_WINDOW_HANDLE)
|
||||
: handle (getFunctions().isValid()
|
||||
? getFunctions().registerNotification (window, DEVICE_NOTIFY_WINDOW_HANDLE)
|
||||
: nullptr)
|
||||
{}
|
||||
|
||||
|
|
@ -516,7 +533,7 @@ private:
|
|||
void operator() (HPOWERNOTIFY ptr) const
|
||||
{
|
||||
if (ptr != nullptr)
|
||||
UnregisterSuspendResumeNotification (ptr);
|
||||
getFunctions().unregisterNotification (ptr);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue