DeviceChangeDetector not a public class


#1

I would like to use the DeviceChangeDetector in a Windows project but it seems not to be a public member.
I tried to include it directly by including the following file:
#include "modules/juce_events/native/juce_win32_HiddenMessageWindow.h"

But i get the following errors: 

error C2440: '=' : cannot convert from 'const wchar_t *' to 'LPCSTR'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

juce_win32_hiddenmessagewindow.h(97): error C2664: 'HiddenMessageWindow::HiddenMessageWindow(const TCHAR *const ,WNDPROC)' : cannot convert parameter 1 from 'const wchar_t *const ' to 'const TCHAR *const '
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

Any thought on getting this to compile properly.

Code:
​
class DisplaysChangeDetector : public DeviceChangeDetector("DisplaysChangeDetector")
{
public:
    DisplaysChangeDetector()
    {
        
    };
    
    ~DisplaysChangeDetector()
    {
        
    };
}

#2

Jules, do you have clues on how i would be able to use the DeviceChangeDetector in my app directly.
Or do you recommend against it?

 


#3

It's very much just an internal helper class, not something I'd want to be public!

If it's audio hardware changes you're trying to detect, then that'll already trigger some callbacks in the AudioDeviceManager, won't it?

 


#4

I was trying to use it as a general callback for when devices change. One thing i'm using it for is to detect display changes.
I've now made a local copy which is targeted to specifically handle WM_DISPLAYCHANGE messages. So i've got a workaround but it thought it would have been handy to use it without creating my own copy.


#5

May not be the best alternative, but you could just poll for a list of devices on a timer with some decent interval, check the new list compared to the last. If such isn't the same, then your devices have changed.

See juce::AudioIODeviceType::getDeviceNames().


#6

thanks jrlanglois but i got the WM_DISPLAYCHANGE messages coming in and that seems to be working for now, as a last resort i could always fallback to a timer of course.