mirror of
https://github.com/reactos/reactos.git
synced 2026-09-11 04:11:38 +08:00
[MMC_NEW] Move the snapin root pointer and implement register and unregister for views
- MMC maintains one snapin tree per instance. Each console is just a view of this tree. Therefore I moved the snapin root pointer from the console window to the main window. - Implement the register and unregister functions for the view and a common UpdateViews function that call UpdateView for each registered view.
This commit is contained in:
277
base/applications/mmc_new/CConsoleWnd.cpp
Normal file
277
base/applications/mmc_new/CConsoleWnd.cpp
Normal file
@@ -0,0 +1,277 @@
|
||||
/*
|
||||
* PROJECT: ReactOS Management Console
|
||||
* LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
|
||||
* PURPOSE: Single 'console' window
|
||||
* COPYRIGHT: Copyright 2006-2007 Thomas Weidenmueller
|
||||
* Copyright 2017 Mark Jansen (mark.jansen@reactos.org)
|
||||
*/
|
||||
|
||||
#include "precomp.h"
|
||||
|
||||
CConsoleWnd::CConsoleWnd(CMainWnd *MainWnd)
|
||||
{
|
||||
m_MainWnd = MainWnd;
|
||||
m_pfnSuperWindowProc = DefMDIChildProc;
|
||||
|
||||
if (!m_thunk.Init(NULL, NULL))
|
||||
return;
|
||||
_AtlWinModule.AddCreateWndData(&m_thunk.cd, this);
|
||||
}
|
||||
|
||||
CConsoleWnd::~CConsoleWnd()
|
||||
{
|
||||
}
|
||||
|
||||
LRESULT CConsoleWnd::OnCreate(UINT nMessage, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
SetWindowLongPtr(0, (LONG_PTR)this);
|
||||
|
||||
LPMDICREATESTRUCT mdicreate = reinterpret_cast<LPMDICREATESTRUCT>(reinterpret_cast<LPCREATESTRUCT>(lParam)->lpCreateParams);
|
||||
if (mdicreate->lParam)
|
||||
PostMessage(WM_SYSCOMMAND, SC_MAXIMIZE, 0);
|
||||
|
||||
m_ViewId = m_MainWnd->RegisterView(this);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
LRESULT CConsoleWnd::OnDestroy(UINT nMessage, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
m_MainWnd->UnregisterView(this);
|
||||
m_MainWnd->PostMessage(WM_USER_CLOSE_CHILD, 0, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
VOID CConsoleWnd::UpdateView()
|
||||
{
|
||||
}
|
||||
|
||||
// +IConsole
|
||||
STDMETHODIMP CConsoleWnd::QueryInterface(REFIID riid, void **ppvObject)
|
||||
{
|
||||
if (riid == IID_IUnknown || riid == IID_IConsole)
|
||||
{
|
||||
*ppvObject = static_cast<IConsole*>(this);
|
||||
AddRef();
|
||||
return S_OK;
|
||||
}
|
||||
else if (riid == IID_IConsole2)
|
||||
{
|
||||
*ppvObject = static_cast<IConsole2*>(this);
|
||||
AddRef();
|
||||
return S_OK;
|
||||
}
|
||||
else if (riid == IID_IConsoleNameSpace)
|
||||
{
|
||||
*ppvObject = static_cast<IConsoleNameSpace*>(this);
|
||||
AddRef();
|
||||
return S_OK;
|
||||
}
|
||||
else if (riid == IID_IConsoleNameSpace2)
|
||||
{
|
||||
*ppvObject = static_cast<IConsoleNameSpace2*>(this);
|
||||
AddRef();
|
||||
return S_OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
CComHeapPtr<OLECHAR> guidstr;
|
||||
HRESULT hr = StringFromCLSID(riid, &guidstr);
|
||||
if (SUCCEEDED(hr))
|
||||
DPRINT1("Unhandled riid: %S\n", (PCWSTR)guidstr);
|
||||
else
|
||||
DPRINT1("Unhandled riid\n");
|
||||
}
|
||||
|
||||
|
||||
*ppvObject = NULL;
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
|
||||
STDMETHODIMP_(ULONG) CConsoleWnd::AddRef()
|
||||
{
|
||||
DPRINT("%s()\n", __FUNCTION__);
|
||||
return 2;
|
||||
}
|
||||
|
||||
STDMETHODIMP_(ULONG) CConsoleWnd::Release()
|
||||
{
|
||||
DPRINT("%s()\n", __FUNCTION__);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
STDMETHODIMP CConsoleWnd::SetHeader(LPHEADERCTRL pHeader)
|
||||
{
|
||||
DPRINT("%s()\n", __FUNCTION__);
|
||||
__debugbreak();
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
STDMETHODIMP CConsoleWnd::SetToolbar(LPTOOLBAR pToolbar)
|
||||
{
|
||||
DPRINT("%s()\n", __FUNCTION__);
|
||||
__debugbreak();
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
STDMETHODIMP CConsoleWnd::QueryResultView(LPUNKNOWN *pUnknown)
|
||||
{
|
||||
DPRINT("%s()\n", __FUNCTION__);
|
||||
__debugbreak();
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
STDMETHODIMP CConsoleWnd::QueryScopeImageList(LPIMAGELIST *ppImageList)
|
||||
{
|
||||
DPRINT("%s(%p)\n", __FUNCTION__);
|
||||
if (!ppImageList)
|
||||
return E_INVALIDARG;
|
||||
|
||||
__debugbreak();
|
||||
//*ppImageList = m_ScopeImageList;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CConsoleWnd::QueryResultImageList(LPIMAGELIST *ppImageList)
|
||||
{
|
||||
DPRINT("%s()\n", __FUNCTION__);
|
||||
__debugbreak();
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
STDMETHODIMP CConsoleWnd::UpdateAllViews(LPDATAOBJECT lpDataObject, LPARAM data, LONG_PTR hint)
|
||||
{
|
||||
DPRINT("%s()\n", __FUNCTION__);
|
||||
__debugbreak();
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
STDMETHODIMP CConsoleWnd::MessageBox(LPCWSTR lpszText, LPCWSTR lpszTitle, UINT fuStyle, int *piRetval)
|
||||
{
|
||||
DPRINT("%s()\n", __FUNCTION__);
|
||||
__debugbreak();
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
STDMETHODIMP CConsoleWnd::QueryConsoleVerb(LPCONSOLEVERB *ppConsoleVerb)
|
||||
{
|
||||
DPRINT("%s()\n", __FUNCTION__);
|
||||
__debugbreak();
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
STDMETHODIMP CConsoleWnd::SelectScopeItem(HSCOPEITEM hScopeItem)
|
||||
{
|
||||
DPRINT("%s()\n", __FUNCTION__);
|
||||
__debugbreak();
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
STDMETHODIMP CConsoleWnd::GetMainWindow(HWND *phwnd)
|
||||
{
|
||||
DPRINT("%s()\n", __FUNCTION__);
|
||||
__debugbreak();
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
STDMETHODIMP CConsoleWnd::NewWindow(HSCOPEITEM hScopeItem, ULONG lOptions)
|
||||
{
|
||||
DPRINT("%s()\n", __FUNCTION__);
|
||||
__debugbreak();
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
// -IConsole
|
||||
|
||||
// +IConsole2
|
||||
STDMETHODIMP CConsoleWnd::Expand(HSCOPEITEM hItem, BOOL bExpand)
|
||||
{
|
||||
DPRINT("%s()\n", __FUNCTION__);
|
||||
__debugbreak();
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
STDMETHODIMP CConsoleWnd::IsTaskpadViewPreferred()
|
||||
{
|
||||
DPRINT("%s()\n", __FUNCTION__);
|
||||
__debugbreak();
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
|
||||
STDMETHODIMP CConsoleWnd::SetStatusText(LPOLESTR pszStatusText)
|
||||
{
|
||||
DPRINT("%s()\n", __FUNCTION__);
|
||||
__debugbreak();
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
// -IConsole2
|
||||
|
||||
// +IConsoleNameSpace
|
||||
STDMETHODIMP CConsoleWnd::InsertItem(LPSCOPEDATAITEM item)
|
||||
{
|
||||
DPRINT("%s()\n", __FUNCTION__);
|
||||
__debugbreak();
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
STDMETHODIMP CConsoleWnd::DeleteItem(HSCOPEITEM hItem, LONG fDeleteThis)
|
||||
{
|
||||
DPRINT("%s()\n", __FUNCTION__);
|
||||
__debugbreak();
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
STDMETHODIMP CConsoleWnd::SetItem(LPSCOPEDATAITEM item)
|
||||
{
|
||||
DPRINT("%s()\n", __FUNCTION__);
|
||||
__debugbreak();
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
STDMETHODIMP CConsoleWnd::GetItem(LPSCOPEDATAITEM item)
|
||||
{
|
||||
DPRINT("%s()\n", __FUNCTION__);
|
||||
__debugbreak();
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
STDMETHODIMP CConsoleWnd::GetChildItem(HSCOPEITEM item, HSCOPEITEM *pItemChild, LONG *plCookie)
|
||||
{
|
||||
DPRINT("%s()\n", __FUNCTION__);
|
||||
__debugbreak();
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
STDMETHODIMP CConsoleWnd::GetNextItem(HSCOPEITEM item, HSCOPEITEM *pItemNext, LONG *plCookie)
|
||||
{
|
||||
DPRINT("%s()\n", __FUNCTION__);
|
||||
__debugbreak();
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
STDMETHODIMP CConsoleWnd::GetParentItem(HSCOPEITEM item, HSCOPEITEM *pItemParent, LONG *plCookie)
|
||||
{
|
||||
DPRINT("%s()\n", __FUNCTION__);
|
||||
__debugbreak();
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
// -IConsoleNameSpace
|
||||
|
||||
|
||||
|
||||
// +IConsoleNameSpace2
|
||||
STDMETHODIMP CConsoleWnd::Expand(HSCOPEITEM hItem)
|
||||
{
|
||||
DPRINT("%s()\n", __FUNCTION__);
|
||||
__debugbreak();
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
STDMETHODIMP CConsoleWnd::AddExtension(HSCOPEITEM hItem, LPCLSID lpClsid)
|
||||
{
|
||||
DPRINT("%s()\n", __FUNCTION__);
|
||||
__debugbreak();
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
// -IConsoleNameSpace2
|
||||
@@ -8,13 +8,16 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
class CMainWnd;
|
||||
|
||||
class CConsoleWnd :
|
||||
public CWindowImpl<CConsoleWnd>,
|
||||
public IConsole2,
|
||||
public IConsoleNameSpace2
|
||||
{
|
||||
private:
|
||||
CWindow* m_MainWnd;
|
||||
CMainWnd *m_MainWnd;
|
||||
int m_ViewId;
|
||||
|
||||
public:
|
||||
CAtlString m_Filename;
|
||||
@@ -47,278 +50,62 @@ public:
|
||||
/* lpszClassName= */L"MMCChildFrm",
|
||||
/* hIconSm= */LoadIcon(_AtlBaseModule.GetModuleInstance(), MAKEINTRESOURCE(IDI_MAINAPP))
|
||||
},
|
||||
NULL, NULL, IDC_ARROW, TRUE, 0, _T("")
|
||||
NULL, NULL, IDC_ARROW, TRUE, 0, L""
|
||||
};
|
||||
return wc;
|
||||
}
|
||||
|
||||
|
||||
static LPCTSTR GetWndClassName()
|
||||
static LPCWSTR GetWndClassName()
|
||||
{
|
||||
return GetWndClassInfo().m_wc.lpszClassName;
|
||||
}
|
||||
|
||||
public:
|
||||
CConsoleWnd(CWindow* parent)
|
||||
{
|
||||
m_MainWnd = parent;
|
||||
m_pfnSuperWindowProc = DefMDIChildProc;
|
||||
CConsoleWnd(CMainWnd *MainWnd);
|
||||
~CConsoleWnd();
|
||||
|
||||
//m_ScopeImageList = new CComObject<CImageList>();
|
||||
|
||||
if (!m_thunk.Init(NULL, NULL))
|
||||
return;
|
||||
_AtlWinModule.AddCreateWndData(&m_thunk.cd, this);
|
||||
}
|
||||
|
||||
LRESULT OnCreate(UINT nMessage, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
SetWindowLongPtr(0, (LONG_PTR)this);
|
||||
|
||||
LPMDICREATESTRUCT mdicreate = reinterpret_cast<LPMDICREATESTRUCT>(reinterpret_cast<LPCREATESTRUCT>(lParam)->lpCreateParams);
|
||||
if (mdicreate->lParam)
|
||||
PostMessage(WM_SYSCOMMAND, SC_MAXIMIZE, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
LRESULT OnDestroy(UINT nMessage, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
||||
{
|
||||
m_MainWnd->PostMessage(WM_USER_CLOSE_CHILD, 0, 0);
|
||||
return 0;
|
||||
}
|
||||
LRESULT OnCreate(UINT nMessage, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||
LRESULT OnDestroy(UINT nMessage, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
||||
|
||||
VOID UpdateView();
|
||||
|
||||
// +IConsole
|
||||
STDMETHODIMP QueryInterface(REFIID riid, void **ppvObject)
|
||||
{
|
||||
if (riid == IID_IUnknown || riid == IID_IConsole)
|
||||
{
|
||||
*ppvObject = static_cast<IConsole*>(this);
|
||||
AddRef();
|
||||
return S_OK;
|
||||
}
|
||||
else if (riid == IID_IConsole2)
|
||||
{
|
||||
*ppvObject = static_cast<IConsole2*>(this);
|
||||
AddRef();
|
||||
return S_OK;
|
||||
}
|
||||
else if (riid == IID_IConsoleNameSpace)
|
||||
{
|
||||
*ppvObject = static_cast<IConsoleNameSpace*>(this);
|
||||
AddRef();
|
||||
return S_OK;
|
||||
}
|
||||
else if (riid == IID_IConsoleNameSpace2)
|
||||
{
|
||||
*ppvObject = static_cast<IConsoleNameSpace2*>(this);
|
||||
AddRef();
|
||||
return S_OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
CComHeapPtr<OLECHAR> guidstr;
|
||||
HRESULT hr = StringFromCLSID(riid, &guidstr);
|
||||
if (SUCCEEDED(hr))
|
||||
DPRINT1("Unhandled riid: %S\n", (PCWSTR)guidstr);
|
||||
else
|
||||
DPRINT1("Unhandled riid\n");
|
||||
}
|
||||
STDMETHODIMP QueryInterface(REFIID riid, void **ppvObject);
|
||||
STDMETHODIMP_(ULONG) AddRef();
|
||||
STDMETHODIMP_(ULONG) Release();
|
||||
|
||||
|
||||
*ppvObject = NULL;
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
|
||||
STDMETHODIMP_(ULONG) AddRef()
|
||||
{
|
||||
DPRINT("%s()\n", __FUNCTION__);
|
||||
return 2;
|
||||
}
|
||||
|
||||
STDMETHODIMP_(ULONG) Release()
|
||||
{
|
||||
DPRINT("%s()\n", __FUNCTION__);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
STDMETHODIMP SetHeader(LPHEADERCTRL pHeader)
|
||||
{
|
||||
DPRINT("%s()\n", __FUNCTION__);
|
||||
__debugbreak();
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
STDMETHODIMP SetToolbar(LPTOOLBAR pToolbar)
|
||||
{
|
||||
DPRINT("%s()\n", __FUNCTION__);
|
||||
__debugbreak();
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
STDMETHODIMP QueryResultView(LPUNKNOWN *pUnknown)
|
||||
{
|
||||
DPRINT("%s()\n", __FUNCTION__);
|
||||
__debugbreak();
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
STDMETHODIMP QueryScopeImageList(LPIMAGELIST *ppImageList)
|
||||
{
|
||||
DPRINT("%s(%p)\n", __FUNCTION__);
|
||||
if (!ppImageList)
|
||||
return E_INVALIDARG;
|
||||
|
||||
__debugbreak();
|
||||
//*ppImageList = m_ScopeImageList;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP QueryResultImageList(LPIMAGELIST *ppImageList)
|
||||
{
|
||||
DPRINT("%s()\n", __FUNCTION__);
|
||||
__debugbreak();
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
STDMETHODIMP UpdateAllViews(LPDATAOBJECT lpDataObject, LPARAM data, LONG_PTR hint)
|
||||
{
|
||||
DPRINT("%s()\n", __FUNCTION__);
|
||||
__debugbreak();
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
STDMETHODIMP MessageBox(LPCWSTR lpszText, LPCWSTR lpszTitle, UINT fuStyle, int *piRetval)
|
||||
{
|
||||
DPRINT("%s()\n", __FUNCTION__);
|
||||
__debugbreak();
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
STDMETHODIMP QueryConsoleVerb(LPCONSOLEVERB *ppConsoleVerb)
|
||||
{
|
||||
DPRINT("%s()\n", __FUNCTION__);
|
||||
__debugbreak();
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
STDMETHODIMP SelectScopeItem(HSCOPEITEM hScopeItem)
|
||||
{
|
||||
DPRINT("%s()\n", __FUNCTION__);
|
||||
__debugbreak();
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
STDMETHODIMP GetMainWindow(HWND *phwnd)
|
||||
{
|
||||
DPRINT("%s()\n", __FUNCTION__);
|
||||
__debugbreak();
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
STDMETHODIMP NewWindow(HSCOPEITEM hScopeItem, ULONG lOptions)
|
||||
{
|
||||
DPRINT("%s()\n", __FUNCTION__);
|
||||
__debugbreak();
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
STDMETHODIMP SetHeader(LPHEADERCTRL pHeader);
|
||||
STDMETHODIMP SetToolbar(LPTOOLBAR pToolbar);
|
||||
STDMETHODIMP QueryResultView(LPUNKNOWN *pUnknown);
|
||||
STDMETHODIMP QueryScopeImageList(LPIMAGELIST *ppImageList);
|
||||
STDMETHODIMP QueryResultImageList(LPIMAGELIST *ppImageList);
|
||||
STDMETHODIMP UpdateAllViews(LPDATAOBJECT lpDataObject, LPARAM data, LONG_PTR hint);
|
||||
STDMETHODIMP MessageBox(LPCWSTR lpszText, LPCWSTR lpszTitle, UINT fuStyle, int *piRetval);
|
||||
STDMETHODIMP QueryConsoleVerb(LPCONSOLEVERB *ppConsoleVerb);
|
||||
STDMETHODIMP SelectScopeItem(HSCOPEITEM hScopeItem);
|
||||
STDMETHODIMP GetMainWindow(HWND *phwnd);
|
||||
STDMETHODIMP NewWindow(HSCOPEITEM hScopeItem, ULONG lOptions);
|
||||
// -IConsole
|
||||
|
||||
// +IConsole2
|
||||
STDMETHODIMP Expand(HSCOPEITEM hItem, BOOL bExpand)
|
||||
{
|
||||
DPRINT("%s()\n", __FUNCTION__);
|
||||
__debugbreak();
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
STDMETHODIMP IsTaskpadViewPreferred()
|
||||
{
|
||||
DPRINT("%s()\n", __FUNCTION__);
|
||||
__debugbreak();
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
|
||||
STDMETHODIMP SetStatusText(LPOLESTR pszStatusText)
|
||||
{
|
||||
DPRINT("%s()\n", __FUNCTION__);
|
||||
__debugbreak();
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
STDMETHODIMP Expand(HSCOPEITEM hItem, BOOL bExpand);
|
||||
STDMETHODIMP IsTaskpadViewPreferred();
|
||||
STDMETHODIMP SetStatusText(LPOLESTR pszStatusText);
|
||||
// -IConsole2
|
||||
|
||||
// +IConsoleNameSpace
|
||||
STDMETHODIMP InsertItem(LPSCOPEDATAITEM item)
|
||||
{
|
||||
DPRINT("%s()\n", __FUNCTION__);
|
||||
__debugbreak();
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
STDMETHODIMP DeleteItem(HSCOPEITEM hItem, LONG fDeleteThis)
|
||||
{
|
||||
DPRINT("%s()\n", __FUNCTION__);
|
||||
__debugbreak();
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
STDMETHODIMP SetItem(LPSCOPEDATAITEM item)
|
||||
{
|
||||
DPRINT("%s()\n", __FUNCTION__);
|
||||
__debugbreak();
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
STDMETHODIMP GetItem(LPSCOPEDATAITEM item)
|
||||
{
|
||||
DPRINT("%s()\n", __FUNCTION__);
|
||||
__debugbreak();
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
STDMETHODIMP GetChildItem(HSCOPEITEM item, HSCOPEITEM *pItemChild, LONG *plCookie)
|
||||
{
|
||||
DPRINT("%s()\n", __FUNCTION__);
|
||||
__debugbreak();
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
STDMETHODIMP GetNextItem(HSCOPEITEM item, HSCOPEITEM *pItemNext, LONG *plCookie)
|
||||
{
|
||||
DPRINT("%s()\n", __FUNCTION__);
|
||||
__debugbreak();
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
STDMETHODIMP GetParentItem(HSCOPEITEM item, HSCOPEITEM *pItemParent, LONG *plCookie)
|
||||
{
|
||||
DPRINT("%s()\n", __FUNCTION__);
|
||||
__debugbreak();
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
STDMETHODIMP InsertItem(LPSCOPEDATAITEM item);
|
||||
STDMETHODIMP DeleteItem(HSCOPEITEM hItem, LONG fDeleteThis);
|
||||
STDMETHODIMP SetItem(LPSCOPEDATAITEM item);
|
||||
STDMETHODIMP GetItem(LPSCOPEDATAITEM item);
|
||||
STDMETHODIMP GetChildItem(HSCOPEITEM item, HSCOPEITEM *pItemChild, LONG *plCookie);
|
||||
STDMETHODIMP GetNextItem(HSCOPEITEM item, HSCOPEITEM *pItemNext, LONG *plCookie);
|
||||
STDMETHODIMP GetParentItem(HSCOPEITEM item, HSCOPEITEM *pItemParent, LONG *plCookie);
|
||||
// -IConsoleNameSpace
|
||||
|
||||
|
||||
|
||||
// +IConsoleNameSpace2
|
||||
STDMETHODIMP Expand(HSCOPEITEM hItem)
|
||||
{
|
||||
DPRINT("%s()\n", __FUNCTION__);
|
||||
__debugbreak();
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
STDMETHODIMP AddExtension(HSCOPEITEM hItem, LPCLSID lpClsid)
|
||||
{
|
||||
DPRINT("%s()\n", __FUNCTION__);
|
||||
__debugbreak();
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
STDMETHODIMP Expand(HSCOPEITEM hItem);
|
||||
STDMETHODIMP AddExtension(HSCOPEITEM hItem, LPCLSID lpClsid);
|
||||
// -IConsoleNameSpace2
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ CMainWnd::CMainWnd()
|
||||
, m_nConsoleCount(0)
|
||||
, m_AppAuthorMode(false)
|
||||
, m_hSnapinImageList(NULL)
|
||||
, m_NextViewId(1)
|
||||
{
|
||||
m_FrameThunk.Init(XDefFrameProc, this);
|
||||
m_pfnSuperWindowProc = m_FrameThunk.GetWNDPROC();
|
||||
@@ -277,3 +278,34 @@ CMainWnd::SnapinImageList()
|
||||
{
|
||||
return m_hSnapinImageList;
|
||||
}
|
||||
|
||||
int
|
||||
CMainWnd::RegisterView(CConsoleWnd *pView)
|
||||
{
|
||||
m_ViewList.AddTail(pView);
|
||||
return m_NextViewId++;
|
||||
}
|
||||
|
||||
void
|
||||
CMainWnd::UnregisterView(CConsoleWnd *pView)
|
||||
{
|
||||
POSITION pos = m_ViewList.Find(pView);
|
||||
if (pos)
|
||||
m_ViewList.RemoveAt(pos);
|
||||
}
|
||||
|
||||
void
|
||||
CMainWnd::UpdateViews()
|
||||
{
|
||||
CConsoleWnd *console;
|
||||
POSITION pos;
|
||||
|
||||
pos = m_ViewList.GetHeadPosition();
|
||||
do
|
||||
{
|
||||
console = (CConsoleWnd*)m_ViewList.GetNext(pos);
|
||||
if (console)
|
||||
console->UpdateView();
|
||||
|
||||
} while (pos != NULL);
|
||||
}
|
||||
|
||||
@@ -24,6 +24,9 @@ private:
|
||||
CSimpleArray<CSnapinCacheEntry*> m_SnapinCache;
|
||||
HIMAGELIST m_hSnapinImageList;
|
||||
|
||||
CAtlList<CConsoleWnd*> m_ViewList;
|
||||
int m_NextViewId;
|
||||
|
||||
public:
|
||||
CWindow m_MDIClient;
|
||||
|
||||
@@ -137,11 +140,14 @@ public:
|
||||
|
||||
private:
|
||||
LRESULT LoadSnapinCache();
|
||||
void UpdateViews();
|
||||
|
||||
public:
|
||||
int GetSnapinCacheCount();
|
||||
CSnapinCacheEntry *GetSnapinCacheEntry(int nIndex);
|
||||
CSnapinCacheEntry *GetSnapinCacheEntryByGuid(PWSTR pszGuid);
|
||||
HIMAGELIST SnapinImageList();
|
||||
int RegisterView(CConsoleWnd *pView);
|
||||
void UnregisterView(CConsoleWnd *pView);
|
||||
};
|
||||
|
||||
|
||||
@@ -5,7 +5,9 @@ include_directories(${REACTOS_SOURCE_DIR}/sdk/lib/atl)
|
||||
add_definitions(-D_ATL_NO_EXCEPTIONS)
|
||||
|
||||
list(APPEND CPP_SOURCE
|
||||
CConsoleWnd.cpp
|
||||
CMainWnd.cpp
|
||||
CSnapin.cpp
|
||||
CSnapinCacheEntry.cpp
|
||||
mmc.cpp
|
||||
# This is here so that they show up in visual studio:
|
||||
|
||||
90
base/applications/mmc_new/CSnapin.cpp
Normal file
90
base/applications/mmc_new/CSnapin.cpp
Normal file
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* PROJECT: ReactOS Management Console
|
||||
* LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
|
||||
* PURPOSE: Retrieve / store information about a snapin
|
||||
* COPYRIGHT: Copyright 2017-2019 Mark Jansen (mark.jansen@reactos.org)
|
||||
* Copyright 2026 Eric Kohl (eric.kohl@reactos.org)
|
||||
*/
|
||||
|
||||
#include "precomp.h"
|
||||
|
||||
// https://web.archive.org/web/20010614160959/msdn.microsoft.com/library/psdk/mmc/mmc12apx02_8jc5.htm
|
||||
// https://msdn.microsoft.com/en-us/library/aa814846(v=vs.85).aspx
|
||||
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/aa815510(v=vs.85).aspx
|
||||
// MMC initializes a snap-in by calling the Initialize method of the IComponentData object.
|
||||
// During initialization, IComponentData should query the console for its IConsoleNamespace and IConsole interfaces using
|
||||
// the console's IUnknown interface pointer that is passed into the call to Initialize.
|
||||
// The snap-in should then cache the returned pointers and use them for calling IConsoleNamespace and IConsole interface methods.
|
||||
|
||||
|
||||
CSnapin::CSnapin(CSnapinCacheEntry *CacheEntry, PWSTR displayName)
|
||||
:m_CacheEntry(CacheEntry)
|
||||
{
|
||||
if (displayName)
|
||||
m_DisplayName = displayName;
|
||||
else
|
||||
m_DisplayName = m_CacheEntry->Name();
|
||||
}
|
||||
|
||||
CSnapin::~CSnapin()
|
||||
{
|
||||
}
|
||||
|
||||
const CAtlString& CSnapin::Name() const { return m_CacheEntry->Name(); }
|
||||
const CAtlString& CSnapin::Provider() const { return m_CacheEntry->Provider(); }
|
||||
const CAtlString& CSnapin::Description() const { return m_CacheEntry->Description(); }
|
||||
const CAtlString& CSnapin::Version() const { return m_CacheEntry->Version(); }
|
||||
const CAtlString& CSnapin::DisplayName() const { return m_DisplayName; }
|
||||
|
||||
CSnapinCacheEntry *CSnapin::GetCacheEntry()
|
||||
{
|
||||
return m_CacheEntry;
|
||||
}
|
||||
|
||||
void CSnapin::OnAdd(IConsole* console)
|
||||
{
|
||||
#if 0
|
||||
CComPtr<IComponentData> spComponentData;
|
||||
HRESULT hr = CoCreateInstance(m_Guid, NULL, CLSCTX_INPROC, IID_PPV_ARG(IComponentData, &spComponentData));
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
//CComPtr<IExtendPropertySheet> spPropertySheet;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void CSnapin::OnAccept(IConsole* console)
|
||||
{
|
||||
#if 0
|
||||
CComPtr<IComponentData> spComponentData;
|
||||
HRESULT hr = CoCreateInstance(m_Guid, NULL, CLSCTX_INPROC, IID_PPV_ARG(IComponentData, &spComponentData));
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
hr = spComponentData->Initialize(console);
|
||||
// CComponentData::CreatePropertyPages(
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
SCOPEDATAITEM item = { 0 };
|
||||
item.mask = SDI_STR | SDI_IMAGE | SDI_OPENIMAGE;
|
||||
|
||||
hr = spComponentData->GetDisplayInfo(&item);
|
||||
|
||||
printf("%S\n", item.displayname);
|
||||
|
||||
|
||||
CComPtr<IDataObject> spDataObject;
|
||||
|
||||
hr = spComponentData->QueryDataObject(NULL, CCT_SCOPE, &spDataObject);
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
//spDataObject->
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -27,165 +27,17 @@ private:
|
||||
CAtlString m_DisplayName;
|
||||
|
||||
public:
|
||||
CSnapin(CSnapinCacheEntry *CacheEntry, PWSTR displayName = NULL)
|
||||
:m_CacheEntry(CacheEntry)
|
||||
{
|
||||
if (displayName)
|
||||
m_DisplayName = displayName;
|
||||
else
|
||||
m_DisplayName = m_CacheEntry->Name();
|
||||
}
|
||||
CSnapin(CSnapinCacheEntry *CacheEntry, PWSTR displayName = NULL);
|
||||
~CSnapin();
|
||||
|
||||
~CSnapin()
|
||||
{
|
||||
}
|
||||
const CAtlString& Name() const;
|
||||
const CAtlString& Provider() const;
|
||||
const CAtlString& Description() const;
|
||||
const CAtlString& Version() const;
|
||||
const CAtlString& DisplayName() const;
|
||||
|
||||
const CAtlString& Name() const { return m_CacheEntry->Name(); }
|
||||
const CAtlString& Provider() const { return m_CacheEntry->Provider(); }
|
||||
const CAtlString& Description() const { return m_CacheEntry->Description(); }
|
||||
const CAtlString& Version() const { return m_CacheEntry->Version(); }
|
||||
const CAtlString& DisplayName() const { return m_DisplayName; }
|
||||
CSnapinCacheEntry *GetCacheEntry();
|
||||
|
||||
CSnapinCacheEntry *GetCacheEntry()
|
||||
{
|
||||
return m_CacheEntry;
|
||||
}
|
||||
|
||||
// const CAtlString& Name() const { return m_Name; }
|
||||
// const CAtlString& Provider() const { return m_Provider; }
|
||||
// int ImageIndex() const { return m_ImageIndex; }
|
||||
// const CAtlString& Description()
|
||||
// {
|
||||
// if (m_Description.IsEmpty() && m_SnapinAbout)
|
||||
// {
|
||||
// CComHeapPtr<WCHAR> Description;
|
||||
// if (!FAILED_UNEXPECTEDLY(m_SnapinAbout->GetSnapinDescription(&Description)))
|
||||
// {
|
||||
// m_Description = Description;
|
||||
// }
|
||||
// }
|
||||
// return m_Description;
|
||||
// }
|
||||
|
||||
|
||||
// void SetImageIndex(int index)
|
||||
// {
|
||||
// m_ImageIndex = index;
|
||||
// }
|
||||
|
||||
// HRESULT GetIcon(HICON* hAppIcon)
|
||||
// {
|
||||
// if (!m_SnapinAbout)
|
||||
// return E_NOINTERFACE;
|
||||
|
||||
// return m_SnapinAbout->GetSnapinImage(hAppIcon);
|
||||
// }
|
||||
|
||||
void OnAdd(IConsole* console)
|
||||
{
|
||||
#if 0
|
||||
CComPtr<IComponentData> spComponentData;
|
||||
HRESULT hr = CoCreateInstance(m_Guid, NULL, CLSCTX_INPROC, IID_PPV_ARG(IComponentData, &spComponentData));
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
//CComPtr<IExtendPropertySheet> spPropertySheet;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void OnAccept(IConsole* console)
|
||||
{
|
||||
#if 0
|
||||
CComPtr<IComponentData> spComponentData;
|
||||
HRESULT hr = CoCreateInstance(m_Guid, NULL, CLSCTX_INPROC, IID_PPV_ARG(IComponentData, &spComponentData));
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
hr = spComponentData->Initialize(console);
|
||||
// CComponentData::CreatePropertyPages(
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
SCOPEDATAITEM item = { 0 };
|
||||
item.mask = SDI_STR | SDI_IMAGE | SDI_OPENIMAGE;
|
||||
|
||||
hr = spComponentData->GetDisplayInfo(&item);
|
||||
|
||||
printf("%S\n", item.displayname);
|
||||
|
||||
|
||||
CComPtr<IDataObject> spDataObject;
|
||||
|
||||
hr = spComponentData->QueryDataObject(NULL, CCT_SCOPE, &spDataObject);
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
//spDataObject->
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#if 0
|
||||
static CSnapin* Create(CRegKey& key, PCWSTR guidString)
|
||||
{
|
||||
GUID guid;
|
||||
/* Not a guid, 'FX:' ?? */
|
||||
if (!SUCCEEDED(::CLSIDFromString(guidString, &guid)))
|
||||
return NULL;
|
||||
|
||||
CRegKey snapin;
|
||||
if (ERROR_SUCCESS != snapin.Open(key, guidString, KEY_READ))
|
||||
return NULL;
|
||||
|
||||
// Can we use this?
|
||||
CRegKey NodeTypes;
|
||||
if (ERROR_SUCCESS != NodeTypes.Open(snapin, L"StandAlone", KEY_READ))
|
||||
return NULL;
|
||||
|
||||
CAtlString Name;
|
||||
QueryString(snapin, L"NameStringIndirect", Name);
|
||||
if (!Name.IsEmpty())
|
||||
{
|
||||
WCHAR IndirectBuffer[MAX_PATH];
|
||||
if (SUCCEEDED(SHLoadIndirectString(Name.GetString(), IndirectBuffer, _countof(IndirectBuffer), NULL)))
|
||||
{
|
||||
Name = IndirectBuffer;
|
||||
}
|
||||
else
|
||||
{
|
||||
Name.Empty();
|
||||
}
|
||||
}
|
||||
if (Name.IsEmpty())
|
||||
QueryString(snapin, L"NameString", Name);
|
||||
|
||||
if (Name.IsEmpty())
|
||||
return NULL;
|
||||
|
||||
CAtlString Provider;
|
||||
QueryString(snapin, L"Provider", Provider);
|
||||
|
||||
CAtlString About;
|
||||
QueryString(snapin, L"About", About);
|
||||
|
||||
return new CSnapin(guid, Name, Provider, About);
|
||||
}
|
||||
|
||||
static void QueryString(CRegKey& key, PCWSTR Name, CAtlString& Value)
|
||||
{
|
||||
WCHAR Buffer[MAX_PATH];
|
||||
ULONG nChars = _countof(Buffer);
|
||||
|
||||
Value.Empty();
|
||||
// FIXME: if too short, allocate
|
||||
if (ERROR_SUCCESS == key.QueryStringValue(Name, Buffer, &nChars))
|
||||
{
|
||||
Value = Buffer;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
void OnAdd(IConsole* console);
|
||||
void OnAccept(IConsole* console);
|
||||
};
|
||||
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
#include <winuser.h>
|
||||
#include <commctrl.h>
|
||||
#include <commdlg.h>
|
||||
#include <tchar.h>
|
||||
#include <atlstr.h>
|
||||
#include <atlwin.h>
|
||||
#include <atlcom.h>
|
||||
@@ -43,7 +42,6 @@
|
||||
#include "CSnapin.h"
|
||||
#include "CConsoleWnd.h"
|
||||
#include "CMainWnd.h"
|
||||
#include "CImageList.h"
|
||||
#include "CAddDialog.h"
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user