4
所以我使用CEF v3.1180.823,我試圖讓瀏覽器有多個選項卡。嵌入鉻(CEF3)。如何調整新的瀏覽器窗口?
對於每一個新的標籤我是:
1)創建與風格WS_POPUPWINDOW一個新的窗口。
HWND hWndTab = CreateWindowEx(NULL, w.lpszClassName, 0,
WS_POPUPWINDOW, x, y, width, height,
NULL, NULL, hInst, NULL);
2)創建新的 「g_handler」
CefRefPtr<ClientHandler> cef_hTab = new ClientHandler();
3)創建新的瀏覽器
CefBrowserHost::CreateBrowser(info, cef_hTab.get(), _url, settings);
4)設置該窗口作爲子爲第一(主)選項卡從未關閉
SetParent(hWndTab, g_handler->GetMainHwnd());
5)設置新的窗口,主要HWND新處理器的HWND
cef_hTab->SetMainHwnd(hWndTab);
我的問題是:我如何調整我的所有標籤時,主窗口調整?
默認窗口過程(即主選項卡的過程)有這樣的代碼:
case WM_SIZE:
// Minimizing resizes the window to 0x0
// which causes our layout to go all
// screwy, so we just ignore it.
if (wParam != SIZE_MINIMIZED &&
g_handler.get() &&
g_handler->GetBrowser())
{
CefWindowHandle hwnd =
g_handler->GetBrowser()->GetHost()->GetWindowHandle();
if (hwnd)
{
// Resize the browser window and
// address bar to match the new frame
// window size
RECT rect;
GetClientRect(hWnd, &rect);
rect.top += URLBAR_HEIGHT;
int urloffset = rect.left + BUTTON_WIDTH * 4;
HDWP hdwp = BeginDeferWindowPos(1);
hdwp = DeferWindowPos(hdwp, hwnd, NULL, rect.left, rect.top,
rect.right - rect.left, rect.bottom - rect.top, SWP_NOZORDER);
EndDeferWindowPos(hdwp);
}
}
break;
我有我的標籤的一個std ::名單:
#include <vector>
#include <list>
#include "include/cef_app.h"
#include "cefclient/binding_test.h"
using namespace std;
struct STab
{
HWND hWndTab;
HWND hWndTabButton;
CefRefPtr<ClientHandler> cef_handler;
void Destroy();
};
typedef list<STab> LTabs;
LTabs* GetTabs();
而且我想編輯這樣的主窗口過程:
case WM_SIZE:
if (wParam != SIZE_MINIMIZED &&
g_handler.get() &&
g_handler->GetBrowser())
{
CefWindowHandle hwnd =
g_handler->GetBrowser()->GetHost()->GetWindowHandle();
if (hwnd)
{
RECT rect;
GetClientRect(hWnd, &rect);
rect.top += URLBAR_HEIGHT;
int urloffset = rect.left + BUTTON_WIDTH * 4;
HDWP hdwp = BeginDeferWindowPos(1);
hdwp = DeferWindowPos(hdwp, hwnd, NULL, rect.left, rect.top,
rect.right - rect.left, rect.bottom - rect.top, SWP_NOZORDER);
// added:
//------------------------------------------------------------------
LTabs* lTabs = GetTabs();
LTabs::iterator it;
for (it = lTabs->begin(); it != lTabs->end(); ++it)
{
CefWindowHandle hWndTab =
it->cef_handler->GetBrowser()->GetHost()->GetWindowHandle();
if (hWndTab)
hdwp = DeferWindowPos(hdwp, hWndTab, NULL,
rect.left, rect.top, rect.right - rect.left,
rect.bottom - rect.top, SWP_NOZORDER);
}
//------------------------------------------------------------------
EndDeferWindowPos(hdwp);
}
}
break;
但在調整主窗口調整大小既不主選項卡,也沒有我自定義標籤。
我到底做錯了什麼?
你解決了嗎?如果是這樣,你可以發佈你的解決方案,並接受它作爲答案。你的回答可能會幫助其他許多程序員。 –