From f0dea6d3a02d180ce22da374f55563a1ced3e63d Mon Sep 17 00:00:00 2001 From: Martin Fuchs Date: Tue, 10 Feb 2004 22:15:20 +0000 Subject: [PATCH] store statustexts in MDI children svn path=/trunk/; revision=8139 --- .../system/explorer/shell/filechild.cpp | 2 +- .../subsys/system/explorer/shell/mainframe.h | 2 - .../system/explorer/shell/shellbrowser.cpp | 2 +- .../subsys/system/explorer/shell/webchild.cpp | 10 +-- .../subsys/system/explorer/shell/webchild.h | 79 +++++++------------ .../subsys/system/explorer/utility/window.cpp | 10 ++- .../subsys/system/explorer/utility/window.h | 7 +- 7 files changed, 50 insertions(+), 62 deletions(-) diff --git a/reactos/subsys/system/explorer/shell/filechild.cpp b/reactos/subsys/system/explorer/shell/filechild.cpp index 278f64e0130..d6c910c5143 100644 --- a/reactos/subsys/system/explorer/shell/filechild.cpp +++ b/reactos/subsys/system/explorer/shell/filechild.cpp @@ -96,7 +96,7 @@ WebChildWndInfo::WebChildWndInfo(HWND hmdiclient, LPCTSTR url) FileChildWindow::FileChildWindow(HWND hwnd, const FileChildWndInfo& info) - : ChildWindow(hwnd) + : ChildWindow(hwnd, info) { CONTEXT("FileChildWindow::FileChildWindow()"); diff --git a/reactos/subsys/system/explorer/shell/mainframe.h b/reactos/subsys/system/explorer/shell/mainframe.h index 19781d522ea..3a58759aa79 100644 --- a/reactos/subsys/system/explorer/shell/mainframe.h +++ b/reactos/subsys/system/explorer/shell/mainframe.h @@ -29,8 +29,6 @@ #define PM_OPEN_WINDOW (WM_APP+0x07) enum OPEN_WINDOW_MODE {OWM_EXPLORE=1, OWM_DETAILS=2, OWM_PIDL=4}; -#define PM_SETSTATUSTEXT (WM_APP+0x1D) - /// Explorer frame window struct MainFrame : public PreTranslateWindow diff --git a/reactos/subsys/system/explorer/shell/shellbrowser.cpp b/reactos/subsys/system/explorer/shell/shellbrowser.cpp index 83a90154bb1..fe1c9fd3838 100644 --- a/reactos/subsys/system/explorer/shell/shellbrowser.cpp +++ b/reactos/subsys/system/explorer/shell/shellbrowser.cpp @@ -49,7 +49,7 @@ static LPARAM TreeView_GetItemData(HWND hwndTreeView, HTREEITEM hItem) ShellBrowserChild::ShellBrowserChild(HWND hwnd, const ShellChildWndInfo& info) - : super(hwnd), + : super(hwnd, info), _create_info(info) { _pShellView = NULL; diff --git a/reactos/subsys/system/explorer/shell/webchild.cpp b/reactos/subsys/system/explorer/shell/webchild.cpp index ac230b78d0f..ab797235a79 100644 --- a/reactos/subsys/system/explorer/shell/webchild.cpp +++ b/reactos/subsys/system/explorer/shell/webchild.cpp @@ -192,7 +192,8 @@ static const CLSID CLSID_MozillaBrowser = WebChildWindow::WebChildWindow(HWND hwnd, const WebChildWndInfo& info) - : super(hwnd) + : super(hwnd, info), + web_super(_navigator) { // first try to create a web control with MS IE's CLASSID HRESULT hr = create_control(hwnd, CLSID_WebBrowser, IID_IWebBrowser2); @@ -204,15 +205,12 @@ WebChildWindow::WebChildWindow(HWND hwnd, const WebChildWndInfo& info) if (SUCCEEDED(hr)) { _navigator.attach(_control); - HWND hwndFrame = GetParent(info._hmdiclient); - - // handling events using DWebBrowserEvents2 - _evt_handler = auto_ptr(new DWebBrowserEvents2Handler(_hwnd, hwndFrame, _navigator)); + _connector = auto_ptr(new EventConnector(_control, DIID_DWebBrowserEvents2, this)); #ifdef __MINGW32__ // MinGW is lacking vtMissing (as of 07.02.2004) Variant vtMissing; #endif - get_browser()->Navigate(BStr(info._path), &vtMissing, &vtMissing, &vtMissing, &vtMissing); + _control->Navigate(BStr(info._path), &vtMissing, &vtMissing, &vtMissing, &vtMissing); //browser->Navigate2(&Variant(info._path), &vtMissing, &vtMissing, &vtMissing, &vtMissing); } } diff --git a/reactos/subsys/system/explorer/shell/webchild.h b/reactos/subsys/system/explorer/shell/webchild.h index 2bf19b20161..207b5b640c3 100644 --- a/reactos/subsys/system/explorer/shell/webchild.h +++ b/reactos/subsys/system/explorer/shell/webchild.h @@ -398,6 +398,11 @@ template struct IPCtrlWindow : public BASE { } + template IPCtrlWindow(HWND hwnd, T& info) + : super(hwnd, info) + { + } + HRESULT create_control(HWND hwnd, REFIID clsid, REFIID riid) { // Erzeugen einer Instanz des Controls @@ -565,8 +570,8 @@ struct DWebBrowserEvents2IF }; - // Das Webbrowser-Control muß zunächst komplett initialisiert sein, bevor eine Seite, - // die nicht auf das Internet zugreift (z.B. addcom/./index.html) dargestellt werden kann. + // The web browser control has to be initialized completely before being able, + // to display a page, that does not access internet. struct ANSUNC BrowserNavigator { BrowserNavigator(); @@ -676,7 +681,7 @@ struct ANSUNC DWebBrowserEvents2Impl : public SimpleComObject, break; - //-> anything below here is not present in DWebBrowserEvents, only in DWebBrowserEvents2: + // anything below here is not present in DWebBrowserEvents, only in DWebBrowserEvents2: -> case DISPID_FRAMEBEFORENAVIGATE: if (pDispParams->cArgs != 6) @@ -886,23 +891,28 @@ protected: }; - /// Web control Eventhandler using DWebBrowserEvents2Impl - -struct DWebBrowserEvents2Handler : public DWebBrowserEvents2Impl + /// encapsulation of Web control in MDI child windows +struct WebChildWindow : public IPCtrlWindow >, + public DWebBrowserEvents2Impl { - typedef DWebBrowserEvents2Impl super; + typedef IPCtrlWindow > super; + typedef DWebBrowserEvents2Impl web_super; - DWebBrowserEvents2Handler(HWND hwnd, HWND hwndFrame, BrowserNavigator& navigator) - : DWebBrowserEvents2Impl(navigator), - _hwnd(hwnd), - _hwndFrame(hwndFrame), - _navigator(navigator), - _browser(navigator.get_browser(), IID_IWebBrowser2), - _connector(navigator.get_browser(), DIID_DWebBrowserEvents2, this) + WebChildWindow(HWND hwnd, const WebChildWndInfo& info); + + static WebChildWindow* create(const FileChildWndInfo& info) { + ChildWindow* child = ChildWindow::create(info, info._pos.rcNormalPosition, + WINDOW_CREATOR_INFO(WebChildWindow,WebChildWndInfo), CLASSNAME_CHILDWND, NULL); + + ShowWindow(*child, info._pos.showCmd); + + return static_cast(child); } -protected: + + // DWebBrowserEvents2Impl overides -> + void BeforeNavigate2(IDispatch* pDisp, const Variant& url, const Variant& flags, const Variant& targetFrameName, const Variant& postData, const Variant& headers, VARIANT_BOOL& cancel) @@ -913,12 +923,13 @@ protected: void NavigateComplete2(IDispatch* pDisp, const Variant& url) { //String adr = (BStr)url; - super::NavigateComplete2(pDisp, url); + web_super::NavigateComplete2(pDisp, url); } void StatusTextChange(const BStr& text) { - SendMessage(_hwndFrame, PM_SETSTATUSTEXT, 0, (LPARAM)String(text).c_str()); + _statusText = text; + SendMessage(_hwndFrame, PM_SETSTATUSTEXT, 0, (LPARAM)_statusText.c_str()); } void ProgressChange(long Progress, long ProgressMax) @@ -940,7 +951,7 @@ protected: void PropertyChange(const BStr& Property) { Variant value; - _browser->GetProperty(Property, &value); + _control->GetProperty(Property, &value); } void CommandStateChange(long command/*CSC_NAVIGATEFORWARD, CSC_NAVIGATEBACK*/, bool enable) @@ -1058,40 +1069,10 @@ protected: { } -protected: - HWND _hwnd; - HWND _hwndFrame; - BrowserNavigator& _navigator; - SIfacePtr _browser; - EventConnector _connector; -}; - - - /// encapsulation of Web control in MDI child windows -struct WebChildWindow : public IPCtrlWindow > -{ - typedef IPCtrlWindow > super; - - WebChildWindow(HWND hwnd, const WebChildWndInfo& info); - - static WebChildWindow* create(const FileChildWndInfo& info) - { - ChildWindow* child = ChildWindow::create(info, info._pos.rcNormalPosition, - WINDOW_CREATOR_INFO(WebChildWindow,WebChildWndInfo), CLASSNAME_CHILDWND, NULL); - - ShowWindow(*child, info._pos.showCmd); - - return static_cast(child); - } - - IWebBrowser2* get_browser() - { - return _control; - } protected: BrowserNavigator _navigator; - auto_ptr _evt_handler; + auto_ptr _connector; LRESULT WndProc(UINT message, WPARAM wparam, LPARAM lparam); }; diff --git a/reactos/subsys/system/explorer/utility/window.cpp b/reactos/subsys/system/explorer/utility/window.cpp index 960f020c94b..54a0f69d8c7 100644 --- a/reactos/subsys/system/explorer/utility/window.cpp +++ b/reactos/subsys/system/explorer/utility/window.cpp @@ -368,8 +368,9 @@ int SubclassedWindow::Notify(int id, NMHDR* pnmh) } -ChildWindow::ChildWindow(HWND hwnd) - : super(hwnd) +ChildWindow::ChildWindow(HWND hwnd, const ChildWndInfo& info) + : super(hwnd), + _hwndFrame(GetParent(info._hmdiclient)) { _focus_pane = 0; _split_pos = DEFAULT_SPLIT_POS; @@ -487,6 +488,11 @@ LRESULT ChildWindow::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam) case PM_DISPATCH_COMMAND: return FALSE; + case WM_MDIACTIVATE: + if ((HWND)lparam == _hwnd) + SendMessage(_hwndFrame, PM_SETSTATUSTEXT, 0, (LPARAM)_statusText.c_str()); + break; + default: def: return DefMDIChildProc(_hwnd, nmsg, wparam, lparam); } diff --git a/reactos/subsys/system/explorer/utility/window.h b/reactos/subsys/system/explorer/utility/window.h index 3727a2448c8..836406eacc1 100644 --- a/reactos/subsys/system/explorer/utility/window.h +++ b/reactos/subsys/system/explorer/utility/window.h @@ -285,7 +285,7 @@ struct ChildWindow : public Window { typedef Window super; - ChildWindow(HWND hwnd); + ChildWindow(HWND hwnd, const ChildWndInfo& info); static ChildWindow* create(const ChildWndInfo& info, const RECT& rect, CREATORFUNC_INFO creator, LPCTSTR classname, LPCTSTR title=NULL); @@ -304,8 +304,13 @@ protected: int _split_pos; int _last_split; + + HWND _hwndFrame; + String _statusText; }; +#define PM_SETSTATUSTEXT (WM_APP+0x1D) + /** PreTranslateWindow is used to register windows to be called by Window::pretranslate_msg().