当前位置: 首页>>代码示例>>C++>>正文


C++ CefRefPtr类代码示例

本文整理汇总了C++中CefRefPtr的典型用法代码示例。如果您正苦于以下问题:C++ CefRefPtr类的具体用法?C++ CefRefPtr怎么用?C++ CefRefPtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了CefRefPtr类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: OnAfterCreated

void LootHandler::OnAfterCreated(CefRefPtr<CefBrowser> browser) {
  assert(CefCurrentlyOn(TID_UI));

#ifdef _WIN32
        // Set the title bar icon.
  HWND hWnd = browser->GetHost()->GetWindowHandle();
  HANDLE hIcon = LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(MAINICON), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE);
  HANDLE hIconSm = LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(MAINICON), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE);
  SendMessage(hWnd, WM_SETICON, ICON_BIG, (LPARAM)hIcon);
  SendMessage(hWnd, WM_SETICON, ICON_SMALL, (LPARAM)hIconSm);

  // Set the window title.
  SetWindowText(hWnd, L"LOOT");
#endif

        // Set window size & position.
  if (lootState_.isWindowPositionStored()) {
#ifdef _WIN32
    RECT rc;
    rc.left = lootState_.getWindowPosition().left;
    rc.top = lootState_.getWindowPosition().top;
    rc.right = lootState_.getWindowPosition().right;
    rc.bottom = lootState_.getWindowPosition().bottom;

    // Fit the saved window size/position to the current monitor setup.

    // Get the nearest monitor to the saved size/pos.
    HMONITOR hMonitor;
    hMonitor = MonitorFromRect(&rc, MONITOR_DEFAULTTONEAREST);

    // Get the rect for the monitor's working area.
    MONITORINFO mi;
    mi.cbSize = sizeof(mi);
    GetMonitorInfo(hMonitor, &mi);

    // Clip the saved rect to fit inside the monitor rect.
    int width = rc.right - rc.left;
    int height = rc.bottom - rc.top;
    rc.left = max(mi.rcWork.left, min(mi.rcWork.right - width, rc.left));
    rc.top = max(mi.rcWork.top, min(mi.rcWork.bottom - height, rc.top));
    rc.right = rc.left + width;
    rc.bottom = rc.top + height;

    SetWindowPos(hWnd, HWND_TOP, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, SWP_SHOWWINDOW);
#endif
  } else {
#ifdef _WIN32
            // High DPI support doesn't seem to scale window content correctly
            // unless the window is resized, so if no size info is recorded,
            // just set its current size + 1.
    RECT rc;
    GetWindowRect(browser->GetHost()->GetWindowHandle(), &rc);
    SetWindowPos(browser->GetHost()->GetWindowHandle(), HWND_TOP, rc.left, rc.top, rc.right - rc.left + 1, rc.bottom - rc.top + 1, SWP_SHOWWINDOW);
#endif
  }

  // Add to the list of existing browsers.
  browser_list_.push_back(browser);

  // Create a message router.
  CefMessageRouterConfig config;
  browser_side_router_ = CefMessageRouterBrowserSide::Create(config);

  browser_side_router_->AddHandler(new QueryHandler(lootState_), false);
}
开发者ID:silentdark,项目名称:loot,代码行数:65,代码来源:loot_handler.cpp


注:本文中的CefRefPtr类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。