Better windows handling.

This commit is contained in:
Jacek Caban 2005-11-28 11:17:28 +01:00 committed by Alexandre Julliard
parent c820a3c17f
commit 8be6eb25bd
4 changed files with 66 additions and 36 deletions

View File

@ -21,6 +21,56 @@
WINE_DEFAULT_DEBUG_CHANNEL(shdocvw);
static ATOM doc_view_atom = 0;
static LRESULT WINAPI doc_view_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
WebBrowser *This;
static const WCHAR wszTHIS[] = {'T','H','I','S',0};
if(msg == WM_CREATE) {
This = *(WebBrowser**)lParam;
ERR("create %p\n", This);
SetPropW(hwnd, wszTHIS, This);
}else {
This = GetPropW(hwnd, wszTHIS);
}
return DefWindowProcA(hwnd, msg, wParam, lParam);
}
void create_doc_view_hwnd(WebBrowser *This)
{
RECT rect;
static const WCHAR wszShell_DocObject_View[] =
{'S','h','e','l','l',' ','D','o','c','O','b','j','e','c','t',' ','V','i','e','w',0};
if(!doc_view_atom) {
static WNDCLASSEXW wndclass = {
sizeof(wndclass),
CS_PARENTDC,
doc_view_proc,
0, 0 /* native uses 4*/, NULL, NULL, NULL,
(HBRUSH)COLOR_WINDOWFRAME, NULL,
wszShell_DocObject_View,
NULL
};
wndclass.hInstance = shdocvw_hinstance;
doc_view_atom = RegisterClassExW(&wndclass);
}
GetWindowRect(This->shell_embedding_hwnd, &rect);
This->doc_view_hwnd = CreateWindowExW(0, wszShell_DocObject_View,
wszShell_DocObject_View,
WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_TABSTOP | WS_MAXIMIZEBOX,
rect.left, rect.top, rect.right, rect.bottom, This->shell_embedding_hwnd,
NULL, shdocvw_hinstance, This);
}
#define DOCHOSTUI_THIS(iface) DEFINE_THIS(WebBrowser, DocHostUIHandler, iface)
static HRESULT WINAPI DocHostUIHandler_QueryInterface(IDocHostUIHandler2 *iface,
@ -214,4 +264,6 @@ static const IDocHostUIHandler2Vtbl DocHostUIHandler2Vtbl = {
void WebBrowser_DocHost_Init(WebBrowser *This)
{
This->lpDocHostUIHandlerVtbl = &DocHostUIHandler2Vtbl;
This->doc_view_hwnd = NULL;
}

View File

@ -29,46 +29,13 @@
WINE_DEFAULT_DEBUG_CHANNEL(shdocvw);
static ATOM doc_view_atom = 0;
static ATOM shell_embedding_atom = 0;
static LRESULT WINAPI doc_view_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
return DefWindowProcA(hwnd, msg, wParam, lParam);
}
static LRESULT WINAPI shell_embedding_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
return DefWindowProcA(hwnd, msg, wParam, lParam);
}
static void create_doc_view_hwnd(WebBrowser *This)
{
static const WCHAR wszShell_DocObject_View[] =
{'S','h','e','l','l',' ','D','o','c','O','b','j','e','c','t',' ','V','i','e','w',0};
if(!doc_view_atom) {
static WNDCLASSEXW wndclass = {
sizeof(wndclass),
CS_PARENTDC,
doc_view_proc,
0, 0 /* native uses 4*/, NULL, NULL, NULL,
(HBRUSH)COLOR_WINDOWFRAME, NULL,
wszShell_DocObject_View,
NULL
};
wndclass.hInstance = shdocvw_hinstance;
doc_view_atom = RegisterClassExW(&wndclass);
}
This->doc_view_hwnd = CreateWindowExW(0, wszShell_DocObject_View, NULL,
WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_TABSTOP | WS_MAXIMIZEBOX,
0, 0, 0, 0, This->shell_embedding_hwnd,
NULL, shdocvw_hinstance, This);
}
static void create_shell_embedding_hwnd(WebBrowser *This)
{
IOleInPlaceSite *inplace;
@ -99,12 +66,10 @@ static void create_shell_embedding_hwnd(WebBrowser *This)
IOleInPlaceSite_Release(inplace);
}
This->shell_embedding_hwnd = CreateWindowExW(0, wszShellEmbedding, NULL,
This->shell_embedding_hwnd = CreateWindowExW(0, wszShellEmbedding, wszShellEmbedding,
WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_TABSTOP | WS_MAXIMIZEBOX,
0, 0, 0, 0, parent,
NULL, shdocvw_hinstance, This);
create_doc_view_hwnd(This);
}
/**********************************************************************
@ -266,6 +231,13 @@ static HRESULT WINAPI OleObject_DoVerb(IOleObject *iface, LONG iVerb, struct tag
IOleInPlaceSite_Release(inplace);
SetWindowPos(This->shell_embedding_hwnd, NULL,
This->pos_rect.left, This->pos_rect.top,
This->pos_rect.right-This->pos_rect.left,
This->pos_rect.bottom-This->pos_rect.top,
SWP_NOZORDER | SWP_SHOWWINDOW);
if(This->client) {
IOleClientSite_ShowObject(This->client);
IOleClientSite_GetContainer(This->client, &This->container);
@ -586,6 +558,7 @@ void WebBrowser_OleObject_Init(WebBrowser *This)
This->frame_hwnd = NULL;
This->frame = NULL;
This->uiwindow = NULL;
This->shell_embedding_hwnd = NULL;
memset(&This->pos_rect, 0, sizeof(RECT));
memset(&This->clip_rect, 0, sizeof(RECT));

View File

@ -146,6 +146,8 @@ void WebBrowser_Events_Destroy(WebBrowser*);
HRESULT WebBrowser_Create(IUnknown*,REFIID,void**);
void create_doc_view_hwnd(WebBrowser *This);
#define DEFINE_THIS(cls,ifc,iface) ((cls*)((BYTE*)(iface)-offsetof(cls,lp ## ifc ## Vtbl)))
/**********************************************************************

View File

@ -515,6 +515,9 @@ static HRESULT WINAPI WebBrowser_Navigate2(IWebBrowser2 *iface, VARIANT *URL, VA
if(V_VT(URL) != VT_BSTR)
return E_INVALIDARG;
if(!This->doc_view_hwnd)
create_doc_view_hwnd(This);
/*
* FIXME:
* We should use URLMoniker's BindToObject instead creating HTMLDocument here.