I’m getting monitor information using EnumDisplayMonitors:
BOOL CALLBACK MonitorEnumProc(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData){
Class::callback(hMonitor,hdcMonitor,lprcMonitor,dwData);
return true;
}
bool Class::callback(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData){
classVar.appendData("callback");
return true;
}
bool Class::f(){
...
EnumDisplayMonitors(NULL,NULL,MonitorEnumProc,NULL);
...
}
Class::callback is static (if it isn’t I get error C2352: illegal call of non-static function). This however causes problems with classVar: error C2228: left of ‘.appendData must have class/struct/union’. What should I be doing here to get around this problem (I want the callback to write data to classVar)?
The last parameter of
EnumDisplayMonitors()is an extra pointer reserved for use by the caller. It is passed uninterpreted to the callback function. Pass a pointer to the class instance.