Visual c++ 嵌入铬(CEF3)。如何调整新浏览器窗口的大小?
所以我使用的是CEF v3.1180.823,我正试图使浏览器具有多个选项卡 对于每个新选项卡,我都: 1) 创建样式为WS_POPUPWINDOW的新窗口Visual c++ 嵌入铬(CEF3)。如何调整新浏览器窗口的大小?,visual-c++,tabs,resize,popup,chromium-embedded,Visual C++,Tabs,Resize,Popup,Chromium Embedded,所以我使用的是CEF v3.1180.823,我正试图使浏览器具有多个选项卡 对于每个新选项卡,我都: 1) 创建样式为WS_POPUPWINDOW的新窗口 HWND hWndTab = CreateWindowEx(NULL, w.lpszClassName, 0, WS_POPUPWINDOW, x, y, width, height, NULL, NULL, hInst, NULL); 2) 创建新的“g_处理程序” 4) 将此窗口设置为从不关闭的第一个(主)选项卡的子
HWND hWndTab = CreateWindowEx(NULL, w.lpszClassName, 0,
WS_POPUPWINDOW, x, y, width, height,
NULL, NULL, hInst, NULL);
2) 创建新的“g_处理程序”
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;
我有一个我的标签列表:
#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();
但在调整主窗口大小时,它既不调整主选项卡的大小,也不调整我的自定义选项卡的大小
我做错了什么?快速解决方法是使用
SetWindowPos
函数而不是DeferWindowPos
函数
//hdwp = DeferWindowPos(hdwp, hWndTab, NULL,
// rect.left, rect.top, rect.right - rect.left,
// rect.bottom - rect.top, SWP_NOZORDER);
SetWindowPos(hWndTab, NULL, rect.left, rect.top,
rect.right - rect.left, rect.bottom - rect.top,
SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE);
你解决了这个问题吗?如果是这样,你可以发布你的解决方案并接受它作为答案。您的回答可能会帮助许多其他程序员。
#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;
//hdwp = DeferWindowPos(hdwp, hWndTab, NULL,
// rect.left, rect.top, rect.right - rect.left,
// rect.bottom - rect.top, SWP_NOZORDER);
SetWindowPos(hWndTab, NULL, rect.left, rect.top,
rect.right - rect.left, rect.bottom - rect.top,
SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE);