I'm developing the application on dual screen monitors environment. normally I use GetSystemMetrics(SM_CMONITORS) Windows API to get it. but when I use SANDBOX, it returns 0. it's no problem if not use SANDBOX.
is there any idea to get correct monitor count?
- Code: Select all
class AdkExtensionHandler : public CefV8Handler{
public:
explicit AdkExtensionHandler(CefRefPtr<client::ClientAppRenderer> client_app)
: client_app_(client_app)
, messageId(0){
}
virtual bool Execute(const CefString& name,
CefRefPtr<CefV8Value> object,
const CefV8ValueList& arguments,
CefRefPtr<CefV8Value>& retval,
CefString& exception) {
if (name == "getMonitorCount") {
int monitorCount = GetSystemMetrics(SM_CMONITORS);
retval = CefV8Value::CreateInt(monitorCount);
return true;
}
}
private:
CefRefPtr<client::ClientAppRenderer> client_app_;
int32 messageId;
IMPLEMENT_REFCOUNTING(AdkExtensionHandler);
};
- Code: Select all
void ClientAppRenderer::OnWebKitInitialized() {
DelegateSet::iterator it = delegates_.begin();
for (; it != delegates_.end(); ++it)
(*it)->OnWebKitInitialized(this);
// Define the extension contents.
std::string strExtensionCode =
"var adk;"
"if (!adk)"
" adk = {};"
"(function() {"
" adk.getMonitorCount = function() {"
" native function getMonitorCount();"
" return getMonitorCount();"
" };"
"})();";
// Register the extension.
CefRefPtr<CefV8Handler> handler = new AdkExtensionHandler(this);
CefRegisterExtension("adk", strExtensionCode, handler);
}
CEF version : cef_84.4.0+g304e015+chromium-84.0.4147.105
Windows version
- Edition : Windows 10 Pro
- Version : 2004
- OS build : 19041.928
thanks