调用 GetWindowHandle() 返回null, 且窗口已经创建完成
HWND hwnd = browser->GetHost()->GetWindowHandle(); // hwnd == null
原因: 此方法在UI 线程中调正常的,在其他线程中会返回null
void test::printHWND(CefRefPtr<CefBrowser> browser){
if (!CefCurrentlyOn(TID_UI)) {
// Execute on the UI thread.
CefPostTask(TID_UI, base::BindOnce(&test::printHWND, this, browser));
return;
}
HWND hwnd = browser->GetHost()->GetWindowHandle(); // 正常
}