Moving window will see black edge

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.

Moving window will see black edge

Postby Tony2020 » Wed Mar 22, 2023 10:45 pm

I created the cefclient window as a child window in a simple window.
When I moving the cefclient window, black edge will show in CefBrowserWindow.
It's easy to check after resizing cefclent window.
How can I resolve this?
OS: win11
version: cef_binary_111.2.1+g870da30+chromium-111.0.5563.64_windows64
The codes I edited to create cefclient window as child window in root_window_win.cc as follows:
Code: Select all
void RootWindowWin::CreateRootWindow(const CefBrowserSettings& settings,
                                     bool initially_hidden) {
  REQUIRE_MAIN_THREAD();
  DCHECK(!hwnd_);

  HINSTANCE hInstance = GetModuleHandle(nullptr);

  // Load strings from the resource file.
  const std::wstring& window_title = GetResourceString(IDS_APP_TITLE);
  const std::wstring& window_class = GetResourceString(IDR_MAINFRAME);

  const cef_color_t background_color = MainContext::Get()->GetBackgroundColor();
  const HBRUSH background_brush = CreateSolidBrush(
      RGB(CefColorGetR(background_color), CefColorGetG(background_color),
          CefColorGetB(background_color)));

  // Register the window class.
  RegisterRootClass(hInstance, window_class, background_brush);

  // Register the message used with the find dialog.
  find_message_id_ = RegisterWindowMessage(FINDMSGSTRING);
  CHECK(find_message_id_);

  CefRefPtr<CefCommandLine> command_line =
      CefCommandLine::GetGlobalCommandLine();
  const bool no_activate = command_line->HasSwitch(switches::kNoActivate);

  DWORD dwStyle = WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN;
  DWORD dwExStyle = always_on_top_ ? WS_EX_TOPMOST : 0;
  if (no_activate) {
    // Don't activate the browser window on creation.
    dwExStyle |= WS_EX_NOACTIVATE;
  }

  if (initial_show_state_ == CEF_SHOW_STATE_MAXIMIZED) {
    dwStyle |= WS_MAXIMIZE;
  } else if (initial_show_state_ == CEF_SHOW_STATE_MINIMIZED) {
    dwStyle |= WS_MINIMIZE;
  }

  int x, y, width, height;
  if (initial_bounds_.IsEmpty()) {
    // Use the default window position/size.
    x = y = width = height = CW_USEDEFAULT;
  } else {
    x = initial_bounds_.x;
    y = initial_bounds_.y;
    width = initial_bounds_.width;
    height = initial_bounds_.height;

    if (is_popup_) {
      // Adjust the window size to account for window frame and controls. Keep
      // the origin unchanged.
      RECT window_rect = {x, y, x + width, y + height};
      ::AdjustWindowRectEx(&window_rect, dwStyle, with_controls_, dwExStyle);
      width = window_rect.right - window_rect.left;
      height = window_rect.bottom - window_rect.top;
    }
  }

  browser_settings_ = settings;
  HWND hWnd = NULL;
  {
     //register window class
     WNDCLASSEX wc{ 0 };
     wc.cbSize = sizeof(wc);
     wc.style = CS_OWNDC;
     wc.lpfnWndProc = DefWindowProc;
     wc.cbClsExtra = 0;
     wc.cbWndExtra = 0;
     wc.hInstance = hInstance;
     wc.hIcon = nullptr;
     wc.hCursor = nullptr;
     wc.hbrBackground = nullptr;
     wc.lpszMenuName = nullptr;
     const wchar_t pClassName[] = L"AAAAA";
     wc.lpszClassName = pClassName;
     wc.hIconSm = nullptr;
     RegisterClassEx(&wc);


     hWnd = CreateWindowEx(
        0, pClassName, L"happy",
        WS_CAPTION | WS_SYSMENU | WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
        200, 400, 640, 480,
        nullptr, nullptr, hInstance, nullptr);

     ShowWindow(hWnd, SW_SHOW);

      dwStyle |= WS_CHILD | WS_TABSTOP;
  }

  // Create the main window initially hidden.
  CreateWindowEx(dwExStyle, window_class.c_str(), window_title.c_str(), dwStyle,
                 0, 0, 640, 480, hWnd, nullptr, hInstance, this);
  CHECK(hwnd_);
 
  if (!called_enable_non_client_dpi_scaling_ && IsProcessPerMonitorDpiAware()) {
    // This call gets Windows to scale the non-client area when WM_DPICHANGED
    // is fired on Windows versions < 10.0.14393.0.
    // Derived signature; not available in headers.
    typedef LRESULT(WINAPI * EnableChildWindowDpiMessagePtr)(HWND, BOOL);
    static EnableChildWindowDpiMessagePtr func_ptr =
        reinterpret_cast<EnableChildWindowDpiMessagePtr>(GetProcAddress(
            GetModuleHandle(L"user32.dll"), "EnableChildWindowDpiMessage"));
    if (func_ptr) {
      func_ptr(hwnd_, TRUE);
    }
  }

  if (!initially_hidden) {
    ShowMode mode = ShowNormal;
    if (no_activate) {
      mode = ShowNoActivate;
    } else if (initial_show_state_ == CEF_SHOW_STATE_MAXIMIZED) {
      mode = ShowMaximized;
    } else if (initial_show_state_ == CEF_SHOW_STATE_MINIMIZED) {
      mode = ShowMinimized;
    }

    // Show this window.
    Show(mode);
  }
}

Image
Tony2020
Newbie
 
Posts: 4
Joined: Mon Mar 13, 2023 12:58 am

Re: Moving window will see black edge

Postby Tony2020 » Thu Dec 21, 2023 9:56 pm

I solve this with disable-gpu-compositing.
Tony2020
Newbie
 
Posts: 4
Joined: Mon Mar 13, 2023 12:58 am


Return to Support Forum

Who is online

Users browsing this forum: No registered users and 180 guests