Cannot create windows on non-UI thread!

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

Cannot create windows on non-UI thread!

Postby StudyCef » Thu Apr 21, 2016 11:57 pm

I use Chromium35 learn js Extensions,
Code: Select all
#include "ClientJsExtensionHandler.h"
#include "common/SystemSetting.h"
#include <json/include/value.h>
#include "include/cef_runnable.h"

bool ClientJsExtensionHandler::Execute(const CefString& name,
   CefRefPtr<CefV8Value> object,
   const CefV8ValueList& arguments,
   CefRefPtr<CefV8Value>& retval,
   CefString& exception){
   bool handled = false;


    if (name == "restart")
   {
      SystemSetting t_SystemSetting;
      t_SystemSetting.restart();
      return true;
   }
   
   // Send a message to the browser process.
   CefRefPtr<CefBrowser> browser =
      CefV8Context::GetCurrentContext()->GetBrowser();
   ASSERT(browser.get());

   CefRefPtr<CefProcessMessage> message =
      CefProcessMessage::Create(name);                     

   int index = 0;
   // Translate the arguments, if any.
   if (arguments.size() > 0)
   {
      for each (CefRefPtr<CefV8Value> arg in arguments)
      {
         JsUtil::SetListValue(message->GetArgumentList(), index, arg);
         index++;
      }
   }

   browser->SendProcessMessage(PID_BROWSER, message);
   handled = true;

   if (!handled)
      exception = "Invalid method arguments";

   return true;
}


Code: Select all
void SystemSetting::restart()
{
   TCHAR appName[MAX_PATH];
   TCHAR configPath[MAX_PATH];
   CommonUtil::GetExecuteDirectory(configPath);
   wcscat(configPath, L"config.ini");
   ::GetPrivateProfileString(L"config", L"appName", L"CEF", appName, MAX_PATH, configPath);
   HWND hWndPrev = ::GetWindow(::GetDesktopWindow(), GW_CHILD);
   while (::IsWindow(hWndPrev))
   {
      MessageBox(NULL,L"11111::IsWindow(hWndPrev)",L"::IsWindow(hWndPrev)",0);
   }
}



it point out “Cannot create windows on non-UI thread!”,and I find it in Chromium31 it is can , it have idea ?
StudyCef
Techie
 
Posts: 25
Joined: Tue Dec 15, 2015 7:38 pm

Re: Cannot create windows on non-UI thread!

Postby magreenblatt » Fri Apr 22, 2016 8:49 am

StudyCef wrote:it point out “Cannot create windows on non-UI thread!”

The message can be safely ignored.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm


Return to Support Forum

Who is online

Users browsing this forum: Google [Bot] and 33 guests